122 lines
3.6 KiB
C#
122 lines
3.6 KiB
C#
// 文件位置建议: Assets/Scripts/TH1_UI/Controller/UIAnnounceMajorEventController.cs
|
||
|
||
using Logic;
|
||
using RuntimeData;
|
||
using TH1_Core.Events;
|
||
using TH1_Logic.Core;
|
||
using TH1_UI.Controller.Base;
|
||
using TH1_UI.View.Info;
|
||
using UnityEngine;
|
||
|
||
// 确保这里引用了View脚本的命名空间
|
||
|
||
namespace TH1_UI.Controller.Info
|
||
{
|
||
public class UIInfoGridInfoController : ViewController<UIInfoGridInfoView>, IEscClosable // 泛型参数是对应的View脚本
|
||
{
|
||
|
||
/// <summary>
|
||
/// ✅ 【新增】一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。
|
||
/// </summary>
|
||
public UIInfoGridInfoController() { }
|
||
|
||
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();
|
||
ApplyContent();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 面板已经在显示时,再次收到Open请求会走这里(而非OnOpen)。
|
||
/// 基类_TryOpen中IsShow()==true时调用UpdateView而不是OnOpen。
|
||
/// </summary>
|
||
public override void UpdateView()
|
||
{
|
||
ApplyContent();
|
||
}
|
||
|
||
private void ApplyContent()
|
||
{
|
||
if (_openParameter is ShowUIInfoGridInfo evt)
|
||
{
|
||
if (WindowScript != null)
|
||
{
|
||
WindowScript.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
|
||
WindowScript.SetContent(evt);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning("[UIInfoGridInfo] Opened without valid parameters.");
|
||
}
|
||
}
|
||
|
||
public override bool Close()
|
||
{
|
||
WindowScript.CloseView();
|
||
return base.Close();
|
||
}
|
||
|
||
//用于UI执行相关
|
||
public void ExecuteAction(ExecuteUIInfoGridInfo evt)
|
||
{
|
||
WindowScript.ExecuteAction(evt);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 外部调用: 刷新当前展示的Unit的ActionPoint显示
|
||
/// 当玩家做完一个action后,应调用此方法来更新APBox
|
||
/// </summary>
|
||
public void RefreshActionPoints(RuntimeData.UnitData unitData)
|
||
{
|
||
if (WindowScript != null)
|
||
WindowScript.RefreshActionPoints(unitData);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关卡限制变动时(OnMatchLimitsChanged)的统一刷新入口。
|
||
/// 当 GridInfo 面板正在显示时,用上次 Open 的参数重新 SetContent,让 Action 列表等
|
||
/// 依赖 MatchLimits 的内容立即生效。面板未显示时直接跳过——下次 Open 时自然会用新规则。
|
||
/// </summary>
|
||
public void RefreshLimitEffects()
|
||
{
|
||
if (!IsShow()) return;
|
||
ApplyContent();
|
||
}
|
||
|
||
void _OnBtnCloseClick()
|
||
{
|
||
Main.Instance.MapInteractionLogic.CancelAllHighlight();
|
||
Close();
|
||
}
|
||
|
||
public bool CanCloseByEsc()
|
||
{
|
||
return true;
|
||
}
|
||
|
||
public void CancelMapHighlightsOrDoNothing()
|
||
{
|
||
Main.Instance.MapInteractionLogic.CancelAllHighlight();
|
||
}
|
||
}
|
||
} |