2025-10-09 17:36:27 +08:00

74 lines
2.5 KiB
C#

using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using ZXKFramework;
namespace YiLiao.SiBuChuZhen
{
public class NavPanel : UIBase
{
Text time;
Text score;
Button homeBtn;
Button shutDown;
GameObject timeContainer;
GameObject scoreContainer;
public override string GroupName => "NavPanel";
public override string Name => "NavPanel";
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
time = transform.FindFirst<Text>("Time");
score = transform.FindFirst<Text>("Score");
homeBtn = transform.FindFirst<Button>("Home");
shutDown = transform.FindFirst<Button>("ShutDown");
timeContainer = transform.FindFirst<Transform>("TimeContainer").gameObject;
scoreContainer = transform.FindFirst<Transform>("ScoreContainer").gameObject;
if (homeBtn)
{
homeBtn.onClick.AddListener(() => {
Game.Instance.sound.StopBGM();
UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
});
}
if (shutDown)
{
shutDown.onClick.AddListener(() => {
uictrl.GetUI<TipPanel>().ShowConfirmGroup(GetModel<GameModel>().GetLanguage(26),
() =>
{
#if UNITY_EDITOR //Ôڱ༭Æ÷ģʽÏÂ
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
});
});
}
transform.FindFirst<Text>("title").text = GetModel<GameModel>().GetLanguage(1);
transform.FindFirst<Text>("TimeText").text = GetModel<GameModel>().GetLanguage(2);
transform.FindFirst<Text>("ScoreText").text = GetModel<GameModel>().GetLanguage(3);
}
public override void Show()
{
base.Show();
if(GetModel<Main.GameModel>().modeType == ModeType.ShiXun)
{
timeContainer.SetActive(false);
scoreContainer.SetActive(false);
}
else{
timeContainer.SetActive(true);
scoreContainer.SetActive(true);
}
}
public void SetTime(string value)
{
time.text = value;
}
public void SetScore(string value)
{
score.text = value;
}
}
}