Bläddra i källkod

狼关卡-自动渲染玩家死亡

lvjincheng 3 år sedan
förälder
incheckning
657cad5699

+ 19 - 3
Assets/BowArrow/Scenes/GameChallengeScene/LocalPK/HunterGameView_LocalPK.cs

@@ -6,6 +6,7 @@ using UnityEngine.UI;
 public class HunterGameView_LocalPK : MonoBehaviour
 {
     int[] hitScores = {0, 0};
+    bool[] dieList = {false, false};
     int curPlayerIndex = -1;
     ChallengeGameModeLocalPK gameModeLocalPK;
     HunterGamePlayerScoreCounter scoreCounter;
@@ -48,6 +49,16 @@ public class HunterGameView_LocalPK : MonoBehaviour
                 RenderScore(i, scoreCounter.hitScores[i]);
             }
         }
+        //渲染死亡
+        if (ChallengeGameMode.IsChallengeWolf()) {
+            if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
+                ShowPlayerDie(((WolfHuntGameMode_LocalPK)gameModeLocalPK).playerDieList);
+            }
+            if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
+                
+            }
+        }
+        //游戏结束
         if (GameMgr.ins.gameOver) {
             this.transform.Find("CurrentPlayer").gameObject.SetActive(false);
         }
@@ -74,8 +85,13 @@ public class HunterGameView_LocalPK : MonoBehaviour
         this.transform.Find("ScoreBox/Item" + posNum + "/Score").GetComponent<Text>().text = "得分: " + score.ToString();
     }
 
-    public void ShowPlayerDie(int playerIndex) {
-        this.transform.Find("ScoreBox/Item" + playerIndex + "/IconDie").gameObject.SetActive(true);
-        this.transform.Find("ScoreBox/Item" + playerIndex + "/MaskDie").gameObject.SetActive(true);
+    public void ShowPlayerDie(bool[] playerDieList) {
+        for (int i = 0; i < playerDieList.Length; i++) {
+            if (playerDieList[i] && !dieList[i]) {
+                dieList[i] = true;
+                this.transform.Find("ScoreBox/Item" + i + "/IconDie").gameObject.SetActive(true);
+                this.transform.Find("ScoreBox/Item" + i + "/MaskDie").gameObject.SetActive(true);
+            }
+        }
     }
 }

+ 2 - 1
Assets/BowArrow/Scripts/Manager/GameMode/WolfHuntGameMode_LocalPK.cs

@@ -9,6 +9,7 @@ public class WolfHuntGameMode_LocalPK : WolfHuntGameMode, ChallengeGameModeLocal
     float singleShootReadyTime = 30f;
     float singleShootReadyTimeMax = 30f;
     int[] playerHpList = {20, 20}; 
+    public bool[] playerDieList = {false, false};
 
     public WolfHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) {
         hunterGamePlayerScoreCounter = new HunterGamePlayerScoreCounter(this);
@@ -17,7 +18,7 @@ public class WolfHuntGameMode_LocalPK : WolfHuntGameMode, ChallengeGameModeLocal
             hasShootOut = true;
         };
         onHpZero += () => {//监听到当前玩家死亡
-            GameObject.FindObjectOfType<HunterGameView_LocalPK>().ShowPlayerDie(currentPlayerIndex);
+            playerDieList[currentPlayerIndex] = true;
             if (hasShootOut) return; //此时箭已射出,避免重复处理下面的逻辑,等NextShoot来处理
             //切换到下一个玩家
             if (IsOtherPlayerNotDie()) {