using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PKMatchingView : MonoBehaviour { [SerializeField] Sprite[] matchHeadBGList; float waitingTime = 0; void Awake() { } void Start() { (Sprite avatar, string nickname) = RoleMgr.GetRoleInfo(0); RenderPlayerInfo(1, avatar, nickname, true); RenderPlayerInfo(2, null, "", false); } void Update() { waitingTime += Time.deltaTime; this.transform.Find("BoxRight/TimeBG").GetComponentInChildren().text = TimeUtil.GetTimeStr(waitingTime, false); } void RenderPlayerInfo(int playerID, Sprite avatar, string nickname, bool active) { this.transform.Find($"BoxRight/Player{playerID}/NameBox") .GetComponentInChildren().text = active ? nickname : "等待加入"; Transform avatarT = this.transform.Find($"BoxRight/Player{playerID}/MatchHeadBG/Avatar"); avatarT.gameObject.SetActive(active); avatarT.Find("Sprite").GetComponent().sprite = avatar; } void ChangeMatchHeadBG(int typeIndex) { Image img = this.transform.Find("BoxRight/Player2/MatchHeadBG").GetComponent(); img.sprite = matchHeadBGList[typeIndex]; img.GetComponent