diff --git a/Role/Bullet.cs b/Role/Bullet.cs index 5d4383e..374dff9 100644 --- a/Role/Bullet.cs +++ b/Role/Bullet.cs @@ -119,73 +119,77 @@ public class Bullet : MonoBehaviour private void OnTriggerEnter2D(Collider2D collision) { - if (NumberOfBulletAttacks > 0) + Role Crole = collision.gameObject.GetComponent(); + if (Crole) { - NumberOfBulletAttacks -= 1; - //Debug.Log("进入检测范围"); - Role Crole = collision.gameObject.GetComponent(); - if (Crole) + if (Crole.camp != role.camp) { - if (Crole.camp != role.camp) + if (NumberOfBulletAttacks < 0) { - foreach (var buff in role.storageBuff) + return; + } + else + { + NumberOfBulletAttacks -= 1; + } + + foreach (var buff in role.storageBuff) + { + if (!Crole.PlayerBuff.Contains(buff)) { - if (!Crole.PlayerBuff.Contains(buff)) - { - Crole.PlayerBuff.Add(buff); - } + Crole.PlayerBuff.Add(buff); } + } - Crole.ApplyBuffs(); + Crole.ApplyBuffs(); - Debug.Log(this.role.gameObject.name + "进行攻击计算"); - int direction = 0; - if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边 + 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 (animator == null) { - direction = 1; + attackObj.bulltes.Remove(this.gameObject); + Destroy(this.gameObject); } - Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role }, direction); - attackObj.bulltes.Remove(this.gameObject); - - if (myBulletType != BulletType.Spraying) + else { + IsMove = false; //停止移动 + Collider2D.enabled = false; //关闭碰撞体 + transform.position = collision.transform.position; + animator.SetTrigger("Boom"); - - if (animator == null) - { - attackObj.bulltes.Remove(this.gameObject); - Destroy(this.gameObject); - } - else - { - IsMove = false; //停止移动 - Collider2D.enabled = false; //关闭碰撞体 - transform.position = collision.transform.position; - animator.SetTrigger("Boom"); - - } } + } - if (bulletAttributes == BulletAttributes.Not) //无属性 + 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; 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) //水 @@ -202,13 +206,8 @@ public class Bullet : MonoBehaviour } } - } } - else - { - - } } private float lastDamageTime = 0f; private void OnTriggerStay2D(Collider2D collision) diff --git a/Role/Role.cs b/Role/Role.cs index bb2482c..a8d51a4 100644 --- a/Role/Role.cs +++ b/Role/Role.cs @@ -36,6 +36,10 @@ public enum CharacterFlags land = 1 << 1, big = 1 << 2, min = 1 << 3, + FlyBig=fly|big, + FlyMin=fly|min, + LandBig = land | big, + LandMin = land | min, } ///