56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using UnityEngine;
|
|
using Logic;
|
|
using RuntimeData;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine.UI;
|
|
|
|
public class LoseUI
|
|
{
|
|
private Main _main;
|
|
private MapData _mapData;
|
|
public GameObject ROLoseUI;
|
|
public Button ReturnButton;
|
|
|
|
|
|
public LoseUI(Main main, MapData mapData)
|
|
{
|
|
return;
|
|
_main = main;
|
|
_mapData = mapData;
|
|
ROLoseUI = UIManager.Instance.ROUIManager.transform.Find("LosePanel").gameObject;
|
|
ROLoseUI.gameObject.SetActive(false);
|
|
ReturnButton = ROLoseUI.transform.Find("MsgList/Row4/Button").GetComponent<Button>(); // ← 新增按钮获取
|
|
|
|
ReturnButton.onClick.AddListener(OnReturnClicked); // ← 新增点击监听
|
|
}
|
|
|
|
public void Update()
|
|
{return;
|
|
if (ROLoseUI.activeSelf)
|
|
return;
|
|
if (_mapData == null)
|
|
return;
|
|
if (_mapData.PlayerMap.CheckSelfLose())
|
|
{
|
|
ROLoseUI.gameObject.SetActive(true);
|
|
ROLoseUI.transform.Find("MsgList/Row1/Head1/Text").GetComponent<TextMeshProUGUI>().text = _mapData.GetCityCount(_mapData.PlayerMap.SelfPlayerData.Id).ToString();
|
|
ROLoseUI.transform.Find("MsgList/Row2/Head1/Text").GetComponent<TextMeshProUGUI>().text = "0";
|
|
ROLoseUI.transform.Find("MsgList/Row3/Head1/Text").GetComponent<TextMeshProUGUI>().text = _mapData.PlayerMap.SelfPlayerData.PlayerScore.ToString();
|
|
}
|
|
|
|
// 如果需要处理每帧逻辑,例如动画或显示控制,可在此添加
|
|
}
|
|
|
|
public void OnReturnClicked()
|
|
{
|
|
return;
|
|
Debug.Log("!!!!!!");
|
|
_main.GameLogic.ChangeState(GameState.Finished);
|
|
Debug.Log("t1");
|
|
ROLoseUI.gameObject.SetActive(false);
|
|
Debug.Log("t2");
|
|
UIManager.Instance.GameUI.ShowMainUIManager();
|
|
Debug.Log("t3");
|
|
}
|
|
} |