93 lines
2.8 KiB
C#
93 lines
2.8 KiB
C#
// 文件位置建议: Assets/Scripts/TH1_UI/Controller/UIAnnounceMajorEventController.cs
|
||
|
||
using Logic;
|
||
using TH1_Core.Events;
|
||
using TH1_Core.Managers;
|
||
using TH1_Logic.Core;
|
||
using TH1_UI.Controller.Base;
|
||
using TH1_UI.View.Bottom;
|
||
using TH1_UI.View.Top;
|
||
using TH1Renderer;
|
||
using UnityEngine;
|
||
|
||
// 确保这里引用了View脚本的命名空间
|
||
|
||
namespace TH1_UI.Controller.Top
|
||
{
|
||
public class UITopWinController : ViewController<UITopWinView> // 泛型参数是对应的View脚本
|
||
{
|
||
|
||
/// <summary>
|
||
/// ✅ 【新增】一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。
|
||
/// </summary>
|
||
public UITopWinController() { }
|
||
|
||
protected override void RegisterEventCallback()
|
||
{
|
||
base.RegisterEventCallback();
|
||
if (WindowScript != null)
|
||
{
|
||
WindowScript.OnBtnCloseClick += _OnBtnCloseClick;
|
||
}
|
||
|
||
}
|
||
|
||
protected override void UnregisterEventCallback()
|
||
{
|
||
if (WindowScript != null)
|
||
{
|
||
WindowScript.OnBtnCloseClick = null;
|
||
}
|
||
base.UnregisterEventCallback();
|
||
}
|
||
|
||
protected override void OnOpen()
|
||
{
|
||
base.OnOpen();
|
||
//WindowScript.SetContent();
|
||
// 检查暂存的参数是否存在且类型正确
|
||
if (_openParameter is ShowUITopWin evt)
|
||
{
|
||
// 使用接收到的数据设置UI内容
|
||
if (WindowScript != null)
|
||
{
|
||
//Main.PlayerLogic.CalcAllPlayerScore(Main.MapData);
|
||
WindowScript.SetContent();
|
||
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果没有参数或参数类型不符,可以提供默认内容或打印警告
|
||
Debug.LogWarning("[UIInfoTechTree] Opened without valid parameters.");
|
||
if (WindowScript != null)
|
||
{
|
||
|
||
//WindowScript.SetContent("警告", "内容未提供");
|
||
}
|
||
}
|
||
}
|
||
|
||
public override bool Close()
|
||
{
|
||
WindowScript.CloseView();
|
||
EventManager.Publish(new ShowUIOutsideMenu());
|
||
//TODO MapRenderer的 位置不应该在这里,目前服务于废弃的BubbleManager 后续迭代
|
||
MapRenderer.Instance.OnMatchEnd();
|
||
UIManager.Instance.OnMatchEnd();
|
||
Main.Instance.GameLogic.ChangeState(GameState.Menu);
|
||
return base.Close();
|
||
}
|
||
|
||
private void _OnBtnCloseClick()
|
||
{
|
||
Close();
|
||
}
|
||
|
||
public void OnMatchStart()
|
||
{
|
||
WindowScript?.OnMatchStart();
|
||
}
|
||
|
||
}
|
||
} |