Эх сурвалжийг харах

修复击落击飞落地回弹会穿过桥面的问题

WGL 2 сар өмнө
parent
commit
5402aad0e9

+ 33 - 29
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -47,15 +47,15 @@ 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);
+    [TabGroup("击飞击落")] [LabelText("飞行预设角速度随机范围")] public Vector2 flyingRotateSpeedRange = new Vector2(15, 45);
     private float flyingRotateSpeed;
     private Vector3 scale;
     [TabGroup("击飞击落")] [LabelText("压缩程度")] public float compressionDegree = 0.8f;
     [Tooltip("x为向下压缩经过的时间,y为回弹经过的时间")]
-    [TabGroup("击飞击落")] [LabelText("压缩速度")]  public Vector2 compressionSpeed =new Vector2(0.2f,0.4f);
+    [TabGroup("击飞击落")] [LabelText("压缩速度")] public Vector2 compressionSpeed = new Vector2(0.2f, 0.4f);
     [TabGroup("击飞击落")] [LabelText("弹跳速度")] public float jumpVel = 5f;
 
     [TabGroup("易伤")]
@@ -70,7 +70,7 @@ public class AttributeStatus : MonoBehaviour
     [Serializable]
     public struct Resistances
     {
-        [LabelText("控制层级")]public int controlOrder;
+        [LabelText("控制层级")] public int controlOrder;
 
         //控制效果抗性
         [Range(0, 1)]
@@ -107,14 +107,14 @@ public class AttributeStatus : MonoBehaviour
         if (haveVulnerable)
         {
             vulnerableTime -= Time.deltaTime;
-            if(vulnerableTime <= 0)
+            if (vulnerableTime <= 0)
             {
                 haveVulnerable = false;
             }
         }
-        
+
         //累伤
-        if(stackingWordsNum > 0)
+        if (stackingWordsNum > 0)
         {
             stackingWoudsTime -= Time.deltaTime;
             if (stackingWoudsTime <= 0)
@@ -224,11 +224,11 @@ public class AttributeStatus : MonoBehaviour
 
 
         }
-        if(curSpecialStates == SpecialState.Null)
+        if (curSpecialStates == SpecialState.Null)
         {
             hitFeedbackSystem.EnterHitStun(attackFrom);
         }
-        
+
     }
 
     //CharacterState为SpecialStatus时调用此函数
@@ -306,14 +306,14 @@ public class AttributeStatus : MonoBehaviour
                             if (!foot.haveGravity)
                             {
                                 character.transform.position = new Vector3(transform.position.x, character.platformPosY, transform.position.z);
-                                
+
                             }
                             character.ani.Play("weak", 0, 0);
                             character.bodyCollider.layer = character.gameObject.layer;
-                            vel = vel/5f;
+                            vel = vel / 5f;
                             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);
+                            character.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, character.platformRotZ);
                             hitState = 1;
                             int landingDamage;
                             if (specialState == SpecialState.BlownUp)
@@ -332,14 +332,14 @@ public class AttributeStatus : MonoBehaviour
                                 if (attackInfo.shotDown.haveLandingDamage)
                                 {
                                     landingDamage = attackInfo.shotDown.landingDamage;
-                                    character.BeHit(attackInfo, landingDamageFrom,landingDamage);
+                                    character.BeHit(attackInfo, landingDamageFrom, landingDamage);
                                 }
                             }
                             BounceEffect();
                         }
                         else
                         {
-                            if(vel.x > 0)
+                            if (vel.x > 0)
                             {
                                 vel.x -= decelerationRatioX * Time.deltaTime;
                             }
@@ -348,7 +348,7 @@ public class AttributeStatus : MonoBehaviour
                                 vel.x += decelerationRatioX * Time.deltaTime;
                             }
                             vel.y -= decelerationRatioY * Time.deltaTime;
-                            character.mecanim.transform.Rotate(0,0, flyingRotateSpeed*Time.deltaTime);
+                            character.mecanim.transform.Rotate(0, 0, flyingRotateSpeed * Time.deltaTime);
                             isFly = true;
                         }
                         break;
@@ -371,8 +371,12 @@ public class AttributeStatus : MonoBehaviour
                             {
                                 vel.x += decelerationRatioX * Time.deltaTime;
                             }
-                            vel.y -= decelerationRatioY * Time.deltaTime;
-                            
+                            if (!foot.TrigGround || vel.y > 0.1f)
+                            {
+                                vel.y -= decelerationRatioY * Time.deltaTime;
+                            }
+
+
                             attributeTime -= Time.deltaTime;
                         }
                         break;
@@ -399,7 +403,7 @@ public class AttributeStatus : MonoBehaviour
         Sequence landSequence = DOTween.Sequence();
         landSequence.Append(spine.DOScaleY(scale.y * compressionDegree, compressionSpeed.x));
         landSequence.Append(spine.DOScaleY(scale.y, compressionSpeed.y));
-    }   
+    }
 
 
     public void OutSpecialState()
@@ -419,7 +423,7 @@ public class AttributeStatus : MonoBehaviour
     public bool PriorityOrder(SpecialState specialState, int controlOrder)
     {
         //控制层级小于控制抗性层级,该控制效果无效
-        if(controlOrder < resistances.controlOrder)
+        if (controlOrder < resistances.controlOrder)
         {
             return false;
         }
@@ -443,12 +447,13 @@ public class AttributeStatus : MonoBehaviour
     //受到漂浮
     public void AddFloat(AttackInfo attackInfo)
     {
-        if(resistances.Float == 1)
+        if (resistances.Float == 1)
         {
             return;
         }
         this.attackInfo = attackInfo;
         AttackInfo.FloatState floatState = attackInfo.floatState;
+        rb.isKinematic = false;
         rb.useGravity = false;
         floatingState = 1;
         origPos = character.transform.position;
@@ -470,7 +475,7 @@ public class AttributeStatus : MonoBehaviour
     //受到击飞
     public void AddBlowUp(AttackInfo attackInfo, Transform attackFrom)
     {
-        if(resistances.BlowUp == 1)
+        if (resistances.BlowUp == 1)
         {
             return;
         }
@@ -478,10 +483,10 @@ public class AttributeStatus : MonoBehaviour
         AttackInfo.BlowUp blowUp = attackInfo.blowUp;
         attributeTime = blowUp.time * (1 - resistances.BlowUp);
         Vector3 vec3 = new Vector3(
-            blowUp.dir.x + UnityEngine.Random.Range(-blowUp.dirRandom.x/2f, blowUp.dirRandom.x/2f),
-            blowUp.dir.y + UnityEngine.Random.Range(-blowUp.dirRandom.y/2f, blowUp.dirRandom.y/2f), 
+            blowUp.dir.x + UnityEngine.Random.Range(-blowUp.dirRandom.x / 2f, blowUp.dirRandom.x / 2f),
+            blowUp.dir.y + UnityEngine.Random.Range(-blowUp.dirRandom.y / 2f, blowUp.dirRandom.y / 2f),
             0).normalized;
-        int attackDir = 0; 
+        int attackDir = 0;
         switch (blowUp.directionType)
         {
             case AttackInfo.BlowUp.DirectionType.Common:
@@ -491,7 +496,7 @@ public class AttributeStatus : MonoBehaviour
                 attackDir = attackFrom.position.x < transform.position.x ? -1 : 1;
                 break;
         }
-        if(attackDir < 0)
+        if (attackDir < 0)
         {
             vec3.x = -vec3.x;
         }
@@ -505,7 +510,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;
@@ -515,7 +520,7 @@ public class AttributeStatus : MonoBehaviour
     //受到击落
     public void AddShotDown(AttackInfo attackInfo, Transform attackFrom)
     {
-        if(resistances.ShotDown == 1)
+        if (resistances.ShotDown == 1)
         {
             return;
         }
@@ -540,7 +545,6 @@ public class AttributeStatus : MonoBehaviour
         {
             vec3.x = -vec3.x;
         }
-        rb.isKinematic = false;
         rb.useGravity = true;
         rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
         rb.velocity = Vector3.zero;
@@ -558,7 +562,7 @@ public class AttributeStatus : MonoBehaviour
     //受到击晕
     public void AddWeak(AttackInfo attackInfo)
     {
-        if(resistances.Weak == 1)
+        if (resistances.Weak == 1)
         {
             return;
         }