LAPTOP-OM1V99U2\永远de小亡灵 1 vuosi sitten
vanhempi
commit
f1b6b583cc

+ 1 - 1
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Assassin.prefab

@@ -190,7 +190,7 @@ MonoBehaviour:
   rb: {fileID: 2437299196472462355}
   distance: 0
   dashEffect: {fileID: 2254593709981819441}
-  moveSpeed: 25
+  moveSpeed: 30
   offset: 2
   targetDir: {x: 0, y: 0, z: 0}
   dashTime: 0.8

+ 65 - 10
ActionTowerDefense/Assets/Scripts/Spirits/DashEffect.cs

@@ -6,19 +6,34 @@ using UnityEngine;
 public class DashEffect : MonoBehaviour
 {
     public bool canHit;
-    public int damage;
-    public Vector3 force;
-    public bool changeHurt;
-    public float repelValue;
+    public bool isEnemy;
+    public bool isDash;
+    public bool isDashAttack;
+    public AttackInfo attackInfo;
     public List<Character> beHitTriggers = new List<Character>();
     public List<GameObject> enemy = new List<GameObject>();
     public float offset;
     public GameObject rushEffect;
     public float targetY;
+    private void Awake()
+    {
+        if (isEnemy)
+        {
+            attackInfo = GetComponentInParent<Enemy>().attack1Infos[0];
+        }
+        else
+        {
+            attackInfo = GetComponentInParent<Demonic>().attack1Infos[0];
+        }
+        
+    }
     private void Update()
     {
+
+
         if (canHit)
         {
+
             transform.gameObject.SetActive(false);
         }
     }
@@ -43,16 +58,56 @@ public class DashEffect : MonoBehaviour
     //        }
     //    }
     //}
+    private void OnTriggerStay(Collider other)
+    {
+        if (isDash)
+        {
+            if (isEnemy && (other.gameObject.layer == 6 || other.gameObject.layer == 7)
+                && other.name == "BodyCollider")
+            {
+                Character character = other.GetComponentInParent<Character>();
+                DashAttack(character);
+            }
+            isDash = false;
+        }
+    }
     private void OnTriggerEnter(Collider other)
     {
-        if(other.gameObject.layer == 8 && other.name == "BodyCollider")
+        
+        if(!isEnemy && other.gameObject.layer == 8 && other.name == "BodyCollider")
+        {
+            Character character = other.GetComponentInParent<Character>();
+            beHitTriggers.Add(character);
+            //enemy.Add(other.transform.parent.parent.parent.gameObject);
+            DashAttack(character);
+        }
+        if (isEnemy && (other.gameObject.layer == 6|| other.gameObject.layer == 7)
+            && other.name == "BodyCollider")
         {
-            //beHitTriggers.Add(other.GetComponentInParent<Character>());
+            Character character = other.GetComponentInParent<Character>();
+            //beHitTriggers.Add(character);
             //enemy.Add(other.transform.parent.parent.parent.gameObject);
-            other.GetComponentInParent<Character>().BeHit(damage, force, changeHurt, repelValue);
-            GameObject effect = Instantiate(rushEffect);
-            effect.transform.position = new Vector3(other.transform.position.x,
-                transform.position.y + targetY,0);
+            if (isDashAttack)
+            {
+                DashAttack(character);
+            }
+            
         }
     }
+    private void OnTriggerExit(Collider other)
+    {
+        if (other.gameObject.layer == 8 && other.name == "BodyCollider")
+        {
+            beHitTriggers.Remove(other.GetComponentInParent<Character>());
+            //enemy.Add(other.transform.parent.parent.parent.gameObject);
+        }
+    }
+    public void DashAttack(Character character)
+    {
+        character.BeHit(attackInfo.damage,attackInfo.force * attackInfo.attackDir * offset, 
+            attackInfo.changeHurt,attackInfo.repelValue);
+        GameObject effect = Instantiate(rushEffect);
+        effect.transform.position = new Vector3(character.transform.position.x,
+            transform.position.y + targetY, 0);
+    }
 }

+ 22 - 6
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Assassin.cs

@@ -29,6 +29,11 @@ public class ESpirits_Assassin : MonoBehaviour
     public Vector3 targetDir;
     public float dashTime;
     private void Update()
+    {
+
+        OnState();
+    }
+    public void OnState()
     {
         switch (state)
         {
@@ -75,17 +80,28 @@ public class ESpirits_Assassin : MonoBehaviour
                 if (time >= dashTime)
                 {
                     rb.velocity = Vector3.zero;
-                    dashEffect.isDashAttack = false;
                     time = 0;
-                    state = AssassinState.Normal;
-                    enemy.isSpiritsAttack = false;
-                    enemy.searchState = SearchState.NoTarget;
-                    enemy.ChangeState(CharacterState.Idle);
+                    if (enemy.foot.TrigGround)
+                    {
+
+                        dashEffect.isDashAttack = false;
+                        state = AssassinState.Normal;
+                        enemy.isSpiritsAttack = false;
+                        enemy.searchState = SearchState.NoTarget;
+                        enemy.ChangeState(CharacterState.Idle);
+                    }
+                    else
+                    {
+                        state = AssassinState.Down;
+                    }
+
 
                 }
+                break;
+            case AssassinState.Down:
+
                 break;
         }
-       
     }
     public void ChosePlayer()
     {