战斗管理系统基础

This commit is contained in:
2025-02-03 22:02:26 +08:00
parent 060046a6a6
commit 36a8aff783
27 changed files with 375 additions and 619 deletions

View File

@@ -0,0 +1,53 @@
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { BattleStateComp } from "./BattleStateComp";
import { BattleManager } from "./BattleManager";
@ecs.register('BattlePhaseSystem')
export class BattlePhaseSystem extends ecs.ComblockSystem {
filter(): ecs.IMatcher {
return ecs.allOf(BattleStateComp);
}
update(e: ecs.Entity) {
const state = e.get(BattleStateComp);
switch(state.phase) {
case BattleStateComp.Phase.Preparation:
this.handlePreparation(state);
break;
case BattleStateComp.Phase.Fighting:
this.handleFighting(state);
break;
case BattleStateComp.Phase.Victory:
this.handleVictory(state);
break;
case BattleStateComp.Phase.Defeat:
this.handleDefeat(state);
break;
}
}
private handlePreparation(state: BattleStateComp) {
// 准备阶段逻辑:角色选择、装备检查等
if (state.startTime > 0) {
state.setPhase(BattleStateComp.Phase.Fighting);
}
}
private handleFighting(state: BattleStateComp) {
// 实时战斗逻辑:由其他系统处理
}
private handleVictory(state: BattleStateComp) {
// 胜利结算逻辑
BattleManager.endBattleWithUI(true);
state.setPhase(BattleStateComp.Phase.Preparation);
}
private handleDefeat(state: BattleStateComp) {
// 失败结算逻辑
BattleManager.endBattleWithUI(false);
state.setPhase(BattleStateComp.Phase.Preparation);
}
}