Răsfoiți Sursa

修复防御塔扣不了血问题

wgl 6 luni în urmă
părinte
comite
5624e58cf0

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

@@ -158,6 +158,32 @@ public class Character : MonoBehaviour
     //仅造成伤害
     public virtual void BeHit(int damage)
     {
+        hp -= damage;
+
+        //伤害跳字
+        if (showInjuryNum)
+        {
+            GameObject injuryNum = Instantiate(injuryNumText);
+            injuryNum.transform.position = new Vector3(transform.position.x + Random.Range(-1f, 1f), transform.position.y + 1, transform.position.z);
+            TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
+            text.text = damage.ToString();
+            if (gameObject.CompareTag("Player"))
+            {
+                text.color = Color.red;
+                if (debugAttackFrom)
+                {
+                    Debug.Log("主角受到" + damage.ToString() + "点伤害");
+                }
+            }
+        }
+
+
+        uiHp.Show(hp, totalHp);
+        if (hp <= 0)
+        {
+            ChangeState(CharacterState.Die);
+            return;
+        }
     }
 
     //造成伤害附加其他效果

+ 5 - 65
ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs

@@ -18,7 +18,6 @@ public class MoveCharacter : Character
 
     [Header("组件")]
     public Foot foot;
-    private ScreenShake ss;
     [HideInInspector]public AttributeStatus attributeStatus;
 
     [Header("额外重力")]
@@ -118,7 +117,6 @@ public class MoveCharacter : Character
         mesh = spinee.GetComponent<MeshRenderer>();
         mats = mesh.materials;
         origY = transform.position.y;
-        ss = Camera.main.GetComponentInParent<ScreenShake>();
         attributeStatus = GetComponent<AttributeStatus>();
     }
 
@@ -161,17 +159,6 @@ public class MoveCharacter : Character
 
     public void FloatStateOn()
     {
-        if (isInvisible)
-        {
-            return;
-        }
-        if (GetComponent<PlayerController>())
-        {
-            if (GetComponent<PlayerController>().isBaseBtnOut)
-            {
-                return;
-            }
-        }
         if (canMove)
         {
             canMove = false;
@@ -355,45 +342,7 @@ public class MoveCharacter : Character
     //仅造成伤害
     public override void BeHit(int damage)
     {
-        hp -= damage;
-
-        //伤害跳字
-        if (showInjuryNum)
-        {
-            GameObject injuryNum = Instantiate(injuryNumText);
-            injuryNum.transform.position = new Vector3(transform.position.x + Random.Range(-1f, 1f), transform.position.y + 1, transform.position.z);
-            TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
-            text.text = damage.ToString();
-            if (gameObject.CompareTag("Player"))
-            {
-                text.color = Color.red;
-                if (debugAttackFrom)
-                {
-                    Debug.Log("主角受到" + damage.ToString() + "点伤害");
-                }
-            }
-        }
-
-
-        uiHp.Show(hp, totalHp);
-        if (hp <= 0)
-        {
-            ChangeState(CharacterState.Die);
-            return;
-        }
-
-        if (gameObject.layer == 6)  //屏幕红闪+抖动
-        {
-            if (ss == null)
-            {
-                ss = Camera.main.GetComponentInParent<ScreenShake>();
-            }
-            ss.enabled = true;
-            if (isSustainedInjury || damage >= heavyDamage)
-            {
-                ss.HeavyShakeShine();
-            }       
-        }
+        base.BeHit(damage);
     }
 
     //造成伤害附加其他效果
@@ -405,6 +354,10 @@ public class MoveCharacter : Character
             {
                 switch (ae)
                 {
+                    //漂浮
+                    case AttackEffect.FloatState:
+                        attributeStatus.AddFloat(attackInfo.floatState);
+                        break;
                     //击飞
                     case AttackEffect.BlowUp:
                         attributeStatus.AddBlowUp(attackInfo.blowUp,dir);
@@ -460,19 +413,6 @@ public class MoveCharacter : Character
             ChangeState(CharacterState.Die);
             return;
         }
-
-        if (gameObject.layer == 6)  //屏幕红闪+抖动
-        {
-            if (ss == null)
-            {
-                ss = Camera.main.GetComponentInParent<ScreenShake>();
-            }
-            ss.enabled = true;
-            if (isSustainedInjury || damage >= heavyDamage)
-            {
-                ss.HeavyShakeShine();
-            }
-        }
     }
 
     //受到持续伤害

+ 32 - 4
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -37,6 +37,7 @@ public class PlayerController : MoveCharacter
     public Collider soulCollector;
     public SkeletonMecanim skeletonMecanim;
     private SpiritSystem spiritSystem;
+    private ScreenShake ss;
 
     [Header("血量")]
     private int curHp;
@@ -132,9 +133,6 @@ public class PlayerController : MoveCharacter
     public float reviveTime;        //复活时间
     public float totalReviveTime;
 
-    [Header("玩家是否在基地")]
-    public bool isBaseBtnOut = false;
-
     [Header("八卦")]
     public ChooseYinYang chooseYinYang;
 
@@ -385,6 +383,7 @@ public class PlayerController : MoveCharacter
     {
         base.Awake();
         PlayerInput playerInput = transform.GetComponent<PlayerInput>();
+        ss = Camera.main.GetComponentInParent<ScreenShake>();
         spirits = GetComponent<Spirits>();
         playerId = playerInput.playerIndex;
         transform.position = new Vector3(pos.x, pos.y, 0);
@@ -1613,7 +1612,6 @@ public class PlayerController : MoveCharacter
     public void PlayerRevive()
     {
         isRevive = false;
-        isBaseBtnOut = false;
         bodyTrans.gameObject.SetActive(true);
         uiHp.transform.parent.gameObject.SetActive(true);
         rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
@@ -2036,4 +2034,34 @@ public class PlayerController : MoveCharacter
     {
         targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
     }*/
+
+    public override void BeHit(int damage)
+    {
+        base.BeHit(damage);
+        //屏幕红闪+抖动
+        if (ss == null)
+        {
+            ss = Camera.main.GetComponentInParent<ScreenShake>();
+        }
+        ss.enabled = true;
+        if (isSustainedInjury || damage >= heavyDamage)
+        {
+            ss.HeavyShakeShine();
+        }
+    }
+
+    public override void BeHit(AttackInfo attackInfo, float dir)
+    {
+        base.BeHit(attackInfo, dir);
+        //屏幕红闪+抖动
+        if (ss == null)
+        {
+            ss = Camera.main.GetComponentInParent<ScreenShake>();
+        }
+        ss.enabled = true;
+        if (isSustainedInjury || attackInfo.damage >= heavyDamage)
+        {
+            ss.HeavyShakeShine();
+        }
+    }
 }

+ 5 - 20
ActionTowerDefense/Assets/Scripts/Tower/Tower.cs

@@ -133,26 +133,11 @@ public class Tower : Character
 
     public override void BeHit(int damage)
     {
-        hp -= damage;
-
-        //É˺¦Ìø×Ö
-        if (showInjuryNum)
-        {
-            GameObject injuryNum = Instantiate(injuryNumText);
-            injuryNum.transform.position = new Vector3(transform.position.x + Random.Range(-1f, 1f), transform.position.y + 1, transform.position.z);
-            TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
-            text.text = damage.ToString();
-            if (gameObject.CompareTag("Player"))
-            {
-                text.color = Color.red;
-            }
-        }
-
-        uiHp.Show(hp, totalHp);
-        if (hp <= 0)
-        {
-            ChangeState(CharacterState.Die);
-        }
+        base.BeHit(damage);
     }
 
+    public override void BeHit(AttackInfo attackInfo, float dir)
+    {
+        base.BeHit(attackInfo, dir);
+    }
 }