wgl il y a 6 mois
Parent
commit
6db45b1a25

+ 1 - 5
ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs

@@ -27,6 +27,7 @@ public enum AttackEffect
 [Serializable]
 public class AttackInfo
 {
+    [LabelText("击打值")] public int attackValue;
     public int damage;
     public Vector3 attackDir;
     public AttackEffect[] attackEffect;
@@ -189,7 +190,6 @@ public class AttackController : MonoBehaviour
         [Header("攻击特效")]
         public GameObject attackEffect;
         [Header("攻击参数")]
-        public int attackValue;
         public AttackInfo attackInfo;
         public AttackTrigger attackTrigger;
         [Header("攻击距离")]
@@ -240,8 +240,6 @@ public class AttackController : MonoBehaviour
 
     [Header("攻击参数")]
     [DisplayOnly]
-    public int attackValue;
-    [DisplayOnly]
     public int curDamage;
     [HideInInspector]
     public bool canHitFly;
@@ -307,7 +305,6 @@ public class AttackController : MonoBehaviour
                     attackMethod[i].maxAttackDis);
             }
         }
-        attackValue = attackMethod[0].attackValue;
     }
 
     private void OnEnable()
@@ -324,7 +321,6 @@ public class AttackController : MonoBehaviour
         curAttackMethod = attackMethod[id];
         attackType = curAttackMethod.attackType;
         canHitFly = curAttackMethod.canHitFly;
-        attackValue = curAttackMethod.attackValue;
         armorPiercing = curAttackMethod.armorPiercing;
         attackInfo = curAttackMethod.attackInfo;
         curDamage = attackInfo.damage;

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

@@ -21,30 +21,9 @@ public class AttributeStatus : MonoBehaviour
     private Rigidbody rb;
     private Foot foot; 
 
-    public SpecialState curSpecialStates = SpecialState.Null;
+    [DisplayOnly] public SpecialState curSpecialStates = SpecialState.Null;
 
-    [Header("控制时间")]
-    [DisplayOnly] public float attributeTime;
-
-    //抗性
-    [Serializable]
-    public struct Resistances
-    {
-        //控制效果抗性
-        [Range(0, 1)][LabelText("漂浮抗性")]
-        public float Float;
-        [Range(0, 1)][LabelText("击飞抗性")]
-        public float BlowUp;
-        [Range(0, 1)][LabelText("击落抗性")]
-        public float ShotDown;
-        [Range(0, 1)][LabelText("击晕抗性")]
-        public float Weak;
-
-        [Space]
-        //非控制效果抗性
-        [LabelText("护甲值")]public int armor;
-    }
-    [LabelText("抗性")]public Resistances resistances;
+    [LabelText("控制时间")] [DisplayOnly] public float attributeTime;
 
     [TabGroup("漂浮")]
     [DisplayOnly] public int floatingState;      //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
@@ -68,6 +47,30 @@ public class AttributeStatus : MonoBehaviour
     [DisplayOnly] public float vulnerableTime;
     private float vulnerableRate;
 
+    //抗性
+    [Serializable]
+    public struct Resistances
+    {
+        //控制效果抗性
+        [Range(0, 1)]
+        [LabelText("漂浮抗性")]
+        public float Float;
+        [Range(0, 1)]
+        [LabelText("击飞抗性")]
+        public float BlowUp;
+        [Range(0, 1)]
+        [LabelText("击落抗性")]
+        public float ShotDown;
+        [Range(0, 1)]
+        [LabelText("击晕抗性")]
+        public float Weak;
+
+        [Space]
+        //非控制效果抗性
+        [LabelText("护甲值")] public int armor;
+    }
+    [LabelText("抗性")] public Resistances resistances;
+
     private void Awake()
     {
         character = GetComponentInParent<MoveCharacter>();

+ 1 - 0
ActionTowerDefense/Assets/Scripts/Characters/Character.cs

@@ -21,6 +21,7 @@ public enum CharacterState
     Rush = 9,
     Sprint = 10,
     Die = 11,
+    HitStun,                //½©Ö±
 
     //¿ØÖÆÐ§¹û
     SpecialStatus_Float,

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -518,6 +518,9 @@ public class Demonic : MoveCharacter
                     }
                 }
                 break;
+            case CharacterState.HitStun:
+                hitFeedbackSystem.HitStunUpdate();
+                break;
             case CharacterState.SpecialStatus_Float:
                 attributeStatus.SpecialStateEffect(SpecialState.FloatState);
                 break;

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -393,6 +393,9 @@ public class Enemy : MoveCharacter
                     break;
                 }
                 break;
+            case CharacterState.HitStun:
+                hitFeedbackSystem.HitStunUpdate();
+                break;
             case CharacterState.SpecialStatus_Float:
                 attributeStatus.SpecialStateEffect(SpecialState.FloatState);
                 break;

+ 24 - 13
ActionTowerDefense/Assets/Scripts/Characters/HitFeedbackSystem.cs

@@ -1,20 +1,20 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using Sirenix.OdinInspector;
 
 public class HitFeedbackSystem : MonoBehaviour
 {
     //组件
     private Character character;
 
-    //顿帧
-    public int freezeFrame;
-    [HideInInspector]
-    public bool isFreeze;
+    [TabGroup("顿帧")] public int freezeFrame;
+    [TabGroup("顿帧")] [DisplayOnly] public bool isFreeze;
     private RigidbodyConstraints origRC;
 
-    public float hitStunTime;
+    [TabGroup("僵直")] [DisplayOnly] public float hitStunTime;
 
+    private CharacterState characterState;  //僵直前状态
 
     private void Awake()
     {
@@ -44,25 +44,36 @@ public class HitFeedbackSystem : MonoBehaviour
         }
     }
 
+    public void HitStunUpdate()
+    {
+        if (hitStunTime <= 0)
+        {
+            character.ChangeState(characterState);
+        }
+        else
+        {
+            character.rb.velocity = Vector3.zero;
+            hitStunTime -= Time.deltaTime;
+        }
+    }
+
     //顿帧
-    public void FreezeFrame(int frame)
+    public void FreezeFrame()
     {
         if (!isFreeze)
         {
             origRC = character.rb.constraints;
         }
         isFreeze = true;
-        freezeFrame = frame;
         character.ani.speed = 0;
         character.rb.constraints = RigidbodyConstraints.FreezeAll;
     }
 
-    //受到击晕
-    public void EnterHitStun(float time)
+    //僵直
+    public void EnterHitStun()
     {
-        //attributeTime = weak.time * (1 - resistances.Weak);
-        //curSpecialStates = SpecialState.Weak;
-        //character.ani.Play("weak", 0, 0);
-        //character.ChangeState(CharacterState.SpecialStatus_Weak);
+        character.ani.Play("weak", 0, 0);
+        characterState = character.state;
+        character.ChangeState(CharacterState.HitStun);
     }
 }

+ 6 - 2
ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs

@@ -12,7 +12,7 @@ public class MoveCharacter : Character
     public Foot foot;
     [HideInInspector] public AttributeStatus attributeStatus;
     private ScreenReflectPresets screenReflectPresets;
-    private HitFeedbackSystem hitFeedbackSystem;
+    [HideInInspector] public HitFeedbackSystem hitFeedbackSystem;
 
     [Header("角色抗击打值")]
     public int hitResistance;
@@ -83,6 +83,7 @@ public class MoveCharacter : Character
         mats = mesh.materials;
         attributeStatus = GetComponentInChildren<AttributeStatus>();
         screenReflectPresets = Camera.main.GetComponentInParent<ScreenReflectPresets>();
+        hitFeedbackSystem = beHitTrigger.GetComponent<HitFeedbackSystem>();
     }
 
     private void Start()
@@ -217,7 +218,7 @@ public class MoveCharacter : Character
     //造成伤害附加其他效果
     public override void BeHit(AttackInfo attackInfo, Character attackFrom)
     {
-        screenReflectPresets.ScreenReflect(hitFeedbackSystem, attackFrom.attackController.attackValue - hitResistance);
+        screenReflectPresets.ScreenReflect(hitFeedbackSystem, attackInfo.attackValue - hitResistance);
         base.BeHit(attackInfo, attackFrom);
         int damage = attackInfo.damage;
         if (attackInfo.attackEffect.Length > 0)
@@ -289,6 +290,9 @@ public class MoveCharacter : Character
             ChangeState(CharacterState.Die);
             return;
         }
+
+        hitFeedbackSystem.EnterHitStun();
+        hitFeedbackSystem.FreezeFrame();
     }
 
     //受到持续伤害

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -1295,6 +1295,9 @@ public class PlayerController : MoveCharacter
                     ChangeState(CharacterState.Idle);
                 }
                 break;
+            case CharacterState.HitStun:
+                hitFeedbackSystem.HitStunUpdate();
+                break;
             case CharacterState.SpecialStatus_Float:
                 attributeStatus.SpecialStateEffect(SpecialState.FloatState);
                 break;

+ 1 - 1
ActionTowerDefense/Assets/Scripts/SystemReflect/ScreenReflectPresets.cs

@@ -37,7 +37,7 @@ public class ScreenReflectPresets : MonoBehaviour
 
     public void ScreenReflect(HitFeedbackSystem hfs, int x)
     {
-        for (int i = reflectPresets.Count; i > 0; i--)
+        for (int i = reflectPresets.Count - 1; i >= 0; i--)
         {
             if (x >= reflectPresets[i].minX)
             {