diff --git a/Role/Attack.cs b/Role/Attack.cs index c300014..59417ab 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -44,6 +44,7 @@ public class Attack : MonoBehaviour [Header("子弹围绕范围")] public float RunRange = 3f; [Header("是否造成额外伤害")] public bool haveAddDamage = false; [Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage; + [Header("子弹爆炸范围")] public float BoomRange = 1; public bool isAttack = true; public bool flag = false; [HideInInspector] public float timer = 0; diff --git a/Role/Bullet.cs b/Role/Bullet.cs index 336bb69..2e70920 100644 --- a/Role/Bullet.cs +++ b/Role/Bullet.cs @@ -84,7 +84,7 @@ public class Bullet : MonoBehaviour [Header("ʱ,Ĭ10f")] public float BulletDeadTimer = 10f; [Header("ӵ")] public Animator animator; [Header("ӵƶ")] public bool IsMove = true; - [Header("ӵײ")] public Collider2D Collider2D; + [Header("ӵײ")] public CircleCollider2D Collider2D; [Header("ӵЧԤ")] public List effectPres = new List(); private float timer = 0; [Header("ӵ")] public int NumberOfBulletAttacks = 1; @@ -92,6 +92,7 @@ public class Bullet : MonoBehaviour [Header("ӵǷĿ")] public bool noLockEnemy=false; [Header("ӵǷ")] public bool Cansplit = false; [Header("ӵԤ")] public GameObject smallBulletPrefab; + [Header("ӵǷᱬը")] public bool CanBoom = false; private void Update() { switch (this.bulletMoveType) @@ -167,28 +168,43 @@ public class Bullet : MonoBehaviour { direction = 1; } - Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent()), attackObj.damageTyp, role }, direction); - attackObj.bulltes.Remove(this.gameObject); - - if (myBulletType != BulletType.Spraying) + if (!CanBoom)//жӵǷᱬը { - - - if (animator == null) + Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent()), attackObj.damageTyp, role }, direction); + attackObj.bulltes.Remove(this.gameObject); + if (myBulletType != BulletType.Spraying) { - SplitBullet(); - attackObj.bulltes.Remove(this.gameObject); - Destroy(this.gameObject); + + + if (animator == null) + { + SplitBullet(); + attackObj.bulltes.Remove(this.gameObject); + Destroy(this.gameObject); + } + else + { + IsMove = false; //ֹͣƶ + Collider2D.enabled = false; //رײ + transform.position = collision.transform.position; + animator.SetTrigger("Boom"); + + } } - else + } + else + { + if (animator!=null) { IsMove = false; //ֹͣƶ Collider2D.enabled = false; //رײ transform.position = collision.transform.position; animator.SetTrigger("Boom"); - } } + + + if (bulletAttributes == BulletAttributes.Not) // { @@ -319,4 +335,38 @@ public class Bullet : MonoBehaviour } } } + + public void BulletBoom() // ӵը + { + + + // չײĴСģⱬըΧ + float explosionRadius = attackObj.BoomRange; // ñըİ뾶С + + + + // ⱬըΧڵĵ + Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(transform.position, explosionRadius); + + foreach (var enemyCollider in hitEnemies) + { + Role enemyRole = enemyCollider.gameObject.GetComponent(); + if (enemyRole != null && enemyRole.camp != role.camp) // ǵ˲ڲͬӪ + { + // ˺ֵԸӵͻ + float damage = role.DamageCreate(enemyRole); + + // Ѫ + enemyRole.bloodLoss(new object[] { enemyRole, damage, attackObj.damageTyp, role }); + + enemyRole.FlashRedEffect(); + } + } + + + // ٵǰӵ + attackObj.bulltes.Remove(this.gameObject); + Destroy(this.gameObject); + } + }