Quellcode durchsuchen

动物状态调整

lvjincheng vor 4 Jahren
Ursprung
Commit
00b5fcd70a

+ 8 - 7
Assets/BowArrow/Scenes/GameChallengeScene/Wolf.cs

@@ -10,9 +10,12 @@ public class Wolf : TargetAnimal
     AnimationPlayer ap;
     //寻路代理
     NavMeshAgent agent;
+    //血量
+    [System.NonSerialized] public int hp = 1;
 
     void Awake()
     {
+        state = new State();
         ap = GetComponent<AnimationPlayer>();
         agent = GetComponent<NavMeshAgent>();
     }
@@ -80,15 +83,15 @@ public class Wolf : TargetAnimal
         arrow.Head().position = hitPoint + arrow.transform.forward * 0.1f;
         arrow.Hit();
         if (partName == "Leg" || partName == "Tail") {
-            state.hp -= 2;
+            hp -= 2;
         }
         else if (partName == "Body") {
-            state.hp -= 3;
+            hp -= 3;
         }
         else if (partName == "Head") {
-            state.hp -= 100;
+            hp -= 100;
         }
-        if (state.hp > 0) {
+        if (hp > 0) {
             Hurt();
         } else {
             Die(arrow);
@@ -519,8 +522,6 @@ public class Wolf : TargetAnimal
     //状态
     [System.Serializable]
     public class State {
-        //数值区
-        public int hp = 1;
         //动作区
         public bool staying = false;
         public bool moving = false;
@@ -552,7 +553,7 @@ public class Wolf : TargetAnimal
             this.movingTime = 0;
         }
     }
-    [SerializeField] public State state = new State();
+    [SerializeField] public State state;
 
     //委托
     public System.Action<Wolf> onDie;

+ 1 - 1
Assets/BowArrow/Scenes/GameChallengeScene/WolfHuntGameMode.cs

@@ -76,7 +76,7 @@ public class WolfHuntGameMode : ChallengeGameMode
         animalObject.SetActive(true);
 
         Wolf wolf = animalObject.GetComponent<Wolf>();
-        wolf.state.hp = animalStyleID == 1 ? 5 : 8;
+        wolf.hp = animalStyleID == 1 ? 5 : 8;
         wolf.ChangeColorByType(animalStyleID);
         wolf.RotateByWorldY(Random.value * 360);
         wolf.onDie += delegate(Wolf wf) {

+ 6 - 5
Assets/BowArrow/Scenes/GameChallengeScene/Yeji.cs

@@ -23,6 +23,7 @@ public class Yeji : TargetAnimal
 
     void Awake()
     {
+        state = new State();
         state.animal = this;
         animator = GetComponent<Animator>();
         agent = GetComponent<NavMeshAgent>();
@@ -203,7 +204,7 @@ public class Yeji : TargetAnimal
         }
 
         TreeAreaRecorder.AreaInfo targetAreaInfo;
-        bool hasCheckFlyDown = false;
+        bool needCheckFlyDown = false;
         void UpdateBehavior() {
             if (state.flyStaying) {
                 canFlyStayTime -= Time.deltaTime;
@@ -224,11 +225,11 @@ public class Yeji : TargetAnimal
             if (state.landing) return;
 
             if (state.flying && !state.down && !state.up) {
-                if (!hasCheckFlyDown) {
+                if (needCheckFlyDown) {
                     float downNeedTime = flyPlaneHeight / downSpeed;
                     float keyDistance = this.agent.speed * downNeedTime; //触发下降的水平距离阈值
                     if (Vector3.Distance(this.transform.position, this.agent.destination) < keyDistance) {
-                        hasCheckFlyDown = true;
+                        needCheckFlyDown = false;
                         if (Random.value < 0.6 && tryOccupyTree()) {
                             state.down = true;
                         } else {
@@ -253,7 +254,7 @@ public class Yeji : TargetAnimal
                 Vector3 newPos = YejiHuntGameMode.CalculateNewPosByTreePos(animalsBaseT, flyPlaneHeight, areaInfo);
                 SetDestination(newPos);
                 targetAreaInfo = areaInfo;
-                hasCheckFlyDown = false;
+                needCheckFlyDown = true;
             #endregion
         }
 
@@ -362,7 +363,7 @@ public class Yeji : TargetAnimal
         }
         public Yeji animal;
     }
-    [SerializeField] public State state = new State();
+    [SerializeField] public State state;
 
     //委托
     public System.Action<Yeji> onDie;

+ 1 - 1
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -8,7 +8,7 @@ using UnityEngine.SceneManagement;
 public class GameMgr : MonoBehaviour
 {
     public static bool debugInEditor = false;
-    public static int gameType = 5;
+    public static int gameType = 4;
     public GameMode gameMode;
     [System.NonSerialized] public bool gameOver = false;
     public static GameMgr ins;