129 lines
3.4 KiB
C#
129 lines
3.4 KiB
C#
using AibisDream.Kit;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using AibisDream.Utility;
|
|
|
|
namespace AibisDream.UI
|
|
{
|
|
public class SettingPanel : MonoBehaviour, IUIPanel
|
|
{
|
|
public bool IsOpen => gameObject.activeSelf;
|
|
public bool IsCloseable => true;
|
|
|
|
#region 索引
|
|
|
|
[SerializeField] private Image background;
|
|
[SerializeField] private Animator animator;
|
|
|
|
[Space]
|
|
[SerializeField] private Button continueBtn;
|
|
[SerializeField] private Button backToMainBtn;
|
|
[SerializeField] private Button quitBtn;
|
|
[SerializeField] private Button wishlistBtn;
|
|
[SerializeField] private Button bugBtn;
|
|
|
|
#endregion
|
|
|
|
#region 打开和关闭
|
|
|
|
public void Show()
|
|
{
|
|
// 暂停游戏
|
|
gameObject.SetActive(true);
|
|
AddBackground();
|
|
animator.Play("Open", 0, 0);
|
|
|
|
// 更新表单内容
|
|
var form = GetComponentInChildren<SettingForm>();
|
|
form.Init();
|
|
// 注册函数
|
|
RegisterButton();
|
|
ActionKit.Delay(ConstRef.PanelDelayDuration, () =>
|
|
{
|
|
GameManager.Instance.PauseGame();
|
|
}).Start(this);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
// 更新表单内容
|
|
var form = GetComponentInChildren<SettingForm>();
|
|
form.UnInit();
|
|
UnRegisterButton();
|
|
|
|
RemoveBackground();
|
|
animator.Play("Close", 0, 0);
|
|
|
|
GameManager.Instance.ContinueGame();
|
|
ActionKit.Delay(ConstRef.PanelDelayDuration, () =>
|
|
{
|
|
gameObject.SetActive(false);
|
|
// 继续游戏
|
|
}).Start(this);
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void AddBackground()
|
|
{
|
|
background.canvasRenderer.SetAlpha(0.0f);
|
|
background.gameObject.SetActive(true);
|
|
background.CrossFadeAlpha(1.0f, 0.4f, false);
|
|
}
|
|
|
|
private void RemoveBackground()
|
|
{
|
|
background.CrossFadeAlpha(0.0f, 0.2f, false);
|
|
}
|
|
|
|
private void RegisterButton()
|
|
{
|
|
continueBtn.onClick.AddListener(BackToGame);
|
|
backToMainBtn.onClick.AddListener(BackToMain);
|
|
quitBtn.onClick.AddListener(Quit);
|
|
|
|
wishlistBtn.onClick.AddListener(OpenWishlist);
|
|
bugBtn.onClick.AddListener(OpenBugReport);
|
|
}
|
|
|
|
private void UnRegisterButton()
|
|
{
|
|
continueBtn.onClick.RemoveAllListeners();
|
|
backToMainBtn.onClick.RemoveAllListeners();
|
|
quitBtn.onClick.RemoveAllListeners();
|
|
|
|
wishlistBtn.onClick.RemoveAllListeners();
|
|
bugBtn.onClick.RemoveAllListeners();
|
|
}
|
|
|
|
private void BackToGame()
|
|
{
|
|
// 关闭Setting面板
|
|
UIManager.Instance.HidePanel<SettingPanel>();
|
|
}
|
|
|
|
private void BackToMain()
|
|
{
|
|
// 关闭Setting面板
|
|
UIManager.Instance.HidePanel<SettingPanel>();
|
|
// 重启
|
|
GameManager.Instance.QuitGame();
|
|
}
|
|
|
|
private void Quit()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
private void OpenWishlist()
|
|
{
|
|
Application.OpenURL(ConstRef.WishlistURL);
|
|
}
|
|
|
|
private void OpenBugReport()
|
|
{
|
|
Application.OpenURL(ConstRef.BugSurveyURL);
|
|
}
|
|
}
|
|
}
|