import { _decorator } from 'cc'; import { BaseSingleton } from '../Core/BaseSingleton'; import EventBus, { GameEvents } from '../Core/EventBus'; import { EnemyController } from '../CombatSystem/EnemyController'; const { ccclass } = _decorator; @ccclass('LevelStateManager') export class LevelStateManager extends BaseSingleton { public static _instance: LevelStateManager; private currentWave = 1; private currentWaveEnemyCount = 0; private totalEnemiesInWave = 0; protected init() { // 临时监听示例,如需根据 LevelConfigManager 生成波次数据再完善 EventBus.getInstance().on('NEXT_WAVE', this.nextWave, this); } public setWaveInfo(wave: number, totalEnemies: number) { this.currentWave = wave; this.totalEnemiesInWave = totalEnemies; this.currentWaveEnemyCount = 0; } public enemySpawned() { this.currentWaveEnemyCount++; } public enemyKilled() { this.currentWaveEnemyCount--; if (this.currentWaveEnemyCount <= 0) { EventBus.getInstance().emit('WAVE_CLEAR', this.currentWave); } } private nextWave() { this.currentWave++; // TODO: 读取 LevelConfigManager 获得下一波敌人信息并驱动 EnemyController EnemyController.getInstance()?.resumeSpawning(); } }