| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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>().text = TimeUtil.GetTimeStr(waitingTime, false);
- }
- void RenderPlayerInfo(int playerID, Sprite avatar, string nickname, bool active) {
- this.transform.Find($"BoxRight/Player{playerID}/NameBox")
- .GetComponentInChildren<Text>().text = active ? nickname : "等待加入";
- Transform avatarT = this.transform.Find($"BoxRight/Player{playerID}/MatchHeadBG/Avatar");
- avatarT.gameObject.SetActive(active);
- avatarT.Find("Sprite").GetComponent<Image>().sprite = avatar;
- }
- void ChangeMatchHeadBG(int typeIndex) {
- Image img = this.transform.Find("BoxRight/Player2/MatchHeadBG").GetComponent<Image>();
- img.sprite = matchHeadBGList[typeIndex];
- img.GetComponent<Button>().enabled = typeIndex == 1;
- }
- public void Back() {
- AudioMgr.ins.PlayBtn();
- Destroy(this.gameObject);
- }
- }
|