|
|
@@ -0,0 +1,51 @@
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
+using UnityEngine.UI;
|
|
|
+
|
|
|
+public class HunterGameView_LocalPK : MonoBehaviour
|
|
|
+{
|
|
|
+ int[] hitScores = {0, 0};
|
|
|
+ int curPlayerIndex = -1;
|
|
|
+ ChallengeGameModeLocalPK gameModeLocalPK;
|
|
|
+
|
|
|
+ void Awake() {
|
|
|
+ gameModeLocalPK = (ChallengeGameModeLocalPK) GameMgr.ins.gameMode;
|
|
|
+ InitRenderPlayerInfo(0, GlobalData.localPK_playerRoleIDs[0], 0);
|
|
|
+ InitRenderPlayerInfo(1, GlobalData.localPK_playerRoleIDs[1], 0);
|
|
|
+ GameEventCenter.ins.onTargetAnimalHurt += (a, hurtValue) => {
|
|
|
+
|
|
|
+ int playerIndex = gameModeLocalPK.GetCurrentPlayIndex();
|
|
|
+ hitScores[playerIndex] += hurtValue;
|
|
|
+ RenderScore(playerIndex, hitScores[playerIndex]);
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ Color itemBG_ColorDark = new Color(0,0,0,155f/255);
|
|
|
+ Color itemBG_ColorLight = new Color(0,100f/255,0,155f/255);
|
|
|
+
|
|
|
+ void Update() {
|
|
|
+ if (gameModeLocalPK.GetCurrentPlayIndex() != curPlayerIndex) {
|
|
|
+ curPlayerIndex = gameModeLocalPK.GetCurrentPlayIndex();
|
|
|
+ RenderItemBG_Color(0, curPlayerIndex == 0 ? itemBG_ColorLight : itemBG_ColorDark);
|
|
|
+ RenderItemBG_Color(1, curPlayerIndex == 1 ? itemBG_ColorLight : itemBG_ColorDark);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void RenderItemBG_Color(int posNum, Color color) {
|
|
|
+ this.transform.Find("ScoreBox/Item" + posNum).GetComponent<Image>().color = color;
|
|
|
+ this.transform.Find("ScoreBox/Item" + posNum + "/Cur").gameObject.SetActive(color.Equals(itemBG_ColorLight));
|
|
|
+ }
|
|
|
+
|
|
|
+ void InitRenderPlayerInfo(int posNum, int playerID, int score)
|
|
|
+ {
|
|
|
+ (Sprite avatar, string nickName) = RoleMgr.GetRoleInfo(playerID);
|
|
|
+ this.transform.Find("ScoreBox/Item" + posNum + "/Avatar/Sprite").GetComponent<Image>().sprite = avatar;
|
|
|
+ this.transform.Find("ScoreBox/Item" + posNum + "/Name").GetComponent<Text>().text = nickName;
|
|
|
+ RenderScore(posNum, score);
|
|
|
+ }
|
|
|
+
|
|
|
+ void RenderScore(int posNum, int score) {
|
|
|
+ this.transform.Find("ScoreBox/Item" + posNum + "/Score").GetComponent<Text>().text = "得分: " + score.ToString();
|
|
|
+ }
|
|
|
+}
|