From a027e7752b99a52e44fa99d92fc1178f4ee4af1c Mon Sep 17 00:00:00 2001 From: wulongxiao <2545507770@qq.com> Date: Wed, 25 Dec 2024 15:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=AD=90=E5=BC=B9=E5=87=BB=E4=B8=AD?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E6=95=8C=E4=BA=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Bullet.cs | 96 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/Role/Bullet.cs b/Role/Bullet.cs index 6e93553..ad1bc9d 100644 --- a/Role/Bullet.cs +++ b/Role/Bullet.cs @@ -87,6 +87,7 @@ public class Bullet : MonoBehaviour [Header("子弹碰撞体")] public Collider2D Collider2D; [Header("子弹特效预制体")] public List effectPres=new List(); 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(); - 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().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().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().SlowDown(0.2f, 3f); - Crole.FlashRedEffect(1,3f); + Crole.FlashRedEffect(1, 3f); + + } - } - } } + } + else + { + } } private float lastDamageTime = 0f; private void OnTriggerStay2D(Collider2D collision)