Files
heros/assets/script/game/battle/BattleManager.ts
2025-02-03 22:02:26 +08:00

46 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { BattleEntity } from "./BattleEntity";
import { BattleStateComp } from "./BattleStateComp";
import { UIID } from "../common/config/GameUIConfig";
import { oops } from "db://oops-framework/core/Oops";
export class BattleManager {
/** 获取战斗实体实例 */
static get instance(): ecs.Entity {
return ecs.query(ecs.allOf(BattleStateComp))[0];
}
/** 启动战斗 */
static startBattle(missionId: number) {
const entity = ecs.getEntity(BattleEntity);
entity.get(BattleStateComp).missionId = missionId;
}
/** 结束战斗 */
static endBattle() {
const entity = ecs.query(ecs.allOf(BattleStateComp))[0];
if (entity) {
entity.get(BattleStateComp).isEnded = true;
}
}
/** 扩展带UI管理的战斗启动 */
static startBattleWithUI(missionId: number) {
// 关闭主界面
// oops.gui.remove(UIID.MainMenu);
// // 显示战斗HUD
// oops.gui.open(UIID.BattleHUD);
// 启动战斗
this.startBattle(missionId);
}
/** 扩展带UI管理的战斗结束 */
static endBattleWithUI(isVictory: boolean) {
// 关闭战斗HUD
// oops.gui.remove(UIID.BattleHUD);
// 显示结算界面
// oops.gui.open(isVictory ? UIID.Victory : UIID.Defeat);
// 结束战斗
this.endBattle();
}
}