Răsfoiți Sursa

接入打击感效果

wgl 6 luni în urmă
părinte
comite
269ea9d316

+ 46 - 23
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -19,7 +19,12 @@ public class AttributeStatus : MonoBehaviour
     //组件
     private MoveCharacter character;
     private Rigidbody rb;
-    private Foot foot; 
+    private Foot foot;
+
+    //behit参数
+    [HideInInspector] public bool haveNewSpecialStates;
+    [HideInInspector] public AttackInfo attackInfo;
+    [HideInInspector] public Character attackFrom;
 
     [DisplayOnly] public SpecialState curSpecialStates = SpecialState.Null;
 
@@ -88,6 +93,36 @@ public class AttributeStatus : MonoBehaviour
         }
     }
 
+    public void AddSpecialState()
+    {
+        if (!haveNewSpecialStates)
+        {
+            return;
+        }
+        haveNewSpecialStates = false;
+        switch (curSpecialStates)
+        {
+            case SpecialState.FloatState:
+                AddFloat(attackInfo.floatState);
+                break;
+            case SpecialState.BlownUp:
+                if (rb.useGravity)
+                {
+                    AddBlowUp(attackInfo.blowUp, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                }
+                break;
+            case SpecialState.ShotDown:
+                if (!rb.useGravity)
+                {
+                    AddShotDown(attackInfo.shotDown, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                }
+                break;
+            case SpecialState.Weak:
+                AddWeak(attackInfo.weak);
+                break;
+        }
+    }
+
     //CharacterState为SpecialStatus时调用此函数
     public void SpecialStateEffect(SpecialState specialState)
     {
@@ -219,14 +254,22 @@ public class AttributeStatus : MonoBehaviour
     }
 
     //判断优先级,ture为优先级高于当前控制
-    public bool PriorityOrder(SpecialState specialState)
+    public bool PriorityOrder(SpecialState specialState,AttackInfo attackInfo,Character attackFrom)
     {
         if (curSpecialStates != SpecialState.Null && curSpecialStates <= specialState)
         {
+            curSpecialStates = specialState;
+            this.attackInfo = attackInfo;
+            this.attackFrom = attackFrom;
+            haveNewSpecialStates = true;
             return true;
         }
         if(curSpecialStates == SpecialState.Null)
         {
+            curSpecialStates = specialState;
+            this.attackInfo = attackInfo;
+            this.attackFrom = attackFrom;
+            haveNewSpecialStates = true;
             return true;
         }
         return true;
@@ -235,11 +278,6 @@ public class AttributeStatus : MonoBehaviour
     //受到漂浮
     public void AddFloat(AttackInfo.FloatState floatState)
     {
-        if (!PriorityOrder(SpecialState.FloatState))
-        {
-            return;
-        } 
-
         rb.useGravity = false;
         floatingState = 1;
         origPos = character.transform.position;
@@ -262,14 +300,7 @@ public class AttributeStatus : MonoBehaviour
     //受到击飞
     public void AddBlowUp(AttackInfo.BlowUp blowUp, float dir)
     {
-        if (!rb.useGravity)
-        {
-            return;
-        }
-        if (!PriorityOrder(SpecialState.BlownUp))
-        {
-            return;
-        }
+        
         attributeTime = blowUp.time * (1 - resistances.BlowUp);
         Vector3 vec3 = blowUp.dir.normalized;
         if (dir < 0)
@@ -290,10 +321,6 @@ public class AttributeStatus : MonoBehaviour
         {
             return;
         }
-        if (!PriorityOrder(SpecialState.ShotDown))
-        {
-            return;
-        }
         attributeTime = shotDown.time * (1 - resistances.ShotDown);
         Vector3 vec3 = shotDown.dir.normalized;
         if (dir < 0)
@@ -312,10 +339,6 @@ public class AttributeStatus : MonoBehaviour
     //受到击晕
     public void AddWeak(AttackInfo.Weak weak)
     {
-        if (!PriorityOrder(SpecialState.Weak))
-        {
-            return;
-        }
         attributeTime = weak.time * (1 - resistances.Weak);
         curSpecialStates = SpecialState.Weak;
         character.ani.Play("weak", 0, 0);

+ 37 - 10
ActionTowerDefense/Assets/Scripts/Characters/HitFeedbackSystem.cs

@@ -7,18 +7,22 @@ public class HitFeedbackSystem : MonoBehaviour
 {
     //组件
     private Character character;
+    private AttributeStatus attributeStatus;
 
     [TabGroup("顿帧")] public int freezeFrame;
     [TabGroup("顿帧")] [DisplayOnly] public bool isFreeze;
+    [HideInInspector] public bool canFreeze;
     private RigidbodyConstraints origRC;
 
     [TabGroup("僵直")] [DisplayOnly] public float hitStunTime;
+    [HideInInspector] public bool canHitStun;
 
-    private CharacterState characterState;  //僵直前状态
+    [DisplayOnly] public CharacterState characterState;  //僵直前状态
 
     private void Awake()
     {
         character = GetComponentInParent<MoveCharacter>();
+        attributeStatus = GetComponent<AttributeStatus>();
     }
 
     void Start()
@@ -48,7 +52,15 @@ public class HitFeedbackSystem : MonoBehaviour
     {
         if (hitStunTime <= 0)
         {
-            character.ChangeState(characterState);
+            if (attributeStatus.haveNewSpecialStates)
+            {
+                characterState = CharacterState.Idle;
+                attributeStatus.AddSpecialState();
+            }
+            else
+            {
+                character.ChangeState(characterState);
+            }
         }
         else
         {
@@ -60,20 +72,35 @@ public class HitFeedbackSystem : MonoBehaviour
     //顿帧
     public void FreezeFrame()
     {
-        if (!isFreeze)
+        if (canFreeze)
         {
-            origRC = character.rb.constraints;
+            canFreeze = false;
+            if (!isFreeze)
+            {
+                origRC = character.rb.constraints;
+            }
+            isFreeze = true;
+            character.ani.speed = 0;
+            character.rb.constraints = RigidbodyConstraints.FreezeAll;
         }
-        isFreeze = true;
-        character.ani.speed = 0;
-        character.rb.constraints = RigidbodyConstraints.FreezeAll;
     }
 
     //僵直
     public void EnterHitStun()
     {
-        character.ani.Play("weak", 0, 0);
-        characterState = character.state;
-        character.ChangeState(CharacterState.HitStun);
+        if (canHitStun)
+        {
+            canHitStun = false;
+            character.ani.Play("hitted", 0, 0);
+            if(character.state != CharacterState.HitStun)
+            {
+                characterState = character.state;
+            }
+            character.ChangeState(CharacterState.HitStun);
+        }
+        else
+        {
+            attributeStatus.AddSpecialState();
+        }
     }
 }

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

@@ -230,19 +230,19 @@ public class MoveCharacter : Character
                     /*¿ØÖÆ*/
                     //Ư¸¡
                     case AttackEffect.FloatState:
-                        attributeStatus.AddFloat(attackInfo.floatState);
+                        attributeStatus.PriorityOrder(SpecialState.FloatState, attackInfo, attackFrom);
                         break;
                     //»÷·É
                     case AttackEffect.BlowUp:
-                        attributeStatus.AddBlowUp(attackInfo.blowUp, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                        attributeStatus.PriorityOrder(SpecialState.BlownUp, attackInfo, attackFrom);
                         break;
                     //»÷Âä
                     case AttackEffect.ShotDown:
-                        attributeStatus.AddShotDown(attackInfo.shotDown, attackFrom.bodyTrans.localScale.x < 0 ? -1 : 1);
+                        attributeStatus.PriorityOrder(SpecialState.ShotDown, attackInfo, attackFrom);
                         break;
                     //»÷ÔÎ
                     case AttackEffect.Weak:
-                        attributeStatus.AddWeak(attackInfo.weak);
+                        attributeStatus.PriorityOrder(SpecialState.Weak, attackInfo, attackFrom);
                         break;
 
                     /*·Ç¿ØÖÆ*/

+ 2 - 0
ActionTowerDefense/Assets/Scripts/SystemReflect/ScreenReflectPresets.cs

@@ -50,9 +50,11 @@ public class ScreenReflectPresets : MonoBehaviour
                             break;
                         case ScreenReflectEffects.freezeFrame:
                             hfs.freezeFrame = sr.frame;
+                            hfs.canFreeze = true;
                             break;
                         case ScreenReflectEffects.hitStun:
                             hfs.hitStunTime = sr.time;
+                            hfs.canHitStun = true;
                             break;
                     }
                 }