75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using Animancer;
|
|
using Logic;
|
|
using RuntimeData;
|
|
using TH1_Core.Events;
|
|
using TH1_Core.Managers;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1Resource;
|
|
using TH1Renderer;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_UI.View.Bottom
|
|
{
|
|
public class UIBottomBottomBarQuitPanelMono : MonoBehaviour
|
|
{
|
|
public AnimancerComponent Animancer;
|
|
public Button CancelButton;
|
|
public Button RestartButton;
|
|
public Button CheckButton;
|
|
|
|
// 确认退出时执行的委托
|
|
public ViDelegateAssisstant.Dele OnQuitConfirm;
|
|
|
|
public void OnInit()
|
|
{
|
|
CancelButton.onClick.RemoveAllListeners();
|
|
CancelButton.onClick.AddListener(OnClose);
|
|
CheckButton.onClick.RemoveAllListeners();
|
|
CheckButton.onClick.AddListener(OnConfirm);
|
|
RestartButton.onClick.RemoveAllListeners();
|
|
RestartButton.onClick.AddListener(OnRestart);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
RestartButton.gameObject.SetActive(false);
|
|
|
|
gameObject.SetActive(true);
|
|
Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeIn);
|
|
}
|
|
|
|
public void OnClose()
|
|
{
|
|
AnimancerState state = Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut);
|
|
state.Events.OnEnd += () =>
|
|
{
|
|
gameObject.SetActive(false);
|
|
};
|
|
}
|
|
|
|
private void OnConfirm()
|
|
{
|
|
OnQuitConfirm?.Invoke();
|
|
}
|
|
|
|
private void OnRestart()
|
|
{
|
|
if (Main.MapData == null) return;
|
|
if (Main.MapData.Net.Mode != NetMode.Single) return;
|
|
|
|
// 清理当前对局
|
|
MapRenderer.Instance.OnMatchEnd();
|
|
UIManager.Instance.OnMatchEnd();
|
|
Main.Instance.GameLogic.ChangeState(GameState.Menu);
|
|
|
|
// 播放loading -> 重新开始 -> 关闭loading
|
|
EventManager.Publish(new ShowUIOutsideLoading());
|
|
Timer.Instance.TimerRegister(this, () => { Main.Instance.StartMatch(); }, 0.3f, "QuitPanel_Restart");
|
|
Timer.Instance.TimerRegister(this, () => { EventManager.Publish(new HideUIOutsideLoading()); }, 1f, "QuitPanel_Restart2");
|
|
}
|
|
}
|
|
}
|