Jelajahi Sumber

解决放行冲突问题

181404010226 1 Minggu lalu
induk
melakukan
6f0f043bc3
2 mengubah file dengan 10 tambahan dan 20 penghapusan
  1. 9 18
      assets/scripts/CharacterManager.ts
  2. 1 2
      assets/scripts/GameFlowManager.ts

+ 9 - 18
assets/scripts/CharacterManager.ts

@@ -48,14 +48,8 @@ export class CharacterManager extends Component {
             this.initialPosition.x += 400; // 初始位置的x坐标增加400
         }
 
-        // 设置按钮事件监听
-        if (this.letPassButton) {
-            this.letPassButton.node.on(Button.EventType.CLICK, this.moveCharacterRight, this);
-        }
-
-        if (this.dismissButton) {
-            this.dismissButton.node.on(Button.EventType.CLICK, this.moveCharacterLeft, this);
-        }
+        // 不再直接绑定按钮事件,这会导致回调函数丢失
+        // 这些按钮事件在GameFlowManager中处理
     }
     
     /**
@@ -112,7 +106,9 @@ export class CharacterManager extends Component {
      * @param onComplete 移动完成后的回调函数
      */
     public moveCharacterRight(onComplete?: () => void): void {
-        if (!this.characterNode || !this.initialPosition) return;
+        if (!this.characterNode || !this.initialPosition) {
+            return;
+        }
 
         // 隐藏对话框
         if (this.dialogueManager) {
@@ -155,7 +151,9 @@ export class CharacterManager extends Component {
      * @param onComplete 移动完成后的回调函数
      */
     public moveCharacterLeft(onComplete?: () => void): void {
-        if (!this.characterNode || !this.initialPosition) return;
+        if (!this.characterNode || !this.initialPosition) {
+            return;
+        }
 
         // 隐藏对话框
         if (this.dialogueManager) {
@@ -255,13 +253,6 @@ export class CharacterManager extends Component {
     }
 
     onDestroy() {
-        // 移除按钮事件监听
-        if (this.letPassButton) {
-            this.letPassButton.node.off(Button.EventType.CLICK, this.moveCharacterRight, this);
-        }
-
-        if (this.dismissButton) {
-            this.dismissButton.node.off(Button.EventType.CLICK, this.moveCharacterLeft, this);
-        }
+        // 不再需要移除这些事件监听
     }
 }

+ 1 - 2
assets/scripts/GameFlowManager.ts

@@ -104,7 +104,6 @@ export class GameFlowManager extends Component {
      * 显示下一个NPC
      */
     public showNextNpc(): void {
-        console.log('showNextNpc');
         this.currentNpcIndex++;
         
         // 检查是否还有NPC
@@ -128,7 +127,7 @@ export class GameFlowManager extends Component {
         // 配置角色外观,并在完成后让角色入场
         this.characterManager.setupCharacterAppearance(npc.characterId, npc.skinName, () => {
             // 让角色入场(只有在外观设置完成后才执行)
-            this.characterManager.characterEnter(undefined);
+            this.characterManager.characterEnter();
             
             // 启用按钮
             this.enableButtons();