|
|
@@ -11,7 +11,7 @@ import { GameBlockSelection } from '../CombatSystem/BlockSelection/GameBlockSele
|
|
|
// GamePause已通过事件系统解耦,不再需要直接导入
|
|
|
import { Wall } from '../CombatSystem/Wall';
|
|
|
import { GameStartMove } from '../Animations/GameStartMove';
|
|
|
-import { ReStartGame } from './ReStartGame';
|
|
|
+import { StartGame } from './StartGame';
|
|
|
import { InGameManager, GameState } from './IN_game';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -109,6 +109,13 @@ export class GameManager extends Component {
|
|
|
|
|
|
// 游戏内管理器引用
|
|
|
private inGameManager: InGameManager = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // BlockSelection UI状态监听
|
|
|
+ private blockSelectionUIWasActive: boolean = false; // 记录BlockSelection UI的上一次状态
|
|
|
+ private blockSelectionUIInitialized: boolean = false; // 标记是否已初始化
|
|
|
+ private blockSelectionUIMonitoringEnabled: boolean = false; // 标记是否启用监听
|
|
|
|
|
|
// 游戏区域的边界
|
|
|
private gameBounds = {
|
|
|
@@ -157,6 +164,9 @@ export class GameManager extends Component {
|
|
|
}
|
|
|
|
|
|
start() {
|
|
|
+ // 初始化StartGame的静态事件监听器
|
|
|
+ StartGame.initializeEventListeners();
|
|
|
+
|
|
|
// 初始化物理系统
|
|
|
this.initPhysicsSystem();
|
|
|
|
|
|
@@ -177,7 +187,18 @@ export class GameManager extends Component {
|
|
|
// 初始化游戏状态
|
|
|
this.initializeGameState();
|
|
|
|
|
|
- // 初始化UI节点
|
|
|
+ // 设置应用状态为游戏中
|
|
|
+ this.currentAppState = AppState.IN_GAME;
|
|
|
+ console.log('[GameManager] 设置应用状态为IN_GAME');
|
|
|
+
|
|
|
+ // 先初始化UI状态监听(记录真实的初始状态)
|
|
|
+ this.initializeBlockSelectionUIListener();
|
|
|
+
|
|
|
+ // 启用BlockSelection UI状态监听
|
|
|
+ this.blockSelectionUIMonitoringEnabled = true;
|
|
|
+ console.log('[GameManager] 游戏启动,启用BlockSelection UI状态监听');
|
|
|
+
|
|
|
+ // 再初始化UI节点(可能会改变UI状态)
|
|
|
this.initUINodes();
|
|
|
|
|
|
// 敌人控制器已通过事件系统解耦,不再需要直接查找和设置
|
|
|
@@ -189,14 +210,19 @@ export class GameManager extends Component {
|
|
|
this.initGameBlockSelection();
|
|
|
this.initGameStartMove();
|
|
|
|
|
|
- // 加载当前关卡配置
|
|
|
- this.loadCurrentLevelConfig();
|
|
|
-
|
|
|
+ // 关卡配置加载已移至StartGame.initializeGameData()中,确保正确的时序
|
|
|
+
|
|
|
// 监听GamePause状态变化事件
|
|
|
this.setupGamePauseEventListeners();
|
|
|
|
|
|
// 初始化游戏计时器
|
|
|
this.gameStartTime = Date.now();
|
|
|
+
|
|
|
+ // 触发游戏启动流程(显示方块选择UI)
|
|
|
+ console.log('[GameManager] 触发游戏启动流程');
|
|
|
+ StartGame.startGameFlow().catch(error => {
|
|
|
+ console.error('[GameManager] 游戏启动流程出错:', error);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -220,6 +246,9 @@ export class GameManager extends Component {
|
|
|
// 监听重置游戏管理器事件
|
|
|
eventBus.on(GameEvents.RESET_GAME_MANAGER, this.onResetGameManagerEvent, this);
|
|
|
|
|
|
+ // 监听主菜单按钮点击事件(由UIStateManager转发)
|
|
|
+ eventBus.on('CONTINUE_CLICK', this.onMainMenuClick, this);
|
|
|
+
|
|
|
// 敌人击杀事件监听已迁移到 InGameManager
|
|
|
}
|
|
|
|
|
|
@@ -230,15 +259,10 @@ export class GameManager extends Component {
|
|
|
console.log('[GameManager] 接收到游戏成功事件,执行成功处理');
|
|
|
|
|
|
// 游戏状态管理已迁移到 InGameManager
|
|
|
+ // UI显示控制已迁移到 UIStateManager
|
|
|
|
|
|
// 注意:不在这里切换到MAIN_MENU状态,保持IN_GAME状态
|
|
|
// 只有用户点击成功界面的按钮时才切换到主界面
|
|
|
-
|
|
|
- // 显示游戏结束UI并设置成功文本
|
|
|
- if (this.gameEndUI) {
|
|
|
- this.gameEndUI.active = true;
|
|
|
- this.setEndLabelText('SUCCESS');
|
|
|
- }
|
|
|
|
|
|
// 执行游戏成功逻辑
|
|
|
this.onGameSuccess();
|
|
|
@@ -251,15 +275,10 @@ export class GameManager extends Component {
|
|
|
console.log('[GameManager] 接收到游戏失败事件,执行失败处理');
|
|
|
|
|
|
// 游戏状态管理已迁移到 InGameManager
|
|
|
+ // UI显示控制已迁移到 UIStateManager
|
|
|
|
|
|
// 注意:不在这里切换到MAIN_MENU状态,保持IN_GAME状态
|
|
|
// 只有用户点击失败界面的按钮时才切换到主界面
|
|
|
-
|
|
|
- // 显示游戏结束UI并设置失败文本
|
|
|
- if (this.gameEndUI) {
|
|
|
- this.gameEndUI.active = true;
|
|
|
- this.setEndLabelText('DEFEAT');
|
|
|
- }
|
|
|
|
|
|
// 执行游戏失败逻辑
|
|
|
this.onGameDefeat().catch(error => {
|
|
|
@@ -280,8 +299,25 @@ export class GameManager extends Component {
|
|
|
* 处理游戏重启事件
|
|
|
*/
|
|
|
private onGameRestartEvent() {
|
|
|
- console.log('[GameManager] 接收到游戏重启事件');
|
|
|
- this.restartGame();
|
|
|
+ console.log('[GameManager] 接收到游戏重启事件,重置GameManager状态');
|
|
|
+
|
|
|
+ // 设置应用状态为游戏中
|
|
|
+ this.currentAppState = AppState.IN_GAME;
|
|
|
+ this.gameStarted = false;
|
|
|
+ this.gameStartTime = 0;
|
|
|
+ this.gameEndTime = 0;
|
|
|
+
|
|
|
+ // 启用BlockSelection UI状态监听
|
|
|
+ this.blockSelectionUIMonitoringEnabled = true;
|
|
|
+ console.log('[GameManager] 游戏重启,启用BlockSelection UI状态监听');
|
|
|
+
|
|
|
+ console.log('[GameManager] GameManager状态重置完成');
|
|
|
+
|
|
|
+ // 直接调用StartGame的启动方法,统一使用游戏启动流程
|
|
|
+ console.log('[GameManager] 直接调用StartGame.startGameFlow');
|
|
|
+ StartGame.startGameFlow().catch(error => {
|
|
|
+ console.error('[GameManager] 游戏重启流程出错:', error);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -294,7 +330,88 @@ export class GameManager extends Component {
|
|
|
this.gameStarted = false;
|
|
|
this.gameStartTime = 0;
|
|
|
this.gameEndTime = 0;
|
|
|
- console.log('[GameManager] 游戏管理器状态已重置');
|
|
|
+
|
|
|
+ // 禁用UI状态监听
|
|
|
+ this.blockSelectionUIMonitoringEnabled = false;
|
|
|
+
|
|
|
+ console.log('[GameManager] 游戏管理器状态已重置,UI监听已禁用');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化BlockSelection UI状态监听
|
|
|
+ */
|
|
|
+ private initializeBlockSelectionUIListener() {
|
|
|
+ if (!this.gameBlockSelection) {
|
|
|
+ console.warn('[GameManager] BlockSelection UI节点未找到,无法初始化状态监听');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取GameBlockSelection组件,检查是否有blockSelectionUINode引用
|
|
|
+ const blockSelectionComponent = this.gameBlockSelection.getComponent(GameBlockSelection);
|
|
|
+ let targetNode = this.gameBlockSelection; // 默认监听gameBlockSelection节点
|
|
|
+
|
|
|
+ if (blockSelectionComponent && blockSelectionComponent.blockSelectionUINode) {
|
|
|
+ // 如果组件有blockSelectionUINode引用,监听该节点
|
|
|
+ targetNode = blockSelectionComponent.blockSelectionUINode;
|
|
|
+ console.log('[GameManager] 将监听blockSelectionUINode:', targetNode.name);
|
|
|
+ } else {
|
|
|
+ console.log('[GameManager] 将监听gameBlockSelection节点:', targetNode.name);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录初始状态
|
|
|
+ this.blockSelectionUIWasActive = targetNode.active;
|
|
|
+ this.blockSelectionUIInitialized = true;
|
|
|
+
|
|
|
+ console.log(`[GameManager] BlockSelection UI状态监听已初始化,目标节点: ${targetNode.name},初始状态: ${this.blockSelectionUIWasActive}`);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查BlockSelection UI状态变化并处理清理逻辑
|
|
|
+ */
|
|
|
+ private checkBlockSelectionUIStateChange() {
|
|
|
+ if (!this.blockSelectionUIInitialized || !this.gameBlockSelection || !this.blockSelectionUIMonitoringEnabled) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取要监听的目标节点
|
|
|
+ const blockSelectionComponent = this.gameBlockSelection.getComponent(GameBlockSelection);
|
|
|
+ let targetNode = this.gameBlockSelection;
|
|
|
+
|
|
|
+ if (blockSelectionComponent && blockSelectionComponent.blockSelectionUINode) {
|
|
|
+ targetNode = blockSelectionComponent.blockSelectionUINode;
|
|
|
+ }
|
|
|
+
|
|
|
+ const currentActive = targetNode.active;
|
|
|
+
|
|
|
+ // 检测从非激活状态变为激活状态(UI显示)
|
|
|
+ if (!this.blockSelectionUIWasActive && currentActive) {
|
|
|
+ console.log(`[GameManager] 检测到BlockSelection UI显示 (${targetNode.name}),触发方块清理`);
|
|
|
+ this.onBlockSelectionUIShow();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新状态记录
|
|
|
+ this.blockSelectionUIWasActive = currentActive;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理BlockSelection UI显示事件
|
|
|
+ */
|
|
|
+ private onBlockSelectionUIShow() {
|
|
|
+ console.log('[GameManager] BlockSelection UI显示,触发方块清理');
|
|
|
+
|
|
|
+ // 触发方块清理事件
|
|
|
+ const eventBus = EventBus.getInstance();
|
|
|
+ eventBus.emit(GameEvents.RESET_BLOCK_MANAGER);
|
|
|
+
|
|
|
+ console.log('[GameManager] 方块清理事件已发送');
|
|
|
}
|
|
|
|
|
|
// 敌人击杀事件处理已迁移到 InGameManager
|
|
|
@@ -314,9 +431,6 @@ export class GameManager extends Component {
|
|
|
const eventBus = EventBus.getInstance();
|
|
|
eventBus.emit(GameEvents.GAME_RESUME);
|
|
|
|
|
|
- if (this.gameEndUI) {
|
|
|
- this.gameEndUI.active = false;
|
|
|
- }
|
|
|
// === 新增:恢复时弹出下一波提示Toast ===
|
|
|
if (this.shouldShowNextWavePrompt) {
|
|
|
this.shouldShowNextWavePrompt = false;
|
|
|
@@ -326,6 +440,9 @@ export class GameManager extends Component {
|
|
|
}
|
|
|
|
|
|
update(deltaTime: number) {
|
|
|
+ // 检查UI状态变化(无论在什么状态下都要检查)
|
|
|
+ this.checkBlockSelectionUIStateChange();
|
|
|
+
|
|
|
// 只有在游戏中时才进行游戏逻辑更新
|
|
|
if (this.currentAppState !== AppState.IN_GAME) {
|
|
|
return;
|
|
|
@@ -357,9 +474,8 @@ export class GameManager extends Component {
|
|
|
this.levelConfigManager = LevelConfigManager.getInstance();
|
|
|
// enemyController已通过事件系统解耦,不再需要直接初始化
|
|
|
|
|
|
- // 初始化存档管理器
|
|
|
+ // 存档管理器初始化已迁移到StartGame
|
|
|
this.saveDataManager = SaveDataManager.getInstance();
|
|
|
- this.saveDataManager.initialize();
|
|
|
}
|
|
|
|
|
|
// === 游戏状态初始化 ===
|
|
|
@@ -372,6 +488,7 @@ export class GameManager extends Component {
|
|
|
}
|
|
|
|
|
|
// === 计算游戏区域边界 ===
|
|
|
+ // 已迁移到StartGame,这里保留方法以兼容现有调用
|
|
|
private calculateGameBounds() {
|
|
|
const canvas = find('Canvas');
|
|
|
if (!canvas) {
|
|
|
@@ -395,11 +512,6 @@ export class GameManager extends Component {
|
|
|
|
|
|
// === 初始化UI节点 ===
|
|
|
private initUINodes() {
|
|
|
- // 初始化游戏结束UI
|
|
|
- if (this.gameEndUI) {
|
|
|
- this.gameEndUI.active = false;
|
|
|
- }
|
|
|
-
|
|
|
// 初始化游戏内管理器
|
|
|
if (this.inGameManagerNode) {
|
|
|
this.inGameManager = this.inGameManagerNode.getComponent(InGameManager);
|
|
|
@@ -466,11 +578,33 @@ export class GameManager extends Component {
|
|
|
// 更新统计数据
|
|
|
this.saveDataManager.updateStatistic('totalTimePlayed', gameTime);
|
|
|
this.saveDataManager.updateStatistic('totalEnemiesDefeated', this.totalEnemiesSpawned);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除上一关的成功或失败记录
|
|
|
+ */
|
|
|
+ private clearPreviousGameRecord() {
|
|
|
+ console.log('[GameManager] 清除上一关的游戏记录');
|
|
|
+
|
|
|
+ // 重置游戏时间记录
|
|
|
+ this.gameStartTime = 0;
|
|
|
+ this.gameEndTime = 0;
|
|
|
|
|
|
- // 兼容原有的LevelManager
|
|
|
- if (this.levelManager) {
|
|
|
- this.levelManager.completeLevel(currentLevel, 0);
|
|
|
+ // 重置敌人击杀统计
|
|
|
+ this.totalEnemiesSpawned = 0;
|
|
|
+
|
|
|
+ // 通过InGameManager重置游戏状态记录
|
|
|
+ const inGameManager = this.getInGameManager();
|
|
|
+ if (inGameManager) {
|
|
|
+ // 重置InGameManager中的游戏状态
|
|
|
+ inGameManager.resetGameRecord();
|
|
|
+ console.log('[GameManager] InGameManager游戏记录已重置');
|
|
|
}
|
|
|
+
|
|
|
+ console.log('[GameManager] 上一关游戏记录清除完成');
|
|
|
+
|
|
|
+ // 兼容原有的LevelManager(已移除错误的currentLevel引用)
|
|
|
+ // 注意:LevelManager的相关逻辑已迁移到SaveDataManager
|
|
|
}
|
|
|
|
|
|
// === 计算游戏时长 ===
|
|
|
@@ -489,82 +623,48 @@ export class GameManager extends Component {
|
|
|
this.setupEndUIButtons();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置游戏结束UI的EndLabel文本
|
|
|
- * @param text 要显示的文本 ('SUCCESS' 或 'DEFEAT')
|
|
|
- */
|
|
|
- private setEndLabelText(text: string) {
|
|
|
- if (!this.gameEndUI) return;
|
|
|
-
|
|
|
- const endLabel = this.gameEndUI.getChildByPath('Sprite/EndLabel');
|
|
|
- if (endLabel) {
|
|
|
- const labelComponent = endLabel.getComponent(Label);
|
|
|
- if (labelComponent) {
|
|
|
- labelComponent.string = text;
|
|
|
- console.log(`[GameManager] 设置EndLabel文本为: ${text}`);
|
|
|
- } else {
|
|
|
- console.warn('[GameManager] 未找到EndLabel的Label组件');
|
|
|
- }
|
|
|
- } else {
|
|
|
- console.warn('[GameManager] 未找到EndLabel节点路径: Sprite/EndLabel');
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// === 设置游戏结束界面按钮 ===
|
|
|
private setupEndUIButtons() {
|
|
|
- if (this.gameEndUI) {
|
|
|
- const restartBtn = this.gameEndUI.getChildByName('RestartBtn');
|
|
|
- const mainMenuBtn = this.gameEndUI.getChildByName('MainMenuBtn');
|
|
|
- const shopBtn = this.gameEndUI.getChildByName('ShopBtn');
|
|
|
- const reviveBtn = this.gameEndUI.getChildByName('ReviveBtn');
|
|
|
-
|
|
|
- if (restartBtn) {
|
|
|
- const button = restartBtn.getComponent(Button);
|
|
|
- if (button) {
|
|
|
- button.node.on(Button.EventType.CLICK, this.onRestartClick, this);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (mainMenuBtn) {
|
|
|
- const button = mainMenuBtn.getComponent(Button);
|
|
|
- if (button) {
|
|
|
- button.node.on(Button.EventType.CLICK, this.onMainMenuClick, this);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (shopBtn) {
|
|
|
- const button = shopBtn.getComponent(Button);
|
|
|
- if (button) {
|
|
|
- button.node.on(Button.EventType.CLICK, this.onShopClick, this);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (reviveBtn) {
|
|
|
- const button = reviveBtn.getComponent(Button);
|
|
|
- if (button) {
|
|
|
- button.node.on(Button.EventType.CLICK, this.onReviveClick, this);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // UI按钮事件处理已迁移到 UIStateManager
|
|
|
+ // 通过事件系统处理按钮点击事件
|
|
|
}
|
|
|
|
|
|
// === 按钮点击事件处理 ===
|
|
|
- private onRestartClick() {
|
|
|
- console.log('[GameManager] 重新开始游戏');
|
|
|
- // 通过事件系统触发游戏重启
|
|
|
- const eventBus = EventBus.getInstance();
|
|
|
- eventBus.emit(GameEvents.GAME_RESTART);
|
|
|
- }
|
|
|
|
|
|
private onMainMenuClick() {
|
|
|
console.log('[GameManager] 返回主菜单');
|
|
|
|
|
|
- // 首先清理游戏数据
|
|
|
- if (this.inGameManager) {
|
|
|
+ // 1. 通过InGameManager清理游戏数据(敌人清除、能量条重置、方块清除、敌人波数和数量重置)
|
|
|
+ const inGameManager = this.getInGameManager();
|
|
|
+ if (inGameManager) {
|
|
|
console.log('[GameManager] 触发游戏数据清理');
|
|
|
- this.inGameManager.triggerGameDataCleanup();
|
|
|
+ inGameManager.triggerGameDataCleanup();
|
|
|
+ } else {
|
|
|
+ console.warn('[GameManager] 未找到InGameManager,跳过游戏数据清理');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 发送重置UI状态事件,让UIStateManager统一关闭所有相关面板
|
|
|
+ const eventBus = EventBus.getInstance();
|
|
|
+ eventBus.emit(GameEvents.RESET_UI_STATES);
|
|
|
+
|
|
|
+ // 3. 清除上一关的成功或失败记录
|
|
|
+ this.clearPreviousGameRecord();
|
|
|
+
|
|
|
+ // 4. 重置关卡到第1关(解决能量条未重置和下次战斗变成下一关的问题)
|
|
|
+ if (this.saveDataManager) {
|
|
|
+ this.saveDataManager.setCurrentLevel(1);
|
|
|
+ console.log('[GameManager] 关卡已重置为第1关');
|
|
|
}
|
|
|
|
|
|
+ // 5. 重置应用状态为主菜单
|
|
|
+ this.currentAppState = AppState.MAIN_MENU;
|
|
|
+ console.log('[GameManager] 应用状态已重置为MAIN_MENU');
|
|
|
+
|
|
|
+ // 6. 触发返回主菜单事件
|
|
|
+ eventBus.emit(GameEvents.RETURN_TO_MAIN_MENU);
|
|
|
+
|
|
|
// 使用装饰器属性获取MainUI,避免使用find
|
|
|
if (!this.mainUI) {
|
|
|
console.error('[GameManager] MainUI节点未在编辑器中设置,请拖拽Canvas/MainUI到GameManager的mainUI属性');
|
|
|
@@ -645,6 +745,10 @@ export class GameManager extends Component {
|
|
|
this.gameStartTime = Date.now();
|
|
|
// 游戏状态管理已迁移到 InGameManager
|
|
|
|
|
|
+ // 启用BlockSelection UI状态监听
|
|
|
+ this.blockSelectionUIMonitoringEnabled = true;
|
|
|
+ console.log('[GameManager] 游戏开始,启用BlockSelection UI状态监听');
|
|
|
+
|
|
|
// 发送游戏开始事件,通知其他组件
|
|
|
const eventBus = EventBus.getInstance();
|
|
|
eventBus.emit(GameEvents.GAME_START);
|
|
|
@@ -665,10 +769,7 @@ export class GameManager extends Component {
|
|
|
// 通过事件系统开始敌人生成
|
|
|
eventBus.emit(GameEvents.ENEMY_START_GAME);
|
|
|
|
|
|
- LevelSessionManager.inst.initialize(
|
|
|
- SaveDataManager.getInstance().getCurrentLevel(),
|
|
|
- this.getWallHealth()
|
|
|
- );
|
|
|
+ // 注意:LevelSessionManager已在StartGame.startGameFlow()中正确初始化,无需重复初始化
|
|
|
}
|
|
|
|
|
|
private spawnBall() {
|
|
|
@@ -800,11 +901,11 @@ export class GameManager extends Component {
|
|
|
this.gameStartTime = 0;
|
|
|
this.gameEndTime = 0;
|
|
|
|
|
|
- // 通过事件系统重置游戏状态
|
|
|
+ // 通过事件系统触发游戏重启,让StartGame组件处理完整的重置流程
|
|
|
const eventBus = EventBus.getInstance();
|
|
|
- eventBus.emit(GameEvents.RESET_GAME_MANAGER);
|
|
|
+ eventBus.emit(GameEvents.GAME_RESTART);
|
|
|
|
|
|
- console.log('[GameManager] 游戏状态重置完成');
|
|
|
+ console.log('[GameManager] 游戏重启事件已发送');
|
|
|
}
|
|
|
|
|
|
public forceGameSuccess() {
|
|
|
@@ -842,15 +943,10 @@ export class GameManager extends Component {
|
|
|
eventBus.off(GameEvents.GAME_DEFEAT, this.onGameDefeatEvent, this);
|
|
|
eventBus.off(GameEvents.GAME_RESTART, this.onGameRestartEvent, this);
|
|
|
eventBus.off(GameEvents.RESET_GAME_MANAGER, this.onResetGameManagerEvent, this);
|
|
|
+ eventBus.off('CONTINUE_CLICK', this.onMainMenuClick, this);
|
|
|
// ENEMY_KILLED事件监听已迁移到 InGameManager
|
|
|
|
|
|
- // 清理按钮事件监听
|
|
|
- if (this.gameEndUI) {
|
|
|
- const buttons = this.gameEndUI.getComponentsInChildren(Button);
|
|
|
- buttons.forEach(button => {
|
|
|
- button.node.off(Button.EventType.CLICK);
|
|
|
- });
|
|
|
- }
|
|
|
+ // 按钮事件监听已迁移到 UIStateManager
|
|
|
|
|
|
// 清理单例实例
|
|
|
if (GameManager._instance === this) {
|
|
|
@@ -998,14 +1094,24 @@ export class GameManager extends Component {
|
|
|
|
|
|
// 初始化GameBlockSelection组件
|
|
|
private initGameBlockSelection() {
|
|
|
+ console.log('[GameManager] 初始化GameBlockSelection组件');
|
|
|
+ console.log('[GameManager] gameBlockSelection节点:', !!this.gameBlockSelection, this.gameBlockSelection?.name);
|
|
|
+
|
|
|
if (this.gameBlockSelection) {
|
|
|
this.blockSelectionComponent = this.gameBlockSelection.getComponent(GameBlockSelection);
|
|
|
+ console.log('[GameManager] GameBlockSelection组件获取结果:', !!this.blockSelectionComponent);
|
|
|
+
|
|
|
if (this.blockSelectionComponent) {
|
|
|
// 设置确认回调
|
|
|
this.blockSelectionComponent.setConfirmCallback(() => {
|
|
|
this.handleConfirmAction();
|
|
|
});
|
|
|
+ console.log('[GameManager] GameBlockSelection组件初始化成功,确认回调已设置');
|
|
|
+ } else {
|
|
|
+ console.error('[GameManager] 无法获取GameBlockSelection组件,请检查节点是否正确挂载了该组件');
|
|
|
}
|
|
|
+ } else {
|
|
|
+ console.error('[GameManager] gameBlockSelection节点未设置,请在Inspector中拖拽正确的节点');
|
|
|
}
|
|
|
}
|
|
|
|