refactor & fix
- 将 `CombatScheduler` 的职责分散到 3 个类中
- `PhaseLoopRuntime`:负责关卡各波次的调度
- `CombatLoadSession`:负责地图与 UI 等资源的加载
- `CombatEventBridge`:负责相关事件的处理
- 统一了战斗的命名为 `Combat`
- 调整了各个地图的坐标,使其位于摄像头中心
- 新增了 CombatInfoForm 展示战斗内的信息
- 补充了循环执行 LevelPhase,手动结束战斗的逻辑
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class CombatInfoForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private TMP_Text _levelMetaText;
|
||||
|
||||
[SerializeField] private TMP_Text _levelPhaseText;
|
||||
|
||||
[SerializeField] private TMP_Text _coinText;
|
||||
|
||||
[SerializeField] private CommonButton _pauseButton;
|
||||
|
||||
[SerializeField] private CommonButton _endButton;
|
||||
|
||||
private CombatInfoFormContext _context;
|
||||
|
||||
public void RefreshUI(CombatInfoFormContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
if (_levelMetaText != null)
|
||||
{
|
||||
_levelMetaText.text = context?.LevelMetaText ?? string.Empty;
|
||||
}
|
||||
|
||||
if (_levelPhaseText != null)
|
||||
{
|
||||
_levelPhaseText.text = context?.LevelPhaseText ?? string.Empty;
|
||||
}
|
||||
|
||||
if (_coinText != null)
|
||||
{
|
||||
_coinText.text = context?.CoinText ?? "0";
|
||||
}
|
||||
|
||||
if (_pauseButton != null)
|
||||
{
|
||||
_pauseButton.Interactive = context?.CanPause ?? false;
|
||||
}
|
||||
|
||||
if (_endButton != null)
|
||||
{
|
||||
_endButton.gameObject.SetActive(context?.CanEnd ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPauseButtonClick()
|
||||
{
|
||||
if (_context != null && !_context.CanPause)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, CombatPauseEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnEndButtonClick()
|
||||
{
|
||||
if (_context != null && !_context.CanEnd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, CombatEndEventArgs.Create());
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is CombatInfoFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("CombatInfoForm requires CombatInfoFormContext as userData.");
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
_context = null;
|
||||
|
||||
if (_levelMetaText != null)
|
||||
{
|
||||
_levelMetaText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (_levelPhaseText != null)
|
||||
{
|
||||
_levelPhaseText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (_coinText != null)
|
||||
{
|
||||
_coinText.text = string.Empty;
|
||||
}
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3971fa7b9e17b04a97d7f10d1472a80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user