Browse Source

修复一直眩晕问题,修复击落后一直不动问题

wgl 6 tháng trước cách đây
mục cha
commit
1b7880ae32

+ 36 - 30
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -46,9 +46,9 @@ public class AttributeStatus : MonoBehaviour
     }
     [LabelText("抗性")]public Resistances resistances;
 
-    [Header("被击飞阻力")]
-    public float decelerationRatioX = 2f;
-    public float decelerationRatioY = 15f;
+    [FoldoutGroup("击飞/击落")] [DisplayOnly] public int hitState;
+    [FoldoutGroup("击飞/击落")] [LabelText("X方向阻力")] public float decelerationRatioX = 2f;
+    [FoldoutGroup("击飞/击落")] [LabelText("Y方向阻力")] public float decelerationRatioY = 15f;
 
     [FoldoutGroup("漂浮")]
     [DisplayOnly]public int floatingState;      //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
@@ -148,34 +148,38 @@ public class AttributeStatus : MonoBehaviour
             case SpecialState.BlownUp:
             //击落
             case SpecialState.ShotDown:
-                if (rb.velocity.magnitude > 0)
+                switch (hitState) 
                 {
-                    //击飞中
-                    Vector3 vel = rb.velocity;
-                    if (foot.TrigGround && vel.y <= 0.01f)
-                    {
-                        vel = Vector3.zero;
-                    }
-                    else
-                    {
-                        vel.x -= decelerationRatioX * Time.deltaTime;
-                        vel.y -= decelerationRatioY * Time.deltaTime;
-                    }
-                    rb.velocity = vel;
-                }
-                else
-                {
-                    //眩晕状态
-                    if (attributeTime <= 0)
-                    {
-                        character.isAdjustHeight = 1;
-                        OutSpecialState();
-                    }
-                    else
-                    {
-                        rb.velocity = Vector3.zero;
-                        attributeTime -= Time.deltaTime;
-                    }
+                    case 0:
+                        if(rb.velocity.magnitude > 0)
+                        {
+                            Vector3 vel = rb.velocity;
+                            if (foot.TrigGround && vel.y <= 0.01f)
+                            {
+                                vel = Vector3.zero;
+                                hitState = 1;
+                            }
+                            else
+                            {
+                                vel.x -= decelerationRatioX * Time.deltaTime;
+                                vel.y -= decelerationRatioY * Time.deltaTime;
+                            }
+                            rb.velocity = vel;
+                        }
+                        break;
+                    case 1:
+                        //眩晕状态
+                        if (attributeTime <= 0)
+                        {
+                            character.isAdjustHeight = 1;
+                            OutSpecialState();
+                        }
+                        else
+                        {
+                            rb.velocity = Vector3.zero;
+                            attributeTime -= Time.deltaTime;
+                        }
+                        break;
                 }
                 break;
             //眩晕
@@ -271,6 +275,7 @@ public class AttributeStatus : MonoBehaviour
         rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
         curSpecialStates = SpecialState.BlownUp;
         character.ani.Play("hitted",0,0);
+        hitState = 0;
         character.ChangeState(CharacterState.SpecialStatus_BlowUp);
     }
 
@@ -296,6 +301,7 @@ public class AttributeStatus : MonoBehaviour
         rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown), ForceMode.Impulse);
         curSpecialStates = SpecialState.ShotDown;
         character.ani.Play("hitted", 0, 0);
+        hitState = 0;
         character.ChangeState(CharacterState.SpecialStatus_ShotDown);
     }
 

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs

@@ -325,9 +325,9 @@ public class MoveCharacter : Character
                 Vector3 pos = transform.position;
                 pos.y = flyHeight;
                 transform.position = pos;
-                isAdjustHeight = 2;
             }
         }
+        isAdjustHeight = 2;
         return true;
     }
 }