M1 回合制战斗架构收敛与 1v1 攻击闭环:BattleRuntime 内核、组件唯一入口、UI 数据驱动与 EditMode 测试
- 删除中间契约(BattleStartRequest/BattlePlayerInput/BattleReturnPlan/桥接与策略接口/FlowState),收敛为 BattleViewState/BattleStep/一层 BattleEvent - 新增内部 BattleRuntime/BattleUnit/BattleStatus 共享上下文;TurnBattleComponent 成为唯一外部入口,吸收启动/暂停/回写职责 - 内核支持 1v1 攻击闭环:效果公式、HP/MP 钳制、阵亡、Victory/TotalDefeat、敌人随机决策;敌人行动间歇 0.6s 由组件协程编排并经 StepListener 推送 - UI:玩家卡片/敌人槽/回合槽按战局重建,图标配置驱动(含新增 EnemyConfig.Icon),每轮刷新一次 TurnSlots 且轮内只移动高亮 - 新增 Tests 程序集 + InternalsVisibleTo,25 个 BattleRuntime 纯逻辑用例全部通过
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using SepCore.Battle;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 战斗单位视图的显示辅助:名称与图标解析。
|
||||
/// 玩家图标来自 CharacterConfig.Icon_Ref,敌人图标来自 EnemyConfig.Icon_Ref。
|
||||
/// </summary>
|
||||
public static class BattleUnitViewHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取单位显示名;配置缺失时回退为配置 ID。
|
||||
/// </summary>
|
||||
public static string GetDisplayName(BattleUnitView unit)
|
||||
{
|
||||
if (unit == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (unit.Faction == BattleFaction.Player)
|
||||
{
|
||||
CharacterConfig config = GameEntry.Luban.Get<CharacterConfig>(unit.ConfigId);
|
||||
return config != null ? config.Name : unit.ConfigId.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
EnemyConfig config = GameEntry.Luban.Get<EnemyConfig>(unit.ConfigId);
|
||||
return config != null ? config.Name : unit.ConfigId.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取玩家单位图标配置;配置缺失时返回 null。
|
||||
/// </summary>
|
||||
public static SpriteConfig GetPlayerIconConfig(int characterId)
|
||||
{
|
||||
CharacterConfig config = GameEntry.Luban.Get<CharacterConfig>(characterId);
|
||||
return config != null ? config.Icon_Ref : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取敌人单位图标配置;配置缺失时返回 null。
|
||||
/// </summary>
|
||||
public static SpriteConfig GetEnemyIconConfig(int enemyId)
|
||||
{
|
||||
EnemyConfig config = GameEntry.Luban.Get<EnemyConfig>(enemyId);
|
||||
return config != null ? config.Icon_Ref : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user