56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
using UnityEngine;
|
|
using TMPro;
|
|
using Animancer;
|
|
using Logic;
|
|
using RuntimeData;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
|
|
public class TimeEndUI
|
|
{
|
|
private Main _main;
|
|
private MapData _mapData;
|
|
public GameObject ROTimeEndUI;
|
|
public Button ReturnButton;
|
|
public TimeEndUI(Main main, MapData mapData)
|
|
{
|
|
_main = main;
|
|
_mapData = mapData;
|
|
ROTimeEndUI = _main.UIManager.ROUIManager.transform.Find("TimeEndPanel").gameObject;
|
|
ROTimeEndUI.gameObject.SetActive(false);
|
|
ReturnButton = ROTimeEndUI.transform.Find("MsgList/Row4/Button").GetComponent<Button>(); // ← 新增按钮
|
|
ReturnButton.onClick.AddListener(OnReturnClicked); // ← 新增点击监听
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (ROTimeEndUI.activeSelf)
|
|
return;
|
|
if (_mapData == null)
|
|
return;
|
|
|
|
//每帧判断,当前是否游戏结束了
|
|
if (_mapData.PlayerMap.CheckTimeEnd())
|
|
{
|
|
_main.GameLogic.ChangeState(GameState.Finished);
|
|
ROTimeEndUI.gameObject.SetActive(true);
|
|
int ans = 1;
|
|
foreach(var player in _mapData.PlayerMap.PlayerDataList)
|
|
if (player.Id != _mapData.PlayerMap.SelfPlayerId
|
|
&& player.PlayerScore > _mapData.PlayerMap.SelfPlayerData.PlayerScore)
|
|
ans++;
|
|
ROTimeEndUI.transform.Find("MsgList/Row0/Text").GetComponent<TextMeshProUGUI>().text = $"恭喜您取得信仰分第{ans}名!";
|
|
ROTimeEndUI.transform.Find("MsgList/Row1/Head1/Text").GetComponent<TextMeshProUGUI>().text = _mapData.GetCityCount(_mapData.PlayerMap.SelfPlayerData.Id).ToString();
|
|
ROTimeEndUI.transform.Find("MsgList/Row2/Head1/Text").GetComponent<TextMeshProUGUI>().text = "0";
|
|
ROTimeEndUI.transform.Find("MsgList/Row3/Head1/Text").GetComponent<TextMeshProUGUI>().text = _mapData.PlayerMap.SelfPlayerData.PlayerScore.ToString();
|
|
}
|
|
|
|
}
|
|
|
|
public void OnReturnClicked()
|
|
{
|
|
_main.GameLogic.ChangeState(GameState.Menu);
|
|
ROTimeEndUI.gameObject.SetActive(false);
|
|
_main.UIManager.GameUI.ShowMainUIManager();
|
|
}
|
|
} |