瀏覽代碼

特殊角色不同击飞模式

wgl 5 月之前
父節點
當前提交
892de70aaa

+ 18 - 12
ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs

@@ -54,12 +54,15 @@ public class AttackInfo
     //击飞
     [Serializable]public struct BlowUp
     {
-        [LabelText("方向")]
-        public Vector3 dir;
-        [LabelText("力")]
-        public float force;
-        [LabelText("落地后眩晕时间")]
-        public float time;
+        public enum DirectionType
+        {
+            [LabelText("角色朝向方向")] Common,
+            [LabelText("X轴方向以角色为中心向外")] Spread,
+        }
+        [LabelText("击飞模式")] public DirectionType directionType;
+        [LabelText("方向")] public Vector3 dir;
+        [LabelText("力")] public float force;
+        [LabelText("落地后眩晕时间")] public float time;
     }
     private bool ShowBlowUpValue() => attackEffect.Contains(AttackEffect.BlowUp);
     [ShowIf("ShowBlowUpValue")][LabelText("击飞参数")]
@@ -68,12 +71,15 @@ public class AttackInfo
     //击落
     [Serializable]public struct ShotDown
     {
-        [LabelText("方向")]
-        public Vector3 dir;
-        [LabelText("力")]
-        public float force;
-        [LabelText("落地后眩晕时间")]
-        public float time;
+        public enum DirectionType
+        {
+            [LabelText("角色朝向方向")] Common,
+            [LabelText("X轴方向以角色为中心向外")] Spread,
+        }
+        [LabelText("击落模式")] public DirectionType directionType;
+        [LabelText("方向")] public Vector3 dir;
+        [LabelText("力")] public float force;
+        [LabelText("落地后眩晕时间")] public float time;
     }
     private bool ShowShotDownValue() => attackEffect.Contains(AttackEffect.ShotDown);
     [ShowIf("ShowShotDownValue")][LabelText("击落参数")]

+ 26 - 6
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -166,13 +166,13 @@ public class AttributeStatus : MonoBehaviour
                         break;
                     //击飞
                     case AttackEffect.BlowUp:
-                        AddBlowUp(attackInfo.blowUp, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                        AddBlowUp(attackInfo.blowUp, attackFrom.bodyTrans);
                         //虾兵特殊攻击先留着
                         //AddBlowUp(attackInfo.blowUp, attackFrom.transform.position.x < character.transform.position.x ? -1 : 1);
                         break;
                     //击落
                     case AttackEffect.ShotDown:
-                        AddShotDown(attackInfo.shotDown, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                        AddShotDown(attackInfo.shotDown, attackFrom.bodyTrans);
                         //虾兵特殊攻击先留着
                         //AddShotDown(attackInfo.shotDown, attackFrom.transform.position.x < character.transform.position.x ? -1 : 1);
                         break;
@@ -362,11 +362,21 @@ public class AttributeStatus : MonoBehaviour
     }
 
     //受到击飞
-    public void AddBlowUp(AttackInfo.BlowUp blowUp, float dir)
+    public void AddBlowUp(AttackInfo.BlowUp blowUp, Transform attackFrom)
     {
         attributeTime = blowUp.time * (1 - resistances.BlowUp);
         Vector3 vec3 = blowUp.dir.normalized;
-        if (dir < 0)
+        int attackDir = 0; 
+        switch (blowUp.directionType)
+        {
+            case AttackInfo.BlowUp.DirectionType.Common:
+                attackDir = attackFrom.localScale.x < 0 ? -1 : 1;
+                break;
+            case AttackInfo.BlowUp.DirectionType.Spread:
+                attackDir = attackFrom.position.x < transform.position.x ? -1 : 1;
+                break;
+        }
+        if (attackDir < 0)
         {
             vec3.x = -vec3.x;
         }
@@ -382,11 +392,21 @@ public class AttributeStatus : MonoBehaviour
     }
 
     //受到击落
-    public void AddShotDown(AttackInfo.ShotDown shotDown, float dir)
+    public void AddShotDown(AttackInfo.ShotDown shotDown, Transform attackFrom)
     {
         attributeTime = shotDown.time * (1 - resistances.ShotDown);
         Vector3 vec3 = shotDown.dir.normalized;
-        if (dir < 0)
+        int attackDir = 0;
+        switch (shotDown.directionType)
+        {
+            case AttackInfo.ShotDown.DirectionType.Common:
+                attackDir = attackFrom.localScale.x < 0 ? -1 : 1;
+                break;
+            case AttackInfo.ShotDown.DirectionType.Spread:
+                attackDir = attackFrom.position.x < transform.position.x ? -1 : 1;
+                break;
+        }
+        if (attackDir < 0)
         {
             vec3.x = -vec3.x;
         }