修子弹击中多个敌人的bug
This commit is contained in:
parent
50720f393c
commit
a027e7752b
@ -87,6 +87,7 @@ public class Bullet : MonoBehaviour
|
|||||||
[Header("子弹碰撞体")] public Collider2D Collider2D;
|
[Header("子弹碰撞体")] public Collider2D Collider2D;
|
||||||
[Header("子弹特效预制体")] public List<GameObject> effectPres=new List<GameObject>();
|
[Header("子弹特效预制体")] public List<GameObject> effectPres=new List<GameObject>();
|
||||||
private float timer = 0;
|
private float timer = 0;
|
||||||
|
[Header("×Óµ¯¹¥»÷ÊýÁ¿")] public int NumberOfBulletAttacks = 1;
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
switch (this.bulletMoveType)
|
switch (this.bulletMoveType)
|
||||||
@ -118,6 +119,9 @@ public class Bullet : MonoBehaviour
|
|||||||
|
|
||||||
private void OnTriggerEnter2D(Collider2D collision)
|
private void OnTriggerEnter2D(Collider2D collision)
|
||||||
{
|
{
|
||||||
|
if (NumberOfBulletAttacks > 0)
|
||||||
|
{
|
||||||
|
NumberOfBulletAttacks -= 1;
|
||||||
//Debug.Log("进入检测范围");
|
//Debug.Log("进入检测范围");
|
||||||
Role Crole = collision.gameObject.GetComponent<Role>();
|
Role Crole = collision.gameObject.GetComponent<Role>();
|
||||||
if (Crole)
|
if (Crole)
|
||||||
@ -131,6 +135,7 @@ public class Bullet : MonoBehaviour
|
|||||||
Crole.PlayerBuff.Add(buff);
|
Crole.PlayerBuff.Add(buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Crole.ApplyBuffs();
|
Crole.ApplyBuffs();
|
||||||
|
|
||||||
Debug.Log(this.role.gameObject.name + "进行攻击计算");
|
Debug.Log(this.role.gameObject.name + "进行攻击计算");
|
||||||
@ -174,7 +179,8 @@ public class Bullet : MonoBehaviour
|
|||||||
if (effectPres.Count == 1)
|
if (effectPres.Count == 1)
|
||||||
{
|
{
|
||||||
GameObject go = Instantiate(effectPres[0], collision.transform);
|
GameObject go = Instantiate(effectPres[0], collision.transform);
|
||||||
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y + 0.2f);
|
go.transform.position = new Vector2(collision.transform.position.x,
|
||||||
|
collision.transform.position.y + 0.2f);
|
||||||
go.GetComponent<Huo>().bullet = this;
|
go.GetComponent<Huo>().bullet = this;
|
||||||
Crole.FlashRedEffect();
|
Crole.FlashRedEffect();
|
||||||
//Debug.Log("创建火焰");
|
//Debug.Log("创建火焰");
|
||||||
@ -187,8 +193,10 @@ public class Bullet : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (effectPres.Count > 1)
|
if (effectPres.Count > 1)
|
||||||
{
|
{
|
||||||
GameObject go = Instantiate(effectPres[Random.Range(0,effectPres.Count-1)], collision.transform);
|
GameObject go = Instantiate(effectPres[Random.Range(0, effectPres.Count - 1)],
|
||||||
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y-0.2f);
|
collision.transform);
|
||||||
|
go.transform.position = new Vector2(collision.transform.position.x,
|
||||||
|
collision.transform.position.y - 0.2f);
|
||||||
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f);
|
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f);
|
||||||
Crole.FlashRedEffect(1, 3f);
|
Crole.FlashRedEffect(1, 3f);
|
||||||
|
|
||||||
@ -197,8 +205,12 @@ public class Bullet : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private float lastDamageTime = 0f;
|
private float lastDamageTime = 0f;
|
||||||
private void OnTriggerStay2D(Collider2D collision)
|
private void OnTriggerStay2D(Collider2D collision)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user