修子弹击中多个敌人的bug
This commit is contained in:
parent
50720f393c
commit
a027e7752b
@ -87,6 +87,7 @@ public class Bullet : MonoBehaviour
|
||||
[Header("×Óµ¯ÅöײÌå")] public Collider2D Collider2D;
|
||||
[Header("×Óµ¯ÌØЧԤÖÆÌå")] public List<GameObject> effectPres=new List<GameObject>();
|
||||
private float timer = 0;
|
||||
[Header("子弹攻击数量")] public int NumberOfBulletAttacks = 1;
|
||||
private void Update()
|
||||
{
|
||||
switch (this.bulletMoveType)
|
||||
@ -118,11 +119,14 @@ public class Bullet : MonoBehaviour
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
//Debug.Log("进入检测范围");
|
||||
if (NumberOfBulletAttacks > 0)
|
||||
{
|
||||
NumberOfBulletAttacks -= 1;
|
||||
//Debug.Log("进入检测范围");
|
||||
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)
|
||||
{
|
||||
@ -131,20 +135,21 @@ public class Bullet : MonoBehaviour
|
||||
Crole.PlayerBuff.Add(buff);
|
||||
}
|
||||
}
|
||||
|
||||
Crole.ApplyBuffs();
|
||||
|
||||
Debug.Log(this.role.gameObject.name+"进行攻击计算");
|
||||
int direction=0;
|
||||
if (collision.transform.position.x>transform.position.x)//子弹打到敌人左边,飘字显示到右边
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role },direction);
|
||||
Debug.Log(this.role.gameObject.name + "进行攻击计算");
|
||||
int direction = 0;
|
||||
if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction);
|
||||
attackObj.bulltes.Remove(this.gameObject);
|
||||
|
||||
if (myBulletType!=BulletType.Spraying)
|
||||
{
|
||||
|
||||
if (myBulletType != BulletType.Spraying)
|
||||
{
|
||||
|
||||
|
||||
if (animator == null)
|
||||
@ -154,50 +159,57 @@ public class Bullet : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
IsMove = false;//停止移动
|
||||
Collider2D.enabled = false;//关闭碰撞体
|
||||
transform.position = collision.transform.position;
|
||||
IsMove = false; //停止移动
|
||||
Collider2D.enabled = false; //关闭碰撞体
|
||||
transform.position = collision.transform.position;
|
||||
animator.SetTrigger("Boom");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bulletAttributes == BulletAttributes.Not)//无属性
|
||||
{
|
||||
Crole.FlashRedEffect();
|
||||
|
||||
}
|
||||
|
||||
if (bulletAttributes==BulletAttributes.Fire)//火
|
||||
{
|
||||
|
||||
if (effectPres.Count==1)
|
||||
{
|
||||
GameObject go = Instantiate(effectPres[0], collision.transform);
|
||||
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y + 0.2f);
|
||||
go.GetComponent<Huo>().bullet = this;
|
||||
if (bulletAttributes == BulletAttributes.Not) //无属性
|
||||
{
|
||||
Crole.FlashRedEffect();
|
||||
//Debug.Log("创建火焰");
|
||||
|
||||
}
|
||||
|
||||
if (bulletAttributes == BulletAttributes.Fire) //火
|
||||
{
|
||||
|
||||
if (effectPres.Count == 1)
|
||||
{
|
||||
GameObject go = Instantiate(effectPres[0], collision.transform);
|
||||
go.transform.position = new Vector2(collision.transform.position.x,
|
||||
collision.transform.position.y + 0.2f);
|
||||
go.GetComponent<Huo>().bullet = this;
|
||||
Crole.FlashRedEffect();
|
||||
//Debug.Log("创建火焰");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (bulletAttributes == BulletAttributes.Water)//水
|
||||
|
||||
if (bulletAttributes == BulletAttributes.Water) //水
|
||||
{
|
||||
if (effectPres.Count > 1)
|
||||
{
|
||||
GameObject go = Instantiate(effectPres[Random.Range(0,effectPres.Count-1)], collision.transform);
|
||||
go.transform.position = new Vector2(collision.transform.position.x, collision.transform.position.y-0.2f);
|
||||
GameObject go = Instantiate(effectPres[Random.Range(0, effectPres.Count - 1)],
|
||||
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);
|
||||
Crole.FlashRedEffect(1,3f);
|
||||
Crole.FlashRedEffect(1, 3f);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private float lastDamageTime = 0f;
|
||||
private void OnTriggerStay2D(Collider2D collision)
|
||||
|
Loading…
Reference in New Issue
Block a user