75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using AibisDream.Utility;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class StartPanel : MonoBehaviour, IUIPanel
|
|
{
|
|
public bool IsOpen => gameObject.activeSelf;
|
|
|
|
#region 开启和关闭
|
|
|
|
public void Show()
|
|
{
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
RegisterButton();
|
|
}
|
|
|
|
private void RegisterButton()
|
|
{
|
|
// 开始界面按钮
|
|
var tabs = transform.Find("Tabs");
|
|
tabs.Find("Start").GetComponent<Button>().onClick.AddListener(StartNewGame);
|
|
tabs.Find("Select Level").GetComponent<Button>().onClick.AddListener(OpenLevelPanel);
|
|
tabs.Find("Load Save File").GetComponent<Button>().onClick.AddListener(OpenSaveFilePanel);
|
|
tabs.Find("Setting").GetComponent<Button>().onClick.AddListener(OpenSetting);
|
|
tabs.Find("Quit").GetComponent<Button>().onClick.AddListener(QuitApp);
|
|
// 打开链接
|
|
transform.Find("问卷").GetComponent<Button>().onClick.AddListener(() => Application.OpenURL(ConstRef.SurveyURL));
|
|
transform.Find("关注").GetComponent<Button>().onClick.AddListener(() => Application.OpenURL(ConstRef.QQURL));
|
|
}
|
|
|
|
#region 按钮对应的函数
|
|
|
|
|
|
private void StartNewGame()
|
|
{
|
|
GameManager.Instance.StartNewGame();
|
|
}
|
|
|
|
private void OpenLevelPanel()
|
|
{
|
|
// TODO 打开选关面板
|
|
}
|
|
|
|
private void OpenSaveFilePanel()
|
|
{
|
|
UIManager.Instance.ShowPanel<SavesPanel>();
|
|
}
|
|
|
|
private void OpenSetting()
|
|
{
|
|
UIManager.Instance.ShowPanel<SettingPanel>();
|
|
}
|
|
|
|
private void QuitApp()
|
|
{
|
|
GameManager.Instance.QuitApp();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|