Browse Source

【BUG】修改第一关引导过后无法到第二关问题

mojunshou 7 months ago
parent
commit
bd3354c9a5

+ 7 - 2
assets/script/game/common/config/GameEvent.ts

@@ -2,7 +2,7 @@
  * @Author: dgflash
  * @Date: 2021-11-23 15:28:39
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-19 10:19:47
+ * @LastEditTime: 2025-04-27 14:21:50
  */
 
 /** 游戏事件 */
@@ -34,6 +34,11 @@ export enum GameEvent {
     /**开始自动功能*/
     StartAutoGame = "StartAutoGame",
     /**更新游戏状态*/
-    updateGameState = "updateGameState"
+    updateGameState = "updateGameState",
+    /**暂停游戏*/
+    pauseGame = "pauseGame",
+    /**恢复游戏*/
+    resumeGame = "resumeGame",
+
 
 }

+ 10 - 7
assets/script/game/common/manager/ADHandler.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-11 10:14:44
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-27 11:18:59
+ * @LastEditTime: 2025-04-27 14:24:24
  * @Description: 
  */
 // ADHandler.ts
@@ -62,12 +62,15 @@ export class ADHandler {
                 param.callback.onLoadFailed = 'ADHandler.inst.adInterstitialLoadFailed';
                 param.callback.onClose = 'ADHandler.inst.adInterstitialClose';
                 break;
-            default:
+            default: //激励视频
                 oops.gui.waitOpen();
+                // oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
+                oops.message.dispatchEvent(GameEvent.pauseGame);
                 method = 'ad.reward';
                 param.callback.onShow = 'ADHandler.inst.adRewardShow';
                 param.callback.onClose = 'ADHandler.inst.adRewardClose';
                 param.callback.onLoadFailed = 'ADHandler.inst.adRewardLoadFailed';
+                break;
         }
         return { method, param };
     }
@@ -93,9 +96,7 @@ export class ADHandler {
 
     adInterstitialClose = (type: boolean) => {
         console.log('[广告] 插屏广告关闭', type);
-        //如果有弹窗,则不发送事件,
         oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
-        // 如果是插屏广告
     };
 
     adRewardShow = (str: string) => {
@@ -110,7 +111,8 @@ export class ADHandler {
         const resetViewType = () => {
             smc.game.GameModel.viewType = "";
         };
-        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
+        // oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
+        oops.message.dispatchEvent(GameEvent.resumeGame);
         // 广告未完成观看
         switch (viewType) {
             case "pass_reward":
@@ -133,9 +135,10 @@ export class ADHandler {
 
     adRewardClose = (state: boolean) => {
         oops.gui.waitClose();
-        console.log("[广告] 激励视频关闭", state);
-        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
+        // oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
+        oops.message.dispatchEvent(GameEvent.resumeGame);
         const viewType = smc.game.GameModel.viewType;
+        console.log("viewType>>>>>>>>>>>", viewType);
         // 重置视图类型
         const resetViewType = () => {
             smc.game.GameModel.viewType = "";

+ 3 - 3
assets/script/game/common/manager/ProtocolEvent.ts

@@ -2,13 +2,13 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-07 10:17:16
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-27 10:34:18
+ * @LastEditTime: 2025-04-27 11:51:36
  * @Description: 消息定义
  */
 
-// const server_url = "http://192.168.10.103:8880";
+const server_url = "http://192.168.10.103:8880";
 // https://central-test.atmob.com
-const server_url = "https://central-test.atmob.com";
+// const server_url = "https://central-test.atmob.com";
 export enum ProtocolEvent {
     /**微信登录*/
     WechatLogin = server_url + "/project/playlet/v1/user/login",

+ 0 - 5
assets/script/game/common/manager/ServerHandler.ts

@@ -378,11 +378,6 @@ export class ServerHandler {
             account.hbCoin = props['1004'] || 0;
             game.changeHbCoin = changes['1004'] || 0;
             game.changeWxCoin = changes['1005'] || 0;
-            //是不是通关奖励点击的
-            if (smc.game.GameModel.viewType == "pass_reward") {
-                smc.game.GameModel.viewType = "";
-                this.getNextLevel();
-            }
             oops.message.dispatchEvent(GameEvent.showCoinAnimation);
         }
     }

+ 3 - 1
assets/script/game/view/DoubleRewardsView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 11:57:43
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-25 11:10:04
+ * @LastEditTime: 2025-04-27 14:33:38
  * @Description: 惊喜翻倍弹窗
  */
 import { _decorator, instantiate, Label, Node, Prefab, UITransform } from 'cc';
@@ -15,6 +15,7 @@ import { smc } from '../common/SingletonModuleComp';
 import { BricsItem } from './BricsItem';
 import { DCHandler } from '../common/manager/DCHandler';
 import { ServerHandler } from '../common/manager/ServerHandler';
+import { GameEvent } from '../common/config/GameEvent';
 
 const { ccclass, property } = _decorator;
 
@@ -92,6 +93,7 @@ export class DoubleRewardsView extends VMParent {
         smc.game.GameModel.viewType = "double_reward";
         ADHandler.inst.showAd(AD_TYPE.Double_Receive);
         oops.gui.remove(UIID.DoubleRewards);
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     }
 
 

+ 2 - 2
assets/script/game/view/DoubleSpeedViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 11:17:22
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-23 17:40:03
+ * @LastEditTime: 2025-04-27 14:31:36
  * @Description: 二倍速弹窗
  */
 import { _decorator } from "cc";
@@ -37,13 +37,13 @@ export class DoubleSpeedViewComp extends VMParent {
     private btn_open() {
         this.openAd();
         oops.gui.remove(UIID.DoubleSpeed);
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     }
 
     //打开广告
     private openAd() {
         smc.game.GameModel.viewType = "speed_reward";
         ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
-        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
         DCHandler.inst.reportData(3000301);
     }
 

+ 56 - 32
assets/script/game/view/EliminateViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:01:09
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-27 10:46:23
+ * @LastEditTime: 2025-04-27 15:21:12
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, v3, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -20,6 +20,7 @@ import { DCHandler } from "../common/manager/DCHandler";
 import { Tween } from "cc";
 import { AD_TYPE } from "../common/config/GameDefine";
 import { ADHandler } from "../common/manager/ADHandler";
+import { director } from "cc";
 
 const { ccclass, property } = _decorator;
 
@@ -193,6 +194,9 @@ export class EliminateViewComp extends CCComp {
     //旋转容错
     rotateFaultTolerant = 50;
 
+    //游戏暂停状态
+    private gamePause: boolean = false;
+
     isAutoMode: boolean = false;
     autoModeInterval: number = 1  // 自动模式的间隔时间(秒)
     autoModeTimer: number = 0  // 自动模式计时器
@@ -279,6 +283,8 @@ export class EliminateViewComp extends CCComp {
         oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
         oops.message.on(GameEvent.StartAutoGame, this.startAutoGame, this);
         oops.message.on(GameEvent.updateGameState, this.updateGameState, this);
+        oops.message.on(GameEvent.pauseGame, this.pauseGame, this);
+        oops.message.on(GameEvent.resumeGame, this.resumeGame, this);
     }
 
     updateGameState(event: string, args: string) {
@@ -295,7 +301,15 @@ export class EliminateViewComp extends CCComp {
         }
     }
 
+    pauseGame() {
+        this.gamePause = true;
+        director.pause();
+    }
 
+    resumeGame() {
+        this.gamePause = false;
+        director.resume();
+    }
 
     //初始化网格
     private initGrid() {
@@ -685,7 +699,7 @@ export class EliminateViewComp extends CCComp {
                 this.redPacketPrefab,
                 lastPos,
                 this.lab_hbCoin.node.getWorldPosition(),
-                5,
+                2,
                 () => {
                     // 显示红包分数增加动画
                     this.showRedPacketScoreAnimation();
@@ -699,7 +713,7 @@ export class EliminateViewComp extends CCComp {
                 this.coinPrefab,
                 lastPos,
                 this.lab_wxCoin.node.getWorldPosition(),
-                score,
+                2,
                 () => {
                     // 显示微信分数增加动画
                     this.showWechatScoreAnimation();
@@ -1261,11 +1275,15 @@ export class EliminateViewComp extends CCComp {
                         }
                         this.operateFlag = true;
                         //新手引导
+                        console.log("消除返回", this.isGuideMode);
+                        console.log("新手引导", this.guideStep);
                         if (this.isGuideMode) {
                             this.scheduleOnce(() => {
                                 if (this.guideStep < 4) {
+                                    console.log("新手引导", this.guideStep);
                                     this.setupGuideStep(this.guideStep + 1)
                                 } else {
+                                    console.log("新手引导结束");
                                     this.isGuideMode = false;
                                     this.guideNode.active = false;
                                     Tween.stopAllByTarget(this.guideFinger);
@@ -1472,7 +1490,7 @@ export class EliminateViewComp extends CCComp {
             .start();
     }
 
-    // 修改 gridEliminate 方法来显示消除次数
+    // 
     gridEliminate() {
         return new Promise<boolean>((resolve, reject) => {
             const d = this.gridEliminateCheck(this.gridList)
@@ -1537,7 +1555,6 @@ export class EliminateViewComp extends CCComp {
                 }
 
                 this.score += score;
-                this.updateGameScore();
                 if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
                     ServerHandler.inst.updateEliminationReward({
                         count: totalEliminationsInThisRound,
@@ -1545,40 +1562,38 @@ export class EliminateViewComp extends CCComp {
                         level: smc.account.AccountModel.curLevel,
                     })
                 }
-
                 if (DeviceUtil.isAndroid && DeviceUtil.isNative) {
-                    //需要欧安的是否通关了,当前通关了就不要弹了
-                    if (this.score >= this.targetScore) {
-                        return;
-                    }
-                    if (this.eliminateInterval.length > 0) {
-                        const minNum = this.eliminateInterval[0]
-                        const maxNum = this.eliminateInterval[1]
-                        if (minNum && maxNum) {
-                            const randomNum = randomRangeInt(minNum, maxNum + 1);
-                            //这个数可以被总消除次数整除那就可以弹广告
-                            if (this.eliminateTotal % randomNum === 0) {
-                                //如果有自动就暂停自动
-                                if (this.autoState) {
-                                    this.gameState = GameState.PAUSED;
-                                }
-                                if (smc.game.GameModel.skipAdConfig != -1) {
-                                    if (smc.game.GameModel.skipAdCount > 0 && smc.game.GameModel.skipAdCount % smc.game.GameModel.skipAdConfig == 0) {
-                                        console.log("skipAdCount>>>>>>>>>>>>>>>", smc.game.GameModel.skipAdCount);
-                                        console.log("skipAdConfig>>>>>>>>>>>>>>", smc.game.GameModel.skipAdConfig);
-                                        smc.game.GameModel.viewType = "double_reward";
-                                        ADHandler.inst.showAd(AD_TYPE.Double_Receive);
+                    //需要欧知道是否通关了,当前通关了就不要弹了
+                    if (this.score < this.targetScore) {
+                        if (this.eliminateInterval.length > 0) {
+                            const minNum = this.eliminateInterval[0]
+                            const maxNum = this.eliminateInterval[1]
+                            if (minNum && maxNum) {
+                                const randomNum = randomRangeInt(minNum, maxNum + 1);
+                                //这个数可以被总消除次数整除那就可以弹广告
+                                if (this.eliminateTotal % randomNum === 0) {
+                                    //如果有自动就暂停自动
+                                    if (this.autoState) {
+                                        this.gameState = GameState.PAUSED;
+                                    }
+                                    if (smc.game.GameModel.skipAdConfig != -1) {
+                                        if (smc.game.GameModel.skipAdCount > 0 && smc.game.GameModel.skipAdCount % smc.game.GameModel.skipAdConfig == 0) {
+                                            console.log("skipAdCount>>>>>>>>>>>>>>>", smc.game.GameModel.skipAdCount);
+                                            console.log("skipAdConfig>>>>>>>>>>>>>>", smc.game.GameModel.skipAdConfig);
+                                            smc.game.GameModel.viewType = "double_reward";
+                                            ADHandler.inst.showAd(AD_TYPE.Double_Receive);
+                                        } else {
+                                            ServerHandler.inst.getDoubleSurprise();
+                                        }
                                     } else {
                                         ServerHandler.inst.getDoubleSurprise();
                                     }
-                                } else {
-                                    ServerHandler.inst.getDoubleSurprise();
                                 }
                             }
                         }
                     }
                 }
-                // 告诉调用者有消除发生
+                this.updateGameScore();
                 resolve(true)
             }, 0.1)
         })
@@ -1625,6 +1640,7 @@ export class EliminateViewComp extends CCComp {
 
         let completedCount = 0;
         const totalCoins = Math.min(count, 5); // 限制最大数量
+        const delayBetweenCoins = 0.1; // 每个金币之间的延迟时间
 
         for (let i = 0; i < totalCoins; i++) {
             const coin = instantiate(prefab);
@@ -1633,7 +1649,10 @@ export class EliminateViewComp extends CCComp {
             coin.setWorldPosition(startPos);
             // 创建曲线动画
             const num = this.isDoubleSpeed ? this.doubleNum : 1;
+
+            // 添加延迟,使金币一个接一个飞出
             tween(coin)
+                .delay(i * delayBetweenCoins / num) // 每个金币有不同的延迟
                 .to(0.2 / num, {
                     position: new Vec3(
                         coin.position.x,
@@ -1932,6 +1951,10 @@ export class EliminateViewComp extends CCComp {
         smc.game.GameModel.curScore = this.score;
         if (this.score >= this.targetScore) {
             this.gameState = GameState.GAME_PASS;
+            //防止第一关的时候出问题
+            if (this.guideNode.active) {
+                this.guideNode.active = false;
+            }
             //弹出通关奖励界面
             DCHandler.inst.reportData(3000505, smc.account.AccountModel.curLevel);
             if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
@@ -2210,7 +2233,6 @@ export class EliminateViewComp extends CCComp {
 
                 // ✅ 销毁方块节点
                 brickData.brickNode.destroy()
-
                 // ✅ 补充新的砖块
                 this.addBrick(brickData.index)
                 // ✅ 消除检查逻辑保持和手动一致
@@ -2322,7 +2344,9 @@ export class EliminateViewComp extends CCComp {
         const showState = smc.game.GameModel.popupShow
         if (!showState) {
             //展示这些的时候,游戏要暂停
-            this.gameState = GameState.PAUSED;
+            if (this.popupType != "") {
+                this.gameState = GameState.PAUSED;
+            }
             switch (this.popupType) {
                 case "weal_1":
                     oops.gui.open(UIID.WarmReminder);

+ 1 - 2
assets/script/game/view/GameOverView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-27 18:19:53
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-23 17:49:45
+ * @LastEditTime: 2025-04-27 14:34:52
  * @Description: 游戏结束界面
  */
 import { _decorator } from 'cc';
@@ -45,7 +45,6 @@ export class GameOverView extends VMParent {
     }
 
     private btn_restart() {
-        // oops.message.dispatchEvent(GameEvent.RestartGame);
         ServerHandler.inst.RestartGame();
         oops.gui.remove(UIID.GameOver);
         DCHandler.inst.reportData(3000603);