浏览代码

刺客英灵冲刺攻击

LAPTOP-OM1V99U2\永远de小亡灵 1 年之前
父节点
当前提交
1982302f5b

+ 24 - 4
ActionTowerDefense/Assets/Resources/Prefab/DashAttackEffect.prefab

@@ -11,6 +11,7 @@ GameObject:
   - component: {fileID: 8664237789312556553}
   - component: {fileID: 3035890298701611987}
   - component: {fileID: 2416267944528422428}
+  - component: {fileID: 2139017838250457536}
   m_Layer: 7
   m_Name: DashAttackTrigger
   m_TagString: Untagged
@@ -58,11 +59,30 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 028d37216b47ca446ba0037910919e25, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  damage: 50
-  attackDir: {x: -2, y: 1, z: 0}
-  force: 10000
+  canHit: 0
+  damage: 100
+  force: {x: 0, y: 0, z: 0}
   changeHurt: 1
-  repelValue: 31
+  repelValue: 51
+  beHitTriggers: []
+  enemy: []
+  offset: 2
+--- !u!54 &2139017838250457536
+Rigidbody:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2183721406926779447}
+  serializedVersion: 2
+  m_Mass: 1
+  m_Drag: 0
+  m_AngularDrag: 0.05
+  m_UseGravity: 0
+  m_IsKinematic: 0
+  m_Interpolate: 0
+  m_Constraints: 126
+  m_CollisionDetection: 0
 --- !u!1 &3022365896308084047
 GameObject:
   m_ObjectHideFlags: 0

+ 24 - 2
ActionTowerDefense/Assets/Resources/Prefab/Spirits_Assassin.prefab

@@ -188,6 +188,10 @@ MonoBehaviour:
   time: 0
   dashTime: 0.5
   dashAttackEffect: {fileID: 5100798150433256090}
+  offset: 2
+  dashEffect: {fileID: 5670168015807601097}
+  dir: {x: 2, y: 1, z: 0}
+  force: 1000
 --- !u!114 &2437299196472462353
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -962,7 +966,6 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   owner: {fileID: 0}
-  mainParent: {fileID: 2437299196472462361}
 --- !u!1 &8802879426389446295
 GameObject:
   m_ObjectHideFlags: 0
@@ -1090,14 +1093,22 @@ PrefabInstance:
       propertyPath: m_LocalEulerAnglesHint.z
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 2183721406926779447, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
+      propertyPath: m_Layer
+      value: 0
+      objectReference: {fileID: 0}
     - target: {fileID: 3022365896308084047, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
       propertyPath: m_Name
       value: DashAttackEffect
       objectReference: {fileID: 0}
     - target: {fileID: 3022365896308084047, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
-      propertyPath: m_IsActive
+      propertyPath: m_Layer
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 3022365896308084047, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
+      propertyPath: m_IsActive
+      value: 1
+      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
 --- !u!1 &5100798150433256090 stripped
@@ -1105,6 +1116,17 @@ GameObject:
   m_CorrespondingSourceObject: {fileID: 3022365896308084047, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
   m_PrefabInstance: {fileID: 8014213950561976277}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &5670168015807601097 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 2416267944528422428, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}
+  m_PrefabInstance: {fileID: 8014213950561976277}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 028d37216b47ca446ba0037910919e25, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!4 &9158931676160558098 stripped
 Transform:
   m_CorrespondingSourceObject: {fileID: 1162837953448672199, guid: b3895ed8d961d9d449084e8630a3293c, type: 3}

+ 28 - 12
ActionTowerDefense/Assets/Scripts/Spirits/DashEffect.cs

@@ -5,25 +5,41 @@ using UnityEngine;
 
 public class DashEffect : MonoBehaviour
 {
+    public bool canHit;
     public int damage;
-    public Vector3 attackDir;
-    public float force;
+    public Vector3 force;
     public bool changeHurt;
     public float repelValue;
-    private void OnTriggerEnter(Collider other)
+    public List<Character> beHitTriggers = new List<Character>();
+    public List<GameObject> enemy = new List<GameObject>();
+    public float offset;
+    private void Update()
     {
-        if(other.name == "BeHitTrigger")
+        if (canHit)
+        {
+            for (int i = 0; i < beHitTriggers.Count; i++)
+            {
+                beHitTriggers[i].BeHit(damage, force, changeHurt, repelValue);
+            }
+
+            transform.parent.gameObject.SetActive(false);
+        }
+        else
         {
             
-            BeHitTrigger beHitTrigger = other.GetComponent<BeHitTrigger>();
-            print(11111111);
-            //print(beHitTrigger.mainParent.tag);
-            //if (beHitTrigger.mainParent.CompareTag("Enemy"))
-            //{
+            for (int i = 0; i< enemy.Count; i++)
+            {
                 
-            //    beHitTrigger.BeHit(damage, attackDir*force, changeHurt, repelValue);
-            //}
-            
+                enemy[i].transform.position = transform.position + Vector3.right * offset;
+            }
+        }
+    }
+    private void OnTriggerEnter(Collider other)
+    {
+        if(other.gameObject.layer == 8)
+        {
+            beHitTriggers.Add(other.GetComponentInParent<Character>());
+            enemy.Add(other.transform.parent.parent.parent.gameObject);
         }
     }
 }

+ 9 - 1
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Dash.cs

@@ -12,6 +12,10 @@ public class Spirits_Dash : MonoBehaviour
     public float time;
     public float dashTime = 0.5f;
     public GameObject dashAttackEffect;
+    public float offset;
+    public DashEffect dashEffect;
+    public Vector3 dir;
+    public float force;
     private void Update()
     {
         if (isDash)
@@ -32,17 +36,21 @@ public class Spirits_Dash : MonoBehaviour
     void DashAttackEffect()
     {
         rb.velocity = Vector3.zero;
-        dashAttackEffect.SetActive(true);
+        dashEffect.canHit = true;
     }
     private void Dash()
     {
         if (demonic.bodyTrans.localScale.x < 0)
         {
             rb.velocity = Vector3.right * moveSpeed;
+            dashEffect.offset = offset;
+            dashEffect.force = new Vector3(dir.x *force,dir.y,0);
         }
         if (demonic.bodyTrans.localScale.x > 0)
         {
             rb.velocity = Vector3.left * moveSpeed;
+            dashEffect.offset = -offset;
+            dashEffect.force = new Vector3(dir.x * -force, dir.y, 0);
         }
     }
 }