147 lines
4.1 KiB
C#
147 lines
4.1 KiB
C#
// 文件位置建议: Assets/Scripts/TH1_UI/Controller/UIAnnounceMajorEventController.cs
|
|
|
|
using Logic;
|
|
using RuntimeData;
|
|
using TH1_Core.Events;
|
|
using TH1_Core.Managers;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_UI.Controller.Base;
|
|
using TH1_UI.View.Bottom;
|
|
using TH1Renderer;
|
|
using UnityEngine;
|
|
|
|
// 确保这里引用了View脚本的命名空间
|
|
|
|
namespace TH1_UI.Controller.Bottom
|
|
{
|
|
public class UIBottomBottomBarController : ViewController<UIBottomBottomBarView> // 泛型参数是对应的View脚本
|
|
{
|
|
|
|
/// <summary>
|
|
/// ✅ 【新增】一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。
|
|
/// </summary>
|
|
public UIBottomBottomBarController() { }
|
|
|
|
protected override void RegisterEventCallback()
|
|
{
|
|
base.RegisterEventCallback();
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.OnBtnCloseClick += _OnBtnCloseClick;
|
|
WindowScript.OnBtnQuitClick += _OnBtnQuitClick;
|
|
}
|
|
|
|
}
|
|
|
|
protected override void UnregisterEventCallback()
|
|
{
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.OnBtnCloseClick = null;
|
|
}
|
|
base.UnregisterEventCallback();
|
|
}
|
|
|
|
|
|
public override void OnMatchStart()
|
|
{
|
|
//比赛开始时,如果当前是自己的回合
|
|
Open();
|
|
if (Main.MapData.CurPlayer == Main.MapData.PlayerMap.SelfPlayerData)
|
|
ShowBottomBarNextTurn();
|
|
else
|
|
HideBottomBarNextTurn();
|
|
|
|
|
|
}
|
|
|
|
public void OnTurnStart()
|
|
{
|
|
|
|
}
|
|
protected override void OnOpen()
|
|
{
|
|
base.OnOpen();
|
|
WindowScript.SetContent();
|
|
// 检查暂存的参数是否存在且类型正确
|
|
/*if (_openParameter is ShowUIBottomBottomBar evt)
|
|
{
|
|
// 使用接收到的数据设置UI内容
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.SetContent();
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 如果没有参数或参数类型不符,可以提供默认内容或打印警告
|
|
Debug.LogWarning("[UIInfoTechTree] Opened without valid parameters.");
|
|
if (WindowScript != null)
|
|
{
|
|
|
|
//WindowScript.SetContent("警告", "内容未提供");
|
|
}
|
|
}*/
|
|
}
|
|
|
|
public override bool Close()
|
|
{
|
|
WindowScript.CloseView();
|
|
return base.Close();
|
|
}
|
|
|
|
public void ShowBottomBarNextTurn()
|
|
{
|
|
WindowScript.ShowBottomBarNextTurn();
|
|
}
|
|
|
|
public void HideBottomBarNextTurn()
|
|
{
|
|
WindowScript.HideBottomBarNextTurn();
|
|
}
|
|
|
|
public void BottomBarQuit()
|
|
{
|
|
_OnBtnCloseClick();
|
|
_OnBtnQuitClick();
|
|
}
|
|
|
|
//用于刷新heroButton的视觉
|
|
public void UpdateHeroAvatar()
|
|
{
|
|
WindowScript.UpdateHeroButtonAvatar();
|
|
}
|
|
|
|
public void ExecuteTechButtonClick()
|
|
{
|
|
WindowScript.ExecuteButtonClick(WindowScript.TechButton);
|
|
}
|
|
|
|
public void ExecuteHeroButtonClick()
|
|
{
|
|
WindowScript.ExecuteButtonClick(WindowScript.HeroButton);
|
|
}
|
|
public void ExecuteNextButtonClick()
|
|
{
|
|
WindowScript.ExecuteButtonClick(WindowScript.NextButton);
|
|
}
|
|
|
|
void _OnBtnQuitClick()
|
|
{
|
|
if(Main.MapData?.Net.Mode == NetMode.Multi)
|
|
LobbyManager.Instance.Lobby?.LeaveLobby();
|
|
MapRenderer.Instance.OnMatchEnd();
|
|
UIManager.Instance.OnMatchEnd();
|
|
|
|
EventManager.Publish(new ShowUIOutsideMenu());
|
|
Main.Instance.GameLogic.ChangeState(GameState.Menu);
|
|
}
|
|
|
|
void _OnBtnCloseClick()
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
} |