IN_game.ts 44 KB

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