IN_game.ts 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. import { _decorator, Component, Node, Label, ProgressBar, find } from 'cc';
  2. import EventBus, { GameEvents } from '../Core/EventBus';
  3. import { GameBlockSelection } from '../CombatSystem/BlockSelection/GameBlockSelection';
  4. import { Wall } from '../CombatSystem/Wall';
  5. import { GameStartMove } from '../Animations/GameStartMove';
  6. import { LevelSessionManager } from '../Core/LevelSessionManager';
  7. import { SaveDataManager } from './SaveDataManager';
  8. import { SkillManager } from '../CombatSystem/SkillSelection/SkillManager';
  9. import { StartGame } from './StartGame';
  10. import { BackgroundManager } from './BackgroundManager';
  11. import { GroundBurnAreaManager } from '../CombatSystem/BulletEffects/GroundBurnAreaManager';
  12. const { ccclass, property } = _decorator;
  13. /**
  14. * 游戏内状态枚举
  15. * 仅在 AppState.IN_GAME 时使用
  16. */
  17. export enum GameState {
  18. PLAYING = 'playing',
  19. SUCCESS = 'success',
  20. DEFEAT = 'defeat',
  21. PAUSED = 'paused',
  22. BLOCK_SELECTION = 'block_selection'
  23. }
  24. /**
  25. * 游戏内状态管理器
  26. * 负责管理游戏进行中的所有状态和逻辑
  27. */
  28. @ccclass('InGameManager')
  29. export class InGameManager extends Component {
  30. // === 游戏内UI节点引用 ===
  31. @property({
  32. type: Node,
  33. tooltip: '拖拽BallController节点到这里'
  34. })
  35. public ballController: Node = null;
  36. @property({
  37. type: Node,
  38. tooltip: '拖拽GameBlockSelection节点到这里'
  39. })
  40. public gameBlockSelection: Node = null;
  41. @property({
  42. type: Node,
  43. tooltip: '拖拽GameArea节点到这里'
  44. })
  45. public gameArea: Node = null;
  46. @property({
  47. type: Node,
  48. tooltip: '拖拽EnemyController节点到这里'
  49. })
  50. public enemyManager: Node = null;
  51. @property({
  52. type: Node,
  53. tooltip: '摄像机节点,用于获取GameStartMove组件'
  54. })
  55. public cameraNode: Node = null;
  56. @property({
  57. type: Node,
  58. tooltip: '墙体节点,用于获取Wall组件'
  59. })
  60. public wallNode: Node = null;
  61. @property({
  62. type: Node,
  63. tooltip: '上围栏墙体节点 (TopFence)'
  64. })
  65. public topFenceNode: Node = null;
  66. @property({
  67. type: Node,
  68. tooltip: '下围栏墙体节点 (BottomFence)'
  69. })
  70. public bottomFenceNode: Node = null;
  71. // === 游戏配置属性 ===
  72. @property({
  73. tooltip: '状态检查间隔(秒)'
  74. })
  75. public checkInterval: number = 1.0;
  76. // === 私有属性 ===
  77. private gameStarted: boolean = false;
  78. private currentState: GameState = GameState.PLAYING;
  79. private checkTimer: number = 0;
  80. // EnemyController现在通过事件系统通信,不再直接引用
  81. private enemySpawningStarted: boolean = false;
  82. private totalEnemiesSpawned: number = 0;
  83. private currentWave: number = 1;
  84. private currentWaveEnemyCount: number = 0;
  85. private currentWaveTotalEnemies: number = 0;
  86. public levelWaves: any[] = [];
  87. private levelTotalEnemies: number = 0;
  88. private enemiesKilled: number = 0;
  89. // === 背景管理器组件 ===
  90. private backgroundManager: BackgroundManager = null;
  91. // === 地面燃烧区域管理器 ===
  92. private groundBurnAreaManager: GroundBurnAreaManager = null;
  93. // 游戏计时器
  94. private gameStartTime: number = 0;
  95. private gameEndTime: number = 0;
  96. // 游戏区域的边界
  97. private gameBounds = {
  98. left: 0,
  99. right: 0,
  100. top: 0,
  101. bottom: 0
  102. };
  103. private preparingNextWave = false;
  104. // 能量系统
  105. private energyPoints: number = 0;
  106. private energyMax: number = 0; // 必须从关卡配置中读取
  107. private energyBar: ProgressBar = null;
  108. private selectSkillUI: Node = null;
  109. // 新增:能量条升级系统
  110. private energyUpgradeCount: number = 0; // 当前能量条升级次数
  111. private energyMaxUpgrades: number[] = []; // 每次升级后的最大值配置
  112. // 能量条UI节点
  113. @property({
  114. type: Node,
  115. tooltip: '拖拽能量条节点到这里 (Canvas/GameLevelUI/EnergyBar)'
  116. })
  117. public energyBarNode: Node = null;
  118. // 技能选择UI节点
  119. @property({
  120. type: Node,
  121. tooltip: '拖拽技能选择UI节点到这里 (Canvas/GameLevelUI/SelectSkillUI)'
  122. })
  123. public selectSkillUINode: Node = null;
  124. // === 背景管理器 ===
  125. @property({
  126. type: Node,
  127. tooltip: '拖拽BackgroundManager节点到这里'
  128. })
  129. public backgroundManagerNode: Node = null;
  130. @property({
  131. type: Node,
  132. tooltip: '拖拽GroundBurnAreaManager节点到这里'
  133. })
  134. public groundBurnAreaManagerNode: Node = null;
  135. // GameBlockSelection组件
  136. private blockSelectionComponent: GameBlockSelection = null;
  137. private pendingSkillSelection: boolean = false;
  138. private pendingBlockSelection: boolean = false;
  139. private shouldShowNextWavePrompt: boolean = false;
  140. // 墙体组件引用
  141. private wallComponent: Wall = null;
  142. private topFenceComponent: Wall = null;
  143. private bottomFenceComponent: Wall = null;
  144. // GameStartMove组件引用
  145. private gameStartMoveComponent: GameStartMove = null;
  146. start() {
  147. this.initializeGameState();
  148. this.setupEventListeners();
  149. this.initGameBlockSelection();
  150. this.initGameStartMove();
  151. this.initWallComponent();
  152. this.initUINodes();
  153. }
  154. update(deltaTime: number) {
  155. if (this.currentState !== GameState.PLAYING) {
  156. return;
  157. }
  158. this.checkTimer += deltaTime;
  159. if (this.checkTimer >= this.checkInterval) {
  160. this.checkTimer = 0;
  161. this.checkGameState();
  162. }
  163. }
  164. /**
  165. * 初始化游戏状态
  166. */
  167. private initializeGameState() {
  168. this.currentState = GameState.PLAYING;
  169. this.checkTimer = 0;
  170. this.enemySpawningStarted = false;
  171. this.totalEnemiesSpawned = 0;
  172. this.currentWave = 1;
  173. this.currentWaveEnemyCount = 0;
  174. this.currentWaveTotalEnemies = 0;
  175. this.energyPoints = 0;
  176. this.pendingSkillSelection = false;
  177. }
  178. /**
  179. * 设置事件监听器
  180. */
  181. private setupEventListeners() {
  182. const eventBus = EventBus.getInstance();
  183. eventBus.on(GameEvents.GAME_SUCCESS, this.onGameSuccessEvent, this);
  184. eventBus.on(GameEvents.GAME_DEFEAT, this.onGameDefeatEvent, this);
  185. eventBus.on(GameEvents.GAME_RESUME, this.onGameResumeEvent, this);
  186. eventBus.on(GameEvents.GAME_RESUME_SKILL_SELECTION, this.onGameResumeEvent, this);
  187. eventBus.on(GameEvents.GAME_RESUME_BLOCK_SELECTION, this.onGameResumeEvent, this);
  188. eventBus.on('ENEMY_KILLED', this.onEnemyKilledEvent, this);
  189. eventBus.on(GameEvents.RESET_ENERGY_SYSTEM, this.resetEnergySystem, this);
  190. eventBus.on(GameEvents.WALL_DESTROYED, this.onWallDestroyedEvent, this);
  191. }
  192. /**
  193. * 初始化GameBlockSelection组件
  194. */
  195. private initGameBlockSelection() {
  196. if (this.gameBlockSelection) {
  197. this.blockSelectionComponent = this.gameBlockSelection.getComponent(GameBlockSelection);
  198. }
  199. }
  200. /**
  201. * 初始化GameStartMove组件
  202. */
  203. private initGameStartMove() {
  204. if (this.cameraNode) {
  205. this.gameStartMoveComponent = this.cameraNode.getComponent(GameStartMove);
  206. }
  207. }
  208. /**
  209. * EnemyController现在通过事件系统通信,不再需要直接初始化
  210. */
  211. /**
  212. * 初始化墙体组件
  213. */
  214. private initWallComponent() {
  215. // 初始化主墙体
  216. if (this.wallNode) {
  217. this.wallComponent = this.wallNode.getComponent(Wall);
  218. if (this.wallComponent) {
  219. console.log('[InGameManager] 主墙体组件初始化成功');
  220. } else {
  221. console.warn('[InGameManager] 未找到主墙体Wall组件');
  222. }
  223. } else {
  224. console.warn('[InGameManager] 主墙体节点未通过装饰器挂载');
  225. }
  226. // 初始化上围栏
  227. if (this.topFenceNode) {
  228. this.topFenceComponent = this.topFenceNode.getComponent(Wall);
  229. if (this.topFenceComponent) {
  230. console.log('[InGameManager] 上围栏墙体组件初始化成功');
  231. } else {
  232. console.warn('[InGameManager] 未找到上围栏Wall组件');
  233. }
  234. } else {
  235. console.warn('[InGameManager] 上围栏节点未通过装饰器挂载');
  236. }
  237. // 初始化下围栏
  238. if (this.bottomFenceNode) {
  239. this.bottomFenceComponent = this.bottomFenceNode.getComponent(Wall);
  240. if (this.bottomFenceComponent) {
  241. console.log('[InGameManager] 下围栏墙体组件初始化成功');
  242. } else {
  243. console.warn('[InGameManager] 未找到下围栏Wall组件');
  244. }
  245. } else {
  246. console.warn('[InGameManager] 下围栏节点未通过装饰器挂载');
  247. }
  248. }
  249. /**
  250. * 获取指定波次的敌人配置
  251. */
  252. private getWaveEnemyConfigs(wave: number): any[] {
  253. if (!this.levelWaves || wave < 1 || wave > this.levelWaves.length) {
  254. return [];
  255. }
  256. const waveConfig = this.levelWaves[wave - 1];
  257. return waveConfig?.enemies || [];
  258. }
  259. /**
  260. * 检查是否应该播放diban动画
  261. */
  262. public shouldPlayDibanAnimation(): boolean {
  263. return this.preparingNextWave && this.currentState === GameState.BLOCK_SELECTION;
  264. }
  265. /**
  266. * 技能选择完成后的处理
  267. */
  268. public onSkillSelectionComplete() {
  269. console.log('[InGameManager] 技能选择完成');
  270. // 关闭技能选择UI
  271. if (this.selectSkillUI) {
  272. this.selectSkillUI.active = false;
  273. console.log('[InGameManager] 技能选择UI已关闭');
  274. }
  275. // 恢复游戏
  276. this.resumeGame();
  277. // 发射技能选择结束恢复事件
  278. EventBus.getInstance().emit(GameEvents.GAME_RESUME_SKILL_SELECTION);
  279. // 如果有等待的diban动画,现在播放diban动画
  280. if (this.pendingBlockSelection) {
  281. console.log('[InGameManager] 技能选择完成,现在播放diban动画');
  282. this.playDibanAnimationAfterSkill();
  283. }
  284. }
  285. /**
  286. * 在技能选择后播放diban动画
  287. */
  288. public playDibanAnimationAfterSkill() {
  289. if (this.pendingBlockSelection) {
  290. console.log('[InGameManager] 技能选择完成,现在播放diban动画');
  291. this.pendingBlockSelection = false;
  292. if (this.currentWave < (this.levelWaves?.length || 1)) {
  293. this.playDibanAnimationForNextWave();
  294. } else {
  295. console.log('[InGameManager] 最后一波结束,触发游戏胜利');
  296. this.triggerGameSuccess();
  297. }
  298. } else if (this.shouldPlayDibanAnimation()) {
  299. this.playDibanAnimationForNextWave();
  300. }
  301. }
  302. /**
  303. * 播放下一波diban动画
  304. */
  305. private playDibanAnimationForNextWave() {
  306. // 如果游戏已经结束,不播放diban动画
  307. if (this.isGameOver()) {
  308. console.warn('[InGameManager] 游戏已经结束(胜利或失败),不播放下一波diban动画!');
  309. return;
  310. }
  311. console.log('[InGameManager] 播放diban动画');
  312. // 生成方块选择(不显示UI)
  313. if (this.blockSelectionComponent) {
  314. this.blockSelectionComponent.generateBlockSelection();
  315. }
  316. // 使用GameStartMove组件播放diban上滑动画和镜头下移动画
  317. if (this.gameStartMoveComponent) {
  318. console.log('[InGameManager] 调用GameStartMove组件播放diban上滑动画');
  319. this.gameStartMoveComponent.slideUpFromBottom(0.3);
  320. } else {
  321. console.warn('[InGameManager] GameStartMove组件未找到,无法播放diban动画');
  322. }
  323. // 使用底板选择专用暂停事件,小球继续运动
  324. EventBus.getInstance().emit(GameEvents.GAME_PAUSE_BLOCK_SELECTION);
  325. }
  326. /**
  327. * 处理游戏成功事件
  328. */
  329. private onGameSuccessEvent() {
  330. console.log('[InGameManager] 接收到游戏成功事件');
  331. this.currentState = GameState.SUCCESS;
  332. // 游戏结束时进入暂停状态,停止所有游戏对象的行为
  333. console.log('[InGameManager] 游戏成功,触发游戏暂停');
  334. const eventBus = EventBus.getInstance();
  335. eventBus.emit(GameEvents.GAME_PAUSE);
  336. }
  337. /**
  338. * 处理游戏失败事件
  339. */
  340. private onGameDefeatEvent() {
  341. console.log('[InGameManager] 接收到游戏失败事件');
  342. this.currentState = GameState.DEFEAT;
  343. // 游戏结束时进入暂停状态,停止所有游戏对象的行为
  344. console.log('[InGameManager] 游戏失败,触发游戏暂停');
  345. const eventBus = EventBus.getInstance();
  346. eventBus.emit(GameEvents.GAME_PAUSE);
  347. }
  348. /**
  349. * 处理游戏恢复事件
  350. */
  351. private onGameResumeEvent() {
  352. console.log('[InGameManager] 接收到游戏恢复事件');
  353. }
  354. /**
  355. * 墙体被摧毁事件处理
  356. * 墙体现在直接触发GAME_DEFEAT事件,与菜单退出处理流程一致
  357. */
  358. private onWallDestroyedEvent() {
  359. console.log('[InGameManager] 收到墙体被摧毁事件,墙体已直接触发GAME_DEFEAT事件');
  360. // 不再需要调用checkGameState,因为墙体已直接触发GAME_DEFEAT事件
  361. }
  362. /**
  363. * 处理敌人被击杀事件
  364. */
  365. private onEnemyKilledEvent() {
  366. // 游戏状态检查现在通过事件系统处理
  367. if (this.isGameOver()) {
  368. console.warn('[InGameManager] 游戏已结束状态下onEnemyKilledEvent被调用!');
  369. return;
  370. }
  371. // 如果游戏状态已经是成功或失败,不处理敌人击杀事件
  372. if (this.currentState === GameState.SUCCESS || this.currentState === GameState.DEFEAT) {
  373. console.warn(`[InGameManager] 游戏已结束(${this.currentState}),跳过敌人击杀事件处理`);
  374. return;
  375. }
  376. this.enemiesKilled++;
  377. this.currentWaveEnemyCount++;
  378. const remaining = this.currentWaveTotalEnemies - this.currentWaveEnemyCount;
  379. console.log(`[InGameManager] 敌人被消灭,当前波剩余敌人: ${remaining}/${this.currentWaveTotalEnemies}`);
  380. // 每死一个敌人就立即增加能量
  381. const energyBeforeIncrement = this.energyPoints;
  382. this.incrementEnergy();
  383. // 通过事件系统更新敌人计数标签
  384. EventBus.getInstance().emit(GameEvents.ENEMY_UPDATE_COUNT, this.currentWaveEnemyCount);
  385. // 检查能量是否已满,如果满了需要触发技能选择
  386. const energyWillBeFull = energyBeforeIncrement + 1 >= this.energyMax;
  387. // 基于UI显示的敌人数量判断波次是否结束(Canvas-001/TopArea/EnemyNode/EnemyNumber为0)
  388. const isWaveEnd = remaining <= 0;
  389. if (isWaveEnd) {
  390. console.log(`[InGameManager] 波次结束检测: remaining=${remaining}`);
  391. // 如果能量已满,设置等待方块选择状态
  392. if (energyWillBeFull) {
  393. this.pendingBlockSelection = true;
  394. this.preparingNextWave = true;
  395. this.currentState = GameState.BLOCK_SELECTION;
  396. } else {
  397. if (this.currentWave < (this.levelWaves?.length || 1)) {
  398. this.showNextWavePrompt();
  399. } else {
  400. this.triggerGameSuccess();
  401. }
  402. }
  403. } else if (energyWillBeFull) {
  404. // 如果波次未结束但能量已满,设置状态为方块选择
  405. // 注意:onEnergyFull()已在incrementEnergy()中调用,这里不需要重复调用
  406. console.log('[InGameManager] 能量已满但波次未结束,设置方块选择状态');
  407. this.currentState = GameState.BLOCK_SELECTION;
  408. }
  409. }
  410. /**
  411. * 增加能量值
  412. */
  413. private incrementEnergy() {
  414. // 获取技能等级
  415. const energyHunterLevel = SkillManager.getInstance() ? SkillManager.getInstance().getSkillLevel('energy_hunter') : 0;
  416. const baseEnergy = 1;
  417. const bonusEnergy = SkillManager.calculateEnergyBonus ? SkillManager.calculateEnergyBonus(baseEnergy, energyHunterLevel) : baseEnergy;
  418. this.energyPoints += bonusEnergy;
  419. console.log(`[InGameManager] 能量值增加: +${bonusEnergy}, 当前: ${this.energyPoints}/${this.energyMax}`);
  420. // 检查是否达到当前能量最大值
  421. if (this.energyPoints >= this.energyMax) {
  422. this.onEnergyFull();
  423. // 能量满后重置为0,开始下一轮积累
  424. this.energyPoints = 0;
  425. }
  426. this.updateEnergyBar();
  427. }
  428. /**
  429. * 显示下一波提示
  430. */
  431. private showNextWavePrompt() {
  432. // 设置准备下一波的状态
  433. this.preparingNextWave = true;
  434. this.pendingBlockSelection = true;
  435. this.currentState = GameState.BLOCK_SELECTION;
  436. console.log('[InGameManager] 设置准备下一波状态,准备播放diban动画');
  437. // 如果当前没有技能选择UI显示,立即播放diban动画
  438. if (!this.selectSkillUI || !this.selectSkillUI.active) {
  439. this.playDibanAnimationForNextWave();
  440. }
  441. // 如果技能选择UI正在显示,则等待技能选择完成后再播放diban动画
  442. // 这种情况下,pendingBlockSelection已经在onEnemyKilledEvent中设置为true
  443. }
  444. /**
  445. * 游戏状态检查
  446. * 现在只检查敌人击败状态,墙体摧毁直接触发GAME_DEFEAT事件
  447. */
  448. private checkGameState() {
  449. // 如果游戏已经结束,不再进行状态检查
  450. if (this.currentState === GameState.SUCCESS || this.currentState === GameState.DEFEAT) {
  451. return;
  452. }
  453. // 墙体摧毁检查已移除,因为墙体现在直接触发GAME_DEFEAT事件
  454. // 这样与菜单退出的失败处理流程保持一致
  455. if (this.checkAllEnemiesDefeated()) {
  456. this.triggerGameSuccess();
  457. return;
  458. }
  459. }
  460. /**
  461. * 检查所有敌人是否被击败
  462. */
  463. private checkAllEnemiesDefeated(): boolean {
  464. // 如果敌人生成还未开始,不进行胜利检查
  465. if (!this.enemySpawningStarted) {
  466. return false;
  467. }
  468. // 基于当前波次的敌人击杀数量判断是否胜利
  469. // 如果当前波次的剩余敌人数量为0,且是最后一波,则胜利
  470. const currentWaveRemaining = this.currentWaveTotalEnemies - this.currentWaveEnemyCount;
  471. const isLastWave = this.currentWave >= (this.levelWaves?.length || 1);
  472. return currentWaveRemaining <= 0 && isLastWave;
  473. }
  474. /**
  475. * 触发游戏失败
  476. * 只负责记录游戏结束时间和发送事件,状态切换由GameEnd.ts统一处理
  477. */
  478. private triggerGameDefeat() {
  479. // 防止重复触发游戏失败
  480. if (this.currentState === GameState.SUCCESS || this.currentState === GameState.DEFEAT) {
  481. console.log('[InGameManager] 游戏已结束,跳过重复的失败触发');
  482. return;
  483. }
  484. // 记录游戏结束时间
  485. this.gameEndTime = Date.now();
  486. // 触发游戏结束状态事件
  487. EventBus.getInstance().emit(GameEvents.ENTER_GAME_END_STATE, { result: 'defeat' });
  488. console.log('[InGameManager] 游戏失败,发送GAME_DEFEAT事件,状态切换由GameEnd.ts处理');
  489. EventBus.getInstance().emit(GameEvents.GAME_DEFEAT);
  490. }
  491. /**
  492. * 触发游戏成功
  493. * 只负责记录游戏结束时间和发送事件,状态切换由GameEnd.ts统一处理
  494. */
  495. private triggerGameSuccess() {
  496. // 防止重复触发游戏成功
  497. if (this.currentState === GameState.SUCCESS || this.currentState === GameState.DEFEAT) {
  498. console.log('[InGameManager] 游戏已结束,跳过重复的成功触发');
  499. return;
  500. }
  501. // 记录游戏结束时间
  502. this.gameEndTime = Date.now();
  503. // 触发游戏结束状态事件
  504. EventBus.getInstance().emit(GameEvents.ENTER_GAME_END_STATE, { result: 'success' });
  505. console.log('[InGameManager] 游戏成功,发送GAME_SUCCESS事件,状态切换由GameEnd.ts处理');
  506. EventBus.getInstance().emit(GameEvents.GAME_SUCCESS);
  507. }
  508. /**
  509. * 获取游戏持续时间
  510. */
  511. public getGameDuration(): number {
  512. const endTime = this.gameEndTime || Date.now();
  513. return Math.max(0, endTime - this.gameStartTime);
  514. }
  515. /**
  516. * 获取当前游戏状态
  517. */
  518. public getCurrentState(): GameState {
  519. return this.currentState;
  520. }
  521. /**
  522. * 设置游戏状态
  523. */
  524. public setCurrentState(state: GameState) {
  525. this.currentState = state;
  526. // 当游戏状态变为PLAYING时,更新能量条显示
  527. if (state === GameState.PLAYING) {
  528. this.updateEnergyBar();
  529. }
  530. }
  531. /**
  532. * 初始化UI节点
  533. */
  534. private initUINodes() {
  535. // 初始化能量条
  536. if (this.energyBarNode) {
  537. this.energyBar = this.energyBarNode.getComponent(ProgressBar);
  538. if (this.energyBar) {
  539. console.log('[InGameManager] 能量条组件初始化成功');
  540. // 不在初始化阶段更新能量条,等待游戏状态变为PLAYING后再更新
  541. } else {
  542. console.error('[InGameManager] 能量条节点存在但ProgressBar组件未找到');
  543. }
  544. } else {
  545. console.error('[InGameManager] 能量条节点未通过装饰器挂载,请在Inspector中拖拽EnergyBar节点');
  546. }
  547. // 初始化技能选择UI
  548. if (this.selectSkillUINode) {
  549. this.selectSkillUI = this.selectSkillUINode;
  550. console.log('[InGameManager] 技能选择UI节点初始化成功');
  551. } else {
  552. console.error('[InGameManager] 技能选择UI节点未通过装饰器挂载,请在Inspector中拖拽SelectSkillUI节点');
  553. }
  554. // 初始化背景管理器
  555. if (this.backgroundManagerNode) {
  556. this.backgroundManager = this.backgroundManagerNode.getComponent(BackgroundManager);
  557. if (this.backgroundManager) {
  558. console.log('[InGameManager] 背景管理器组件初始化成功');
  559. } else {
  560. console.error('[InGameManager] 背景管理器节点存在但BackgroundManager组件未找到');
  561. }
  562. } else {
  563. console.error('[InGameManager] 背景管理器节点未通过装饰器挂载,请在Inspector中拖拽BackgroundManager节点');
  564. }
  565. // 初始化地面燃烧区域管理器
  566. if (this.groundBurnAreaManagerNode) {
  567. this.groundBurnAreaManager = this.groundBurnAreaManagerNode.getComponent(GroundBurnAreaManager);
  568. if (this.groundBurnAreaManager) {
  569. console.log('[InGameManager] 地面燃烧区域管理器组件初始化成功');
  570. } else {
  571. console.error('[InGameManager] 地面燃烧区域管理器节点存在但GroundBurnAreaManager组件未找到');
  572. }
  573. } else {
  574. console.error('[InGameManager] 地面燃烧区域管理器节点未通过装饰器挂载,请在Inspector中拖拽GroundBurnAreaManager节点');
  575. }
  576. }
  577. /**
  578. * 更新能量条显示
  579. */
  580. private updateEnergyBar() {
  581. // 只有在游戏状态为PLAYING时才更新能量条,避免初始化阶段的报错
  582. if (this.currentState !== GameState.PLAYING) {
  583. return;
  584. }
  585. if (this.energyBar && this.energyMax > 0) {
  586. const progress = this.energyPoints / this.energyMax;
  587. this.energyBar.progress = Math.min(progress, 1.0);
  588. console.log(`[InGameManager] 能量条更新: ${this.energyPoints}/${this.energyMax} (${Math.round(progress * 100)}%)`);
  589. } else {
  590. console.warn('[InGameManager] 能量条组件未初始化或energyMax未设置,无法更新显示');
  591. }
  592. }
  593. /**
  594. * 能量满时的处理
  595. */
  596. private onEnergyFull() {
  597. console.log('[InGameManager] 能量已满,开始升级处理');
  598. // 升级能量条
  599. this.upgradeEnergySystem();
  600. // 显示技能选择UI
  601. this.showSkillSelection();
  602. }
  603. /**
  604. * 升级能量系统
  605. */
  606. private upgradeEnergySystem() {
  607. // 增加升级次数
  608. this.energyUpgradeCount++;
  609. // 更新能量最大值
  610. // energyMaxUpgrades数组索引0是初始值,索引1是第1次升级后的值,以此类推
  611. if (this.energyUpgradeCount < this.energyMaxUpgrades.length) {
  612. const newMaxEnergy = this.energyMaxUpgrades[this.energyUpgradeCount];
  613. this.energyMax = newMaxEnergy;
  614. console.log(`[InGameManager] 能量条升级 ${this.energyUpgradeCount} 次,新的最大值: ${this.energyMax}`);
  615. } else {
  616. // 超出配置次数,按照上一次的值+1递增
  617. this.energyMax = this.energyMax + 1;
  618. console.log(`[InGameManager] 能量条升级超出配置次数,使用递增模式,新的最大值: ${this.energyMax}`);
  619. }
  620. // 立即更新能量条显示,确保新的最大值生效
  621. this.updateEnergyBar();
  622. }
  623. /**
  624. * 显示技能选择UI
  625. */
  626. private showSkillSelection() {
  627. if (this.selectSkillUI) {
  628. this.selectSkillUI.active = true;
  629. // 使用技能选择专用暂停事件,所有小球停止运动
  630. EventBus.getInstance().emit(GameEvents.GAME_PAUSE_SKILL_SELECTION);
  631. // 注意:不调用StartGame.resetEnergy(),因为那会重置整个能量系统包括最大值
  632. // 能量点数已在onEnergyFull()中重置为0
  633. }
  634. }
  635. /**
  636. * 恢复游戏
  637. */
  638. private resumeGame() {
  639. console.log('[InGameManager] 恢复游戏');
  640. EventBus.getInstance().emit(GameEvents.GAME_RESUME);
  641. }
  642. /**
  643. * 检查游戏是否结束
  644. */
  645. private isGameOver(): boolean {
  646. let gameOver = false;
  647. EventBus.getInstance().emit(GameEvents.GAME_CHECK_OVER, (isOver: boolean) => {
  648. gameOver = isOver;
  649. });
  650. return gameOver;
  651. }
  652. /**
  653. * 设置当前波次
  654. */
  655. public setCurrentWave(wave: number, enemyCount: number = 0) {
  656. this.currentWave = wave;
  657. this.currentWaveEnemyCount = 0; // 重置当前击杀数
  658. this.currentWaveTotalEnemies = enemyCount; // 设置该波次总敌人数
  659. const totalWaves = this.levelWaves?.length || 1;
  660. // 获取波次敌人配置
  661. const waveEnemyConfigs = this.getWaveEnemyConfigs(wave);
  662. // 获取当前波次的血量系数
  663. let healthMultiplier = 1.0;
  664. if (this.levelWaves && this.levelWaves.length > 0) {
  665. const waveIndex = wave - 1; // 波次从1开始,数组从0开始
  666. if (waveIndex >= 0 && waveIndex < this.levelWaves.length) {
  667. const waveData = this.levelWaves[waveIndex];
  668. if (waveData && typeof waveData.healthMultiplier === 'number') {
  669. healthMultiplier = waveData.healthMultiplier;
  670. }
  671. }
  672. }
  673. // 通过事件系统启动波次
  674. EventBus.getInstance().emit(GameEvents.ENEMY_START_WAVE, {
  675. wave: wave,
  676. totalWaves: totalWaves,
  677. enemyCount: enemyCount,
  678. waveEnemyConfigs: waveEnemyConfigs,
  679. healthMultiplier: healthMultiplier
  680. });
  681. }
  682. /**
  683. * 更新当前波次敌人数量
  684. */
  685. public updateCurrentWaveEnemyCount(count: number) {
  686. this.currentWaveEnemyCount = count;
  687. }
  688. /**
  689. * 获取当前波次
  690. */
  691. public getCurrentWave(): number {
  692. return this.currentWave;
  693. }
  694. /**
  695. * 获取当前波次敌人数量
  696. */
  697. public getCurrentWaveEnemyCount(): number {
  698. return this.currentWaveEnemyCount;
  699. }
  700. /**
  701. * 获取当前波次总敌人数量
  702. */
  703. public getCurrentWaveTotalEnemies(): number {
  704. return this.currentWaveTotalEnemies;
  705. }
  706. /**
  707. * 进入下一波
  708. */
  709. public nextWave() {
  710. this.currentWave++;
  711. // 根据关卡配置获取下一波敌人数
  712. let enemyTotal = 0;
  713. if (this.levelWaves && this.levelWaves.length >= this.currentWave) {
  714. const waveCfg = this.levelWaves[this.currentWave - 1];
  715. if (waveCfg && waveCfg.enemies) {
  716. enemyTotal = waveCfg.enemies.reduce((t: number, g: any) => t + (g.count || 0), 0);
  717. }
  718. }
  719. this.setCurrentWave(this.currentWave, enemyTotal);
  720. }
  721. /**
  722. * 获取当前能量值
  723. */
  724. public getCurrentEnergy(): number {
  725. return this.energyPoints;
  726. }
  727. /**
  728. * 获取最大能量值
  729. */
  730. public getMaxEnergy(): number {
  731. return this.energyMax;
  732. }
  733. /**
  734. * 获取墙体健康度(返回主墙体健康度)
  735. */
  736. public getWallHealth(): number {
  737. if (this.wallComponent) {
  738. return this.wallComponent.getCurrentHealth();
  739. }
  740. return 0;
  741. }
  742. /**
  743. * 获取所有墙体的健康度
  744. */
  745. public getAllWallsHealth(): { main: number; topFence: number; bottomFence: number } {
  746. return {
  747. main: this.wallComponent ? this.wallComponent.getCurrentHealth() : 0,
  748. topFence: this.topFenceComponent ? this.topFenceComponent.getCurrentHealth() : 0,
  749. bottomFence: this.bottomFenceComponent ? this.bottomFenceComponent.getCurrentHealth() : 0
  750. };
  751. }
  752. /**
  753. * 根据等级获取墙体健康度
  754. */
  755. public getWallHealthByLevel(level: number): number {
  756. if (this.wallComponent) {
  757. return this.wallComponent.getWallHealthByLevel(level);
  758. }
  759. return 100;
  760. }
  761. /**
  762. * 获取当前墙体等级(返回主墙体等级)
  763. */
  764. public getCurrentWallLevel(): number {
  765. if (this.wallComponent) {
  766. return this.wallComponent.getCurrentWallLevel();
  767. }
  768. return 1;
  769. }
  770. /**
  771. * 获取当前墙体健康度(返回主墙体健康度)
  772. */
  773. public getCurrentWallHealth(): number {
  774. if (this.wallComponent) {
  775. return this.wallComponent.getCurrentHealth();
  776. }
  777. return 100;
  778. }
  779. /**
  780. * 获取所有墙体的等级
  781. */
  782. public getAllWallsLevel(): { main: number; topFence: number; bottomFence: number } {
  783. return {
  784. main: this.wallComponent ? this.wallComponent.getCurrentWallLevel() : 1,
  785. topFence: this.topFenceComponent ? this.topFenceComponent.getCurrentWallLevel() : 1,
  786. bottomFence: this.bottomFenceComponent ? this.bottomFenceComponent.getCurrentWallLevel() : 1
  787. };
  788. }
  789. /**
  790. * 处理确认操作(方块选择确认)
  791. */
  792. public handleConfirmAction() {
  793. console.log('[InGameManager] 处理方块选择确认操作');
  794. // 如果是在准备下一波的状态,需要先切换到下一波
  795. if (this.preparingNextWave) {
  796. console.log('[InGameManager] 检测到准备下一波状态,切换到下一波');
  797. this.nextWave();
  798. // 重置状态
  799. this.preparingNextWave = false;
  800. this.pendingBlockSelection = false;
  801. this.currentState = GameState.PLAYING;
  802. }
  803. // 触发进入游玩状态事件
  804. EventBus.getInstance().emit(GameEvents.ENTER_PLAYING_STATE);
  805. // 注意:不再发送GAME_START事件,避免重复触发游戏启动流程
  806. // 游戏启动流程已在用户点击战斗按钮时完成,这里只需要启动游戏逻辑
  807. // 通过事件系统启动球的移动
  808. EventBus.getInstance().emit(GameEvents.BALL_START);
  809. console.log('[InGameManager] 发送BALL_START事件,球已启动');
  810. // 通过事件系统开始当前波次的敌人生成
  811. EventBus.getInstance().emit(GameEvents.ENEMY_START_GAME);
  812. EventBus.getInstance().emit(GameEvents.ENEMY_SHOW_START_WAVE_PROMPT);
  813. console.log(`[InGameManager] 波次 ${this.currentWave} 敌人生成已启动`);
  814. }
  815. /**
  816. * 重置能量值(供StartGame调用)
  817. */
  818. public resetEnergyValue() {
  819. this.energyPoints = 0;
  820. this.updateEnergyBar();
  821. console.log('[InGameManager] 能量值重置完成');
  822. }
  823. /**
  824. * 重置波次信息(供StartGame调用)
  825. */
  826. public resetWaveInfo() {
  827. this.currentWave = 1;
  828. this.currentWaveEnemyCount = 0;
  829. this.currentWaveTotalEnemies = 0;
  830. this.enemiesKilled = 0;
  831. this.totalEnemiesSpawned = 0;
  832. this.levelTotalEnemies = 0;
  833. console.log('[InGameManager] 波次信息重置完成');
  834. }
  835. /**
  836. * 重置能量系统(供StartGame调用)
  837. * 注意:只在游戏真正重新开始时重置升级状态,技能选择后不应重置升级状态
  838. */
  839. public resetEnergySystem() {
  840. this.energyPoints = 0;
  841. // 只有在游戏状态不是BLOCK_SELECTION时才重置升级状态
  842. // 这样可以避免技能选择后重置已获得的能量升级
  843. if (this.currentState !== GameState.BLOCK_SELECTION) {
  844. this.energyUpgradeCount = 0;
  845. // 重置energyMax到初始值(energyMaxUpgrades数组的第一个值)
  846. if (this.energyMaxUpgrades && this.energyMaxUpgrades.length > 0) {
  847. this.energyMax = this.energyMaxUpgrades[0];
  848. }
  849. console.log('[InGameManager] 能量系统完全重置(包括升级状态)');
  850. } else {
  851. console.log('[InGameManager] 技能选择状态下,仅重置能量点数,保持升级状态');
  852. }
  853. this.updateEnergyBar();
  854. console.log('[InGameManager] 能量系统重置完成');
  855. }
  856. /**
  857. * 清理游戏数据,为返回主页面做准备
  858. * 当游戏胜利或失败返回主页面时调用
  859. */
  860. private cleanupGameDataForMainMenu() {
  861. console.log('[InGameManager] 开始清理游戏数据,准备返回主页面');
  862. const eventBus = EventBus.getInstance();
  863. // 1. 清空场上的所有游戏对象
  864. console.log('[InGameManager] 清空场上敌人、方块、球');
  865. eventBus.emit(GameEvents.CLEAR_ALL_ENEMIES); // 清空所有敌人
  866. eventBus.emit(GameEvents.CLEAR_ALL_BULLETS); // 清空所有子弹
  867. eventBus.emit(GameEvents.CLEAR_ALL_GAME_OBJECTS); // 清空其他游戏对象
  868. // 2. 重置能量系统
  869. console.log('[InGameManager] 重置能量系统');
  870. this.energyPoints = 0;
  871. this.updateEnergyBar();
  872. // 3. 清空技能选择数据(重置临时技能状态)
  873. console.log('[InGameManager] 清空技能选择数据');
  874. const skillManager = SkillManager.getInstance();
  875. if (skillManager) {
  876. skillManager.resetAllSkillLevels();
  877. }
  878. // 4. 重置关卡数据和游戏状态
  879. console.log('[InGameManager] 重置关卡数据和游戏状态');
  880. this.currentWave = 1;
  881. this.currentWaveEnemyCount = 0;
  882. this.currentWaveTotalEnemies = 0;
  883. this.enemiesKilled = 0;
  884. this.totalEnemiesSpawned = 0;
  885. this.levelTotalEnemies = 0;
  886. this.levelWaves = [];
  887. this.gameStarted = false;
  888. this.enemySpawningStarted = false;
  889. this.preparingNextWave = false;
  890. this.pendingSkillSelection = false;
  891. this.pendingBlockSelection = false;
  892. this.shouldShowNextWavePrompt = false;
  893. // 5. 重置UI状态
  894. console.log('[InGameManager] 重置UI状态');
  895. if (this.selectSkillUI) {
  896. this.selectSkillUI.active = false;
  897. }
  898. // 6. 清理会话数据(局内金币等临时数据)
  899. console.log('[InGameManager] 清理会话数据');
  900. if (LevelSessionManager.inst) {
  901. LevelSessionManager.inst.clear(); // 清空局内金币等临时数据
  902. }
  903. // 7. 通过事件系统通知其他组件进行清理
  904. eventBus.emit(GameEvents.RESET_BALL_CONTROLLER); // 重置球控制器
  905. eventBus.emit(GameEvents.RESET_BLOCK_MANAGER); // 重置方块管理器
  906. eventBus.emit(GameEvents.RESET_BLOCK_SELECTION); // 重置方块选择
  907. eventBus.emit(GameEvents.RESET_ENEMY_CONTROLLER); // 重置敌人控制器
  908. eventBus.emit(GameEvents.RESET_WALL_HEALTH); // 重置墙体血量
  909. eventBus.emit(GameEvents.RESET_UI_STATES); // 重置UI状态
  910. // 8. 重置镜头位置
  911. console.log('[InGameManager] 重置镜头位置');
  912. if (this.gameStartMoveComponent) {
  913. this.gameStartMoveComponent.resetCameraToOriginalPositionImmediate();
  914. } else {
  915. console.warn('[InGameManager] GameStartMove组件未找到,无法重置镜头位置');
  916. }
  917. // 9. 发送游戏结束事件,确保游戏状态正确转换
  918. console.log('[InGameManager] 发送游戏结束事件');
  919. eventBus.emit('GAME_END');
  920. // 10. 重置游戏状态为初始状态
  921. this.currentState = GameState.PLAYING;
  922. // 11. 重置游戏结束时间,确保下次游戏状态检查正常
  923. this.gameEndTime = 0;
  924. console.log('[InGameManager] 游戏数据清理完成,可以安全返回主页面');
  925. }
  926. /**
  927. * 重置游戏状态(供StartGame调用)
  928. */
  929. public resetGameStates() {
  930. this.currentState = GameState.PLAYING;
  931. this.gameStarted = false;
  932. this.enemySpawningStarted = false;
  933. this.preparingNextWave = false;
  934. this.pendingSkillSelection = false;
  935. this.pendingBlockSelection = false;
  936. this.shouldShowNextWavePrompt = false;
  937. this.gameStartTime = 0;
  938. this.gameEndTime = 0;
  939. this.checkTimer = 0;
  940. console.log('[InGameManager] 游戏状态重置完成');
  941. }
  942. // resetGameRecord方法已被移除,避免与cleanupGameDataForMainMenu重复
  943. // 所有清理逻辑已统一在cleanupGameDataForMainMenu中处理
  944. /**
  945. * 手动触发游戏数据清理(供外部调用)
  946. * 可以在返回主菜单按钮点击时调用
  947. */
  948. public triggerGameDataCleanup() {
  949. this.cleanupGameDataForMainMenu();
  950. }
  951. /**
  952. * 应用关卡配置
  953. */
  954. public async applyLevelConfig(levelConfig: any) {
  955. console.log('[InGameManager] 应用关卡配置');
  956. // 应用能量配置 - 现在从energyMaxUpgrades数组获取初始值
  957. let initialEnergyMax = 5; // 默认值
  958. // 先读取energyMaxUpgrades配置以获取初始能量最大值
  959. if (levelConfig.levelSettings && levelConfig.levelSettings.energyMaxUpgrades && Array.isArray(levelConfig.levelSettings.energyMaxUpgrades) && levelConfig.levelSettings.energyMaxUpgrades.length > 0) {
  960. initialEnergyMax = levelConfig.levelSettings.energyMaxUpgrades[0];
  961. console.log(`[InGameManager] 从energyMaxUpgrades获取初始能量配置: ${initialEnergyMax}`);
  962. } else {
  963. console.warn('[InGameManager] 警告:关卡配置中缺少 energyMaxUpgrades 设置,使用默认值!');
  964. }
  965. this.energyMax = initialEnergyMax;
  966. this.updateEnergyBar();
  967. // 应用新的能量条升级配置
  968. if (levelConfig.levelSettings) {
  969. // 读取能量条升级后最大值配置
  970. if (levelConfig.levelSettings.energyMaxUpgrades && Array.isArray(levelConfig.levelSettings.energyMaxUpgrades)) {
  971. this.energyMaxUpgrades = [...levelConfig.levelSettings.energyMaxUpgrades];
  972. console.log(`[InGameManager] 应用能量条升级配置: ${this.energyMaxUpgrades.length}个配置`);
  973. } else {
  974. // 默认升级配置(基于初始最大值递增)
  975. this.energyMaxUpgrades = [];
  976. for (let i = 0; i < 20; i++) {
  977. this.energyMaxUpgrades.push(this.energyMax + i + 1);
  978. }
  979. console.log('[InGameManager] 使用默认能量条升级配置');
  980. }
  981. this.energyUpgradeCount = 0;
  982. console.log('[InGameManager] 初始化能量条升级系统');
  983. }
  984. // 如果有武器配置,应用武器
  985. if (levelConfig.weapons && Array.isArray(levelConfig.weapons)) {
  986. console.log('[InGameManager] 应用武器配置');
  987. // TODO: 应用武器配置逻辑
  988. }
  989. // 如果有波次配置,设置敌人波次
  990. if (levelConfig.waves && Array.isArray(levelConfig.waves)) {
  991. this.levelWaves = levelConfig.waves;
  992. this.currentWave = 1;
  993. // 计算本关卡总敌人数
  994. this.levelTotalEnemies = 0;
  995. for (const wave of this.levelWaves) {
  996. for (const enemy of wave.enemies || []) {
  997. this.levelTotalEnemies += enemy.count || 0;
  998. }
  999. }
  1000. console.log(`[InGameManager] 应用波次配置: ${this.levelWaves.length}波,总敌人数: ${this.levelTotalEnemies}`);
  1001. // 通过事件系统通知 EnemyController 初始化第一波数据及 UI
  1002. const firstWaveEnemies = this.levelWaves.length > 0 && this.levelWaves[0].enemies ?
  1003. this.levelWaves[0].enemies.reduce((t: number, g: any) => t + (g.count || 0), 0) : 0;
  1004. // 通过事件系统调用setCurrentWave
  1005. this.setCurrentWave(1, firstWaveEnemies);
  1006. }
  1007. // 应用背景图片配置
  1008. if (this.backgroundManager && levelConfig.backgroundImage) {
  1009. // 转换路径格式:从 "images/LevelBackground/BG1" 转换为 "LevelBackground/BG1"
  1010. const bundlePath = levelConfig.backgroundImage.replace('images/', '');
  1011. await this.backgroundManager.setBackground(bundlePath);
  1012. console.log(`[InGameManager] 应用背景配置: ${levelConfig.backgroundImage}`);
  1013. } else if (this.backgroundManager) {
  1014. // 如果没有指定背景图片,使用默认背景
  1015. await this.backgroundManager.setBackground('LevelBackground/BG1');
  1016. console.log('[InGameManager] 使用默认背景: LevelBackground/BG1');
  1017. }
  1018. }
  1019. onDestroy() {
  1020. const eventBus = EventBus.getInstance();
  1021. eventBus.off(GameEvents.GAME_SUCCESS, this.onGameSuccessEvent, this);
  1022. eventBus.off(GameEvents.GAME_DEFEAT, this.onGameDefeatEvent, this);
  1023. eventBus.off(GameEvents.GAME_RESUME, this.onGameResumeEvent, this);
  1024. eventBus.off(GameEvents.GAME_RESUME_SKILL_SELECTION, this.onGameResumeEvent, this);
  1025. eventBus.off(GameEvents.GAME_RESUME_BLOCK_SELECTION, this.onGameResumeEvent, this);
  1026. eventBus.off('ENEMY_KILLED', this.onEnemyKilledEvent, this);
  1027. eventBus.off(GameEvents.RESET_ENERGY_SYSTEM, this.resetEnergySystem, this);
  1028. eventBus.off(GameEvents.WALL_DESTROYED, this.onWallDestroyedEvent, this);
  1029. }
  1030. }