ソースを参照

击飞击落落地后弹起来

WGL 3 ヶ月 前
コミット
43195590c6
1 ファイル変更20 行追加26 行削除
  1. 20 26
      ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

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

@@ -47,6 +47,7 @@ public class AttributeStatus : MonoBehaviour
     [TabGroup("击飞击落")] [LabelText("Y方向阻力")] public float decelerationRatioY = 15f;
     private Character landingDamageFrom;
     private Vector3 startFlyPos;
+    
     [TabGroup("击飞击落")] [LabelText("起飞预设角度")] public float startFlyAngle = 15f;
     [Tooltip("x为最小值,y为最大值")]
     [TabGroup("击飞击落")] [LabelText("飞行预设角速度随机范围")]  public Vector2 flyingRotateSpeedRange = new Vector2(15,45);
@@ -54,7 +55,8 @@ public class AttributeStatus : MonoBehaviour
     private Vector3 scale;
     [TabGroup("击飞击落")] [LabelText("压缩程度")] public float compressionDegree = 0.8f;
     [Tooltip("x为向下压缩经过的时间,y为回弹经过的时间")]
-    [TabGroup("击飞击落")] [LabelText("压缩速度")]  public Vector2 compressionSpeed =new Vector2(0.2f,1f);
+    [TabGroup("击飞击落")] [LabelText("压缩速度")]  public Vector2 compressionSpeed =new Vector2(0.2f,0.4f);
+    [TabGroup("击飞击落")] [LabelText("弹跳速度")] public float jumpVel = 5f;
 
     [TabGroup("易伤")]
     [DisplayOnly] public bool haveVulnerable;
@@ -293,23 +295,23 @@ public class AttributeStatus : MonoBehaviour
             case SpecialState.BlownUp:
             //击落
             case SpecialState.ShotDown:
+                Vector3 vel = rb.velocity;
                 switch (hitState)
                 {
                     case -1:
                         break;
                     case 0:
-                        Vector3 vel = rb.velocity;
                         if (isFly && foot.TrigGround && vel.y <= 0)
                         {
-                            vel = Vector3.zero;
                             if (!foot.haveGravity)
                             {
                                 character.transform.position = new Vector3(transform.position.x, character.platformPosY, transform.position.z);
-                                rb.useGravity = false;
+                                
                             }
                             character.ani.Play("weak", 0, 0);
                             character.bodyCollider.layer = character.gameObject.layer;
-                            rb.velocity = Vector3.zero;
+                            vel = vel/2f;
+                            vel.y = jumpVel;
                             character.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, character.platformRotZ);
                             character.mecanim.transform.rotation = Quaternion.Euler(0, 0, 0);
                             hitState = 1;
@@ -349,7 +351,6 @@ public class AttributeStatus : MonoBehaviour
                             character.mecanim.transform.Rotate(0,0, flyingRotateSpeed*Time.deltaTime);
                             isFly = true;
                         }
-                        rb.velocity = vel;
                         break;
                     case 1:
                         //眩晕状态
@@ -362,11 +363,21 @@ public class AttributeStatus : MonoBehaviour
                         }
                         else
                         {
+                            if (vel.x > 0)
+                            {
+                                vel.x -= decelerationRatioX * Time.deltaTime;
+                            }
+                            else
+                            {
+                                vel.x += decelerationRatioX * Time.deltaTime;
+                            }
+                            vel.y -= decelerationRatioY * Time.deltaTime;
                             
                             attributeTime -= Time.deltaTime;
                         }
                         break;
                 }
+                rb.velocity = vel;
                 break;
             //眩晕
             case SpecialState.Weak:
@@ -384,28 +395,11 @@ public class AttributeStatus : MonoBehaviour
     }
     void BounceEffect()
     {
-        float velocity = Mathf.Clamp(rb.velocity.y, 0, 10);
-        float squash = Mathf.Lerp(0.8f, 0.5f, velocity / 10f);
-
         Transform spine = character.mecanim.transform;
-        
         Sequence landSequence = DOTween.Sequence();
         landSequence.Append(spine.DOScaleY(scale.y * compressionDegree, compressionSpeed.x));
-        landSequence.Append(spine.DOScaleY(scale.y, compressionSpeed.y).SetEase(Ease.OutElastic));
-        //landSequence.Append(spine.DOScaleY(scale.y * 0.8f, 0.2f));
-        //landSequence.Append(spine.DOScaleY(scale.y, 1f).SetEase(Ease.OutElastic));
-
-        // 小弹跳
-        //if (velocity > 2f)
-        //{
-        //    landSequence.Append(transform.DOJump(
-        //        transform.position,
-        //        velocity * 0.1f,
-        //        1,
-        //        0.3f
-        //    ));
-        //}
-    }
+        landSequence.Append(spine.DOScaleY(scale.y, compressionSpeed.y));
+    }   
 
 
     public void OutSpecialState()
@@ -498,7 +492,7 @@ public class AttributeStatus : MonoBehaviour
         rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
         rb.transform.rotation = Quaternion.Euler(0, 0, 0);
         character.mecanim.transform.rotation = Quaternion.Euler(0, 0, startFlyAngle * attackDir);
-        flyingRotateSpeed =  UnityEngine.Random.Range(flyingRotateSpeedRange.x,flyingRotateSpeedRange.y) * attackDir;
+        flyingRotateSpeed = - UnityEngine.Random.Range(flyingRotateSpeedRange.x,flyingRotateSpeedRange.y) * attackDir;
         startFlyPos = transform.position;
         hitState = 0;
         isFly = false;