Переглянути джерело

可控制飞行高度怪物状态添加,修复白鹭y轴锁死

GrainFull 3 місяців тому
батько
коміт
29f0793e40

+ 3 - 1
ActionTowerDefense/Assets/Resources/Prefab/Enemy/Enemy_1014.prefab

@@ -1281,6 +1281,7 @@ MonoBehaviour:
   totalHp: 50
   hp: 0
   canFly: 1
+  canControlFly: 1
   nowCanFly: 0
   canNotShotDown: 1
   canNotAddForce: 0
@@ -1342,9 +1343,9 @@ MonoBehaviour:
   sustainedInjury_damage: 0
   heavyDamage: 0
   killer: {fileID: 0}
+  exp: 1
   tag: 0
   dieEffect: {fileID: 417478504669294145, guid: 71b8503fcde80984c9c72cdff74b849a, type: 3}
-  exp: 1
   name: 
   baseSortingOrder: 2001
   isBack: 0
@@ -1363,6 +1364,7 @@ MonoBehaviour:
   attackRatio: 0
   dropSoulMax: 2
   dropSoulMin: 1
+  dropProbability: 100
   dropSoulAngle: 120
   canEscape: 0
   stopEscapeCD: 0

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

@@ -98,6 +98,7 @@ public class Character : MonoBehaviour
 
     [Header("角色状态")]
     public bool canFly = false;
+    public bool canControlFly = false;
     [HideInInspector] public bool nowCanFly; //当前是否能飞行
     [LabelText("不会被击落,用于让不可飞行怪可以被击落")] public bool canNotShotDown = true;
     [LabelText("不会被击飞")] public bool canNotAddForce;
@@ -160,11 +161,16 @@ public class Character : MonoBehaviour
         //血量重置
         hp = totalHp;
         nowCanFly = canFly;
-        if (canFly)
+        if (canFly && !canControlFly)
         {
             rb.useGravity = false;
             rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
         }
+        else if (canFly && canControlFly)
+        {
+            rb.useGravity = false;
+            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
+        }
         uiHp.Show(hp, totalHp);
         ChangeState(CharacterState.Idle);
 
@@ -305,6 +311,10 @@ public class Character : MonoBehaviour
 
     public void ChangeStateText(CharacterState state)
     {
+        if (!statePre)
+        {
+            return;
+        }
         GameObject obj = PoolManager.Instantiate(statePre);
         stateText = obj.GetComponentInChildren<TextMeshProUGUI>();
         obj.transform.position = transform.position + Vector3.up;