wgl 6 miesięcy temu
rodzic
commit
02a88a95f4

+ 37 - 22
ActionTowerDefense/Assets/Scripts/Characters/AttackController.cs

@@ -15,11 +15,11 @@ public enum AttackEffect
     [LabelText("击晕")]Stun = 3, 
 
     //非控制
-    [LabelText("穿甲")]Armor = 100,
-    [LabelText("易伤")]Vulnerable = 101,
-    ChangeDamage = 102,       //更改攻击力
-    SustainedInjury = 103,    //持续伤害
-    Burn = 104,               //灼烧
+    [LabelText("穿甲")]Armor,
+    [LabelText("易伤")]Vulnerable,
+    ChangeDamage,       //更改攻击力
+    SustainedInjury,    //持续伤害
+    Burn = 104,         //灼烧
     //中毒
     //麻痹
 }
@@ -34,11 +34,16 @@ public class AttackInfo
     //漂浮
     [Serializable]public struct FloatState
     {
-        public float time;          //漂浮时间
-        public Vector2 upTime;      //上升最大耗时
-        public Vector2 backSpeed;   //往后退的速度
-        public Vector2 rotateSpeed; //旋转速度
-        public Vector2 height;      //上升高度
+        [LabelText("持续时间")]
+        public float time;   
+        [LabelText("上升最大耗时")]
+        public Vector2 upTime;    
+        [LabelText("往后退的速度")]
+        public Vector2 backSpeed;  
+        [LabelText("旋转速度")]
+        public Vector2 rotateSpeed; 
+        [LabelText("上升高度")]
+        public Vector2 height;  
     }
     private bool ShowFloatStateValue()
     {
@@ -50,9 +55,12 @@ public class AttackInfo
     //击飞
     [Serializable]public struct BlowUp
     {
-        public Vector3 dir; //击打的方向
-        public float force; //击打的力
-        public float time;  //落地后眩晕时间
+        [LabelText("方向")]
+        public Vector3 dir;
+        [LabelText("力")]
+        public float force;
+        [LabelText("落地后眩晕时间")]
+        public float time;
     }
     private bool ShowBlowUpValue()
     {
@@ -64,9 +72,12 @@ public class AttackInfo
     //击落
     [Serializable]public struct ShotDown
     {
-        public Vector3 dir; //击打的方向
-        public float force; //击打的力
-        public float time; //落地后眩晕时间
+        [LabelText("方向")]
+        public Vector3 dir;
+        [LabelText("力")]
+        public float force;
+        [LabelText("落地后眩晕时间")]
+        public float time;
     }
     private bool ShowShotDownValue()
     {
@@ -78,7 +89,8 @@ public class AttackInfo
     //击晕
     [Serializable]public struct Stun
     {
-        public float time;  //击晕时间
+        [LabelText("持续时间")]
+        public float time;
     }
     private bool ShowStunValue()
     {
@@ -90,7 +102,8 @@ public class AttackInfo
     //穿甲
     [Serializable]public struct Armor
     {
-        public int rate;  //穿甲率
+        [LabelText("穿甲值")]
+        public int rate;
     }
     private bool ShowArmorValue()
     {
@@ -100,10 +113,12 @@ public class AttackInfo
     public Armor armor;
 
     //易伤
-    [Searchable]public struct Vulnerable
+    [Serializable]public struct Vulnerable
     {
-        public float rate;  //伤害倍率
-        public float time;  //持续时间
+        [LabelText("倍率")]
+        public float rate;
+        [LabelText("持续时间")]
+        public float time; 
     }
     private bool ShowVulnerable()
     {
@@ -133,7 +148,7 @@ public class AttackInfo
     {
         return attackEffect.Contains(AttackEffect.SustainedInjury);
     }
-    [ShowIf("ShowSustainedInjuryValue")][LabelText("易伤参数")]
+    [ShowIf("ShowSustainedInjuryValue")][LabelText("持续伤害参数")]
     public SustainedInjury sustainedInjury;
 
     public void CopyTo(AttackInfo ai)

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

@@ -8,15 +8,10 @@ using Sirenix.OdinInspector;
 public enum SpecialState
 {
     Null = -1,
-
-    //控制
     FloatState = 0,
     ShotDown = 1,
     BlownUp = 2,
     Stun = 3,
-
-    //非控制
-    armor,
 }
 
 public class AttributeStatus : MonoBehaviour
@@ -26,7 +21,7 @@ public class AttributeStatus : MonoBehaviour
     private Rigidbody rb;
     private Foot foot; 
 
-    public List<SpecialState> curSpecialStates = new List<SpecialState> {SpecialState.Null};    //[0]存放控制类状态,没有则为SpecialState.Null,[1:]存放其他状态
+    public SpecialState curSpecialStates = SpecialState.Null;
 
     [Header("各状态时间")]
     [DisplayOnly] public float attributeTime;
@@ -55,7 +50,6 @@ public class AttributeStatus : MonoBehaviour
     public float decelerationRatioX = 2f;
     public float decelerationRatioY = 15f;
 
-    //漂浮
     [FoldoutGroup("漂浮")]
     [DisplayOnly]public int floatingState;      //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
     private Vector3 origPos;        //初始位置
@@ -68,6 +62,11 @@ public class AttributeStatus : MonoBehaviour
     private float rise = 1;
     private float normalFallSpeed = 15f;
 
+    [FoldoutGroup("易伤")]
+    [DisplayOnly][ToggleLeft] public bool haveVulnerable;
+    [DisplayOnly] public float vulnerableTime;
+    private float vulnerableRate;
+
     private void Awake()
     {
         character = GetComponent<MoveCharacter>();
@@ -75,6 +74,15 @@ public class AttributeStatus : MonoBehaviour
         foot = GetComponentInChildren<Foot>();
     }
 
+    public void Update()
+    {
+        vulnerableTime -= Time.deltaTime;
+        if (vulnerableTime <= 0)
+        {
+            haveVulnerable = false;
+        }
+    }
+
     //CharacterState为SpecialStatus时调用此函数
     public void SpecialStateEffect(SpecialState specialState)
     {
@@ -107,7 +115,7 @@ public class AttributeStatus : MonoBehaviour
                         {
                             floatingState = 0;
                             character.ChangeState(CharacterState.Idle);
-                            curSpecialStates[0] = SpecialState.Null;
+                            curSpecialStates = SpecialState.Null;
                             return;
                         }
                         break;
@@ -156,7 +164,7 @@ public class AttributeStatus : MonoBehaviour
                     //眩晕状态
                     if (attributeTime <= 0)
                     {
-                        curSpecialStates[0] = SpecialState.Null;
+                        curSpecialStates = SpecialState.Null;
                         character.ChangeState(CharacterState.Idle);
                     }
                     else
@@ -193,7 +201,7 @@ public class AttributeStatus : MonoBehaviour
                         rb.useGravity = false;
                         if (character.AdjustHeight())
                         {
-                            curSpecialStates[0] = SpecialState.Null;
+                            curSpecialStates = SpecialState.Null;
                             character.ChangeState(CharacterState.Idle);
                         }
                     }
@@ -208,7 +216,7 @@ public class AttributeStatus : MonoBehaviour
             case SpecialState.Stun:
                 if (attributeTime <= 0)
                 {
-                    curSpecialStates[0] = SpecialState.Null;
+                    curSpecialStates = SpecialState.Null;
                     character.ChangeState(CharacterState.Idle);
                 }
                 else
@@ -220,10 +228,16 @@ public class AttributeStatus : MonoBehaviour
         }
     }
 
+    public int DamageCalculation(int damage)
+    {
+        damage = (int)(damage * (1 + vulnerableRate) + 0.5f);
+        return damage;
+    }
+
     //判断优先级,ture为优先级高于当前控制
     public bool PriorityOrder(SpecialState specialState)
     {
-        if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < specialState)
+        if (curSpecialStates != SpecialState.Null && curSpecialStates < specialState)
         {
             return false;
         }
@@ -253,7 +267,7 @@ public class AttributeStatus : MonoBehaviour
         height = UnityEngine.Random.Range(floatState.height.x, floatState.height.y);
         attributeTime = floatState.time * (1 - resistances.Float);
 
-        curSpecialStates[0] = SpecialState.FloatState;
+        curSpecialStates = SpecialState.FloatState;
         character.ChangeState(CharacterState.SpecialStatus_Float);
     }
 
@@ -275,7 +289,7 @@ public class AttributeStatus : MonoBehaviour
             vec3.x = -vec3.x;
         }
         rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
-        curSpecialStates[0] = SpecialState.BlownUp;
+        curSpecialStates = SpecialState.BlownUp;
         character.ChangeState(CharacterState.SpecialStatus_BlowUp);
     }
 
@@ -299,7 +313,7 @@ public class AttributeStatus : MonoBehaviour
         rb.useGravity = true;
         rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
         rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown), ForceMode.Impulse);
-        curSpecialStates[0] = SpecialState.ShotDown;
+        curSpecialStates = SpecialState.ShotDown;
         character.ChangeState(CharacterState.SpecialStatus_ShotDown);
     }
 
@@ -311,7 +325,7 @@ public class AttributeStatus : MonoBehaviour
             return;
         }
         attributeTime = stun.time * (1 - resistances.Stun);
-        curSpecialStates[0] = SpecialState.Stun;
+        curSpecialStates = SpecialState.Stun;
         character.ChangeState(CharacterState.SpecialStatus_Stun);
     }
 
@@ -336,6 +350,8 @@ public class AttributeStatus : MonoBehaviour
     //受到易伤
     public void AddVulnerable(AttackInfo.Vulnerable vulnerable)
     {
-
+        vulnerableTime = vulnerable.time;
+        vulnerableRate = vulnerable.rate;
+        haveVulnerable = true;
     }
 }

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

@@ -244,10 +244,12 @@ public class MoveCharacter : Character
                         break;
                     //Ò×ÉË
                     case AttackEffect.Vulnerable:
+                        attributeStatus.AddVulnerable(attackInfo.vulnerable);
                         break;
                 }
             }
         }
+        damage = attributeStatus.DamageCalculation(damage);
 
         //É˺¦¼õÃâ
         if (isDamageReduction)