Explorar el Código

爆炸预制体增加对塔也能造成伤害选项

LAPTOP-OM1V99U2\永远de小亡灵 hace 1 año
padre
commit
64d41e2bec
Se han modificado 1 ficheros con 19 adiciones y 8 borrados
  1. 19 8
      ActionTowerDefense/Assets/Scripts/Spirits/SoulBoom.cs

+ 19 - 8
ActionTowerDefense/Assets/Scripts/Spirits/SoulBoom.cs

@@ -13,6 +13,8 @@ public class SoulBoom : MonoBehaviour
     public float destroyTime;       //消失时间
     public List<MoveCharacter> characters = new List<MoveCharacter>();  //被炸到的对象
 
+    public bool canHitTower;      //也对塔造成伤害
+
     private void Update()
     {
         time += Time.deltaTime;
@@ -64,21 +66,30 @@ public class SoulBoom : MonoBehaviour
     private void OnTriggerEnter(Collider other)
     {
         BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
-        if (beHitTrigger != null
-            && (other.transform.parent.parent.parent.gameObject.layer == 6
-            || other.transform.parent.parent.parent.gameObject.layer == 7))
+        if (beHitTrigger != null)
         {
-            MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
-            if (character.rb == null)
+            if(other.transform.parent.parent.parent.gameObject.layer == 6
+            || other.transform.parent.parent.parent.gameObject.layer == 7)
             {
-                character = character.transform.parent.GetComponent<MoveCharacter>();
+                MoveCharacter character = other.GetComponentInParent<MoveCharacter>();
+                if (character.rb == null)
+                {
+                    character = character.transform.parent.GetComponent<MoveCharacter>();
 
+                }
+                if (!characters.Exists(t => t == character))
+                {
+                    characters.Add(character);
+                }
             }
-            if (!characters.Exists(t => t == character))
+            Tower tower = other.GetComponentInParent<Tower>();
+            if (canHitTower && tower != null)
             {
-                characters.Add(character);
+                tower.BeHit(attackInfo.damage, attackInfo.force* Vector3.zero,attackInfo.changeHurt,attackInfo.repelValue);
             }
         }
+        
+        
     }
 
     private void OnTriggerExit(Collider other)