Bläddra i källkod

修复脚底抹油问题

wgl 6 månader sedan
förälder
incheckning
83a2804815
1 ändrade filer med 36 tillägg och 11 borttagningar
  1. 36 11
      ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

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

@@ -43,12 +43,37 @@ public class AttributeStatus : MonoBehaviour
         switch (curSpecialStates[0])
         {
             case SpecialState.BlownUp:
-            case SpecialState.ShotDown:
                 if (rb.velocity.magnitude > 0)
                 {
                     //击飞中
                     Vector3 vel = rb.velocity;
-                    if (foot.TrigGround && vel.y <= 0)
+                    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(strikeStunTime > 0)
+                    {
+                        rb.velocity = Vector3.zero;
+                        strikeStunTime -= Time.deltaTime;
+                    }
+                }
+                break;
+            case SpecialState.ShotDown:
+                if (rb.velocity.magnitude > 0)
+                {
+                    //击落中
+                    Vector3 vel = rb.velocity;
+                    if (foot.TrigGround && vel.y <= 0.01f)
                     {
                         vel = Vector3.zero;
                     }
@@ -62,15 +87,15 @@ public class AttributeStatus : MonoBehaviour
                 else
                 {
                     //眩晕状态
-                    if(strikeStunTime <= 0)
+                    if (strikeStunTime <= 0)
                     {
-                        ////被击晕后上升
-                        //rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
-                        //rb.useGravity = false;
-                        //if (character.AdjustHeight())
-                        //{
-                        //    character.ChangeState(CharacterState.Idle);
-                        //}
+                        //被击晕后上升
+                        rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
+                        rb.useGravity = false;
+                        if (character.AdjustHeight())
+                        {
+                            character.ChangeState(CharacterState.Idle);
+                        }
                         character.ChangeState(CharacterState.Idle);
                     }
                     else
@@ -120,7 +145,7 @@ public class AttributeStatus : MonoBehaviour
     }
 
     //受到击晕
-    public void AddStun()
+    public void AddStun(AttackInfo.Stun stun)
     {
         character.ChangeState(CharacterState.SpecialStatus);
     }