修子弹击中多个敌人的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,11 +119,14 @@ 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)
|
||||||
{
|
{
|
||||||
if(Crole.camp!= role.camp)
|
if (Crole.camp != role.camp)
|
||||||
{
|
{
|
||||||
foreach (var buff in role.storageBuff)
|
foreach (var buff in role.storageBuff)
|
||||||
{
|
{
|
||||||
@ -131,19 +135,20 @@ 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 + "进行攻击计算");
|
||||||
int direction=0;
|
int direction = 0;
|
||||||
if (collision.transform.position.x>transform.position.x)//子弹打到敌人左边,飘字显示到右边
|
if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边
|
||||||
{
|
{
|
||||||
direction = 1;
|
direction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role },direction);
|
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction);
|
||||||
attackObj.bulltes.Remove(this.gameObject);
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
|
|
||||||
if (myBulletType!=BulletType.Spraying)
|
if (myBulletType != BulletType.Spraying)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -154,27 +159,28 @@ public class Bullet : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IsMove = false;//停止移动
|
IsMove = false; //停止移动
|
||||||
Collider2D.enabled = false;//关闭碰撞体
|
Collider2D.enabled = false; //关闭碰撞体
|
||||||
transform.position = collision.transform.position;
|
transform.position = collision.transform.position;
|
||||||
animator.SetTrigger("Boom");
|
animator.SetTrigger("Boom");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bulletAttributes == BulletAttributes.Not)//无属性
|
if (bulletAttributes == BulletAttributes.Not) //无属性
|
||||||
{
|
{
|
||||||
Crole.FlashRedEffect();
|
Crole.FlashRedEffect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bulletAttributes==BulletAttributes.Fire)//火
|
if (bulletAttributes == BulletAttributes.Fire) //火
|
||||||
{
|
{
|
||||||
|
|
||||||
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("´´½¨»ðÑæ");
|
||||||
@ -183,22 +189,28 @@ public class Bullet : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bulletAttributes == BulletAttributes.Water)//水
|
if (bulletAttributes == BulletAttributes.Water) //水
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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