refactor 4:

- CombatWaitingForPhaseEndState.cs 不再调用旧的 PhaseLoopRuntime.ShouldEndCurrentPhase(...),改为构造 PhaseEndConditionContext,再通过
PhaseEndConditionFactory.Create(currentPhase.EndType) 执行判定。
- PhaseLoopRuntime.cs 删除了旧的 phase 结束规则实现,现在只保留 phase 运行时数据管理,职责和架构文档一致。
- 为了让 BossDeadPhaseEndCondition 真正可用,我补了 boss 真值链路:
    - EnemyLifecycleTracker.cs 现在会跟踪存活 boss。
    - EnemyManager.cs 暴露 HasAliveBoss,并在 EntryType.Boss 刷怪时标记 boss 身份。
This commit is contained in:
2026-03-07 14:45:42 +08:00
parent 91eeeaaeea
commit e488a2ca0f
4 changed files with 31 additions and 51 deletions
@@ -1,8 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using GeometryTD.DataTable;
using GeometryTD.Definition;
using UnityEngine;
namespace GeometryTD.CustomComponent
{
@@ -71,31 +68,6 @@ namespace GeometryTD.CustomComponent
_currentPhaseElapsed += elapseSeconds;
}
public bool ShouldEndCurrentPhase(bool isPhaseSpawnCompleted, int aliveEnemyCount)
{
if (_currentPhase == null)
{
return false;
}
switch (_currentPhase.EndType)
{
case PhaseEndType.TimeElapsed:
return _currentPhaseElapsed >= ResolveTimeElapsedThreshold(_currentPhase);
case PhaseEndType.EnemiesCleared:
case PhaseEndType.BossDead:
return isPhaseSpawnCompleted && aliveEnemyCount <= 0;
case PhaseEndType.None:
default:
if (_currentPhase.DurationSeconds > 0 && _currentPhaseElapsed >= _currentPhase.DurationSeconds)
{
return true;
}
return isPhaseSpawnCompleted && aliveEnemyCount <= 0;
}
}
public bool TryEnterNextPhase(out DRLevelPhase nextPhase)
{
nextPhase = null;
@@ -125,21 +97,5 @@ namespace GeometryTD.CustomComponent
nextPhase = _currentPhase;
return true;
}
private static float ResolveTimeElapsedThreshold(DRLevelPhase phase)
{
if (!string.IsNullOrWhiteSpace(phase.EndParam) &&
float.TryParse(phase.EndParam, NumberStyles.Float, CultureInfo.InvariantCulture, out float parsed))
{
return parsed;
}
if (phase.DurationSeconds > 0)
{
return phase.DurationSeconds;
}
return 0f;
}
}
}