Kaynağa Gözat

【优化】修改新手引导引起的消除问题

mojunshou 7 ay önce
ebeveyn
işleme
5e9214d548

+ 3 - 1
assets/script/game/common/config/GameEvent.ts

@@ -32,6 +32,8 @@ export enum GameEvent {
     //更新红包币和微信币
     updateHbAndWxCoin = "updateHbAndWxCoin",
     /**开始自动功能*/
-    StartAutoGame = "StartAutoGame"
+    StartAutoGame = "StartAutoGame",
+    /**更新游戏状态*/
+    updateGameState = "updateGameState"
 
 }

+ 4 - 0
assets/script/game/common/manager/ADHandler.ts

@@ -85,11 +85,13 @@ export class ADHandler {
 
     adInterstitialLoadFailed = () => {
         console.log('[广告] 插屏广告加载失败');
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     };
 
     adInterstitialClose = (type: boolean) => {
         smc.game.GameModel.isShowAd = false;
         console.log('[广告] 插屏广告关闭', type);
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     };
 
     adRewardShow = (str: string) => {
@@ -107,6 +109,7 @@ export class ADHandler {
             smc.game.GameModel.curScore = Math.floor(score / 2);
             oops.message.dispatchEvent(GameEvent.RestartGame);
         }
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     };
 
     adRewardClose = (state: boolean) => {
@@ -130,6 +133,7 @@ export class ADHandler {
             }
             ServerHandler.inst.getVideorReward();
         }
+        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
     };
 }
 window["ADHandler"] = ADHandler;

+ 2 - 1
assets/script/game/common/manager/ServerHandler.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-11 10:16:41
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-22 19:55:58
+ * @LastEditTime: 2025-04-23 10:28:35
  * @Description: 
  */
 // ServerHandler.ts
@@ -308,6 +308,7 @@ export class ServerHandler {
         if (smc.game.GameModel.curLevelConfig.eventType && smc.game.GameModel.curLevelConfig.eventType == "WITHDRAW_POINT") {
             //展示提现信息
             this.WechatReward();
+            smc.game.GameModel.curLevelConfig.eventType = "";
         } else {
             this.getNextLevel();
         }

+ 21 - 1
assets/script/game/model/GameModelComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-10 14:49:42
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-19 16:36:21
+ * @LastEditTime: 2025-04-23 10:37:23
  * @Description: 
  */
 import { ecs } from "db://oops-framework/libs/ecs/ECS";
@@ -96,6 +96,15 @@ interface loadBarInfo {
     wealCount: number  //福利次数
 }
 
+// 游戏状态枚举
+enum GameState {
+    READY,      // 准备中
+    PLAYING,    // 游戏中
+    PAUSED,     // 暂停 --进其他界面,广告等,游戏自动状态暂停
+    GAME_OVER,  // 游戏结束
+    GAME_PASS
+}
+
 
 
 /** 数据层对象 */
@@ -164,6 +173,8 @@ export class GameModelComp extends ecs.Comp {
 
     _popupType: string = "";
 
+    _gameState: GameState = GameState.READY;
+
     /** 数据层组件移除时,重置所有数据为默认值 */
     reset() {
         this.id = -1;
@@ -174,6 +185,15 @@ export class GameModelComp extends ecs.Comp {
     }
 
 
+    set gameState(v: GameState) {
+        this._gameState = v;
+    }
+
+    get gameState() {
+        return this._gameState;
+    }
+
+
     set popupType(v: string) {
         this._popupType = v;
     }

+ 6 - 1
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-22 16:27:55
+ * @LastEditTime: 2025-04-23 10:49:01
  * @Description: 二倍速弹窗
  */
 import { _decorator } from "cc";
@@ -12,6 +12,7 @@ import { AD_TYPE } from "../common/config/GameDefine";
 import { UIID } from "../common/config/GameUIConfig";
 import { ADHandler } from "../common/manager/ADHandler";
 import { smc } from "../common/SingletonModuleComp";
+import { GameEvent } from "../common/config/GameEvent";
 
 const { ccclass, property } = _decorator;
 
@@ -40,12 +41,15 @@ export class DoubleSpeedViewComp extends VMParent {
     private openAd() {
         smc.game.GameModel.viewType = "speed_reward";
         ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
+        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
     }
 
 
     private btn_no() {
         oops.gui.remove(UIID.DoubleSpeed);
         ADHandler.inst.showAd("107");
+        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
+
     }
 
 
@@ -53,5 +57,6 @@ export class DoubleSpeedViewComp extends VMParent {
         oops.gui.remove(UIID.DoubleSpeed);
         //播放插屏广告
         ADHandler.inst.showAd("107");
+        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
     }
 }

+ 40 - 29
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-22 19:37:03
+ * @LastEditTime: 2025-04-23 11:13:27
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -236,6 +236,7 @@ export class EliminateViewComp extends CCComp {
         this.initData();
         this.setData();
         this.addEventList();
+        // smc.account.AccountModel.curLevel = 1;
         if (this.guideStep === 0 && smc.account.AccountModel.curLevel == 1) {
             this.startGuideMode()
         } else {
@@ -256,6 +257,19 @@ export class EliminateViewComp extends CCComp {
         // oops.message.on(GameEvent.Resurrection, this.onResurrection, this);
         oops.message.on(GameEvent.updateHbAndWxCoin, this.updateCoin, this);
         oops.message.on(GameEvent.StartAutoGame, this.startAutoGame, this);
+        oops.message.on(GameEvent.updateGameState, this.updateGameState, this);
+    }
+
+    updateGameState(event: string, args: string) {
+        console.log("更新游戏状态", args);
+        switch (args) {
+            case "paused":
+                this.gameState = GameState.PAUSED;
+                break;
+            case "playing":
+                this.gameState = GameState.PLAYING;
+                break;
+        }
     }
 
 
@@ -302,11 +316,16 @@ export class EliminateViewComp extends CCComp {
 
     //设置数据
     setData() {
-        // this.eliminateInterval = smc.game.GameModel.curLevelConfig.eliminateScope;
+        if (smc.game.GameModel.curLevelConfig.eliminateScope) {
+            this.eliminateInterval = smc.game.GameModel.curLevelConfig.eliminateScope || [];
+        }
+
+
         this.score = smc.game.GameModel.curScore;
         this.money = smc.account.AccountModel.wxCoin;
         this.cash = smc.account.AccountModel.hbCoin;
-        this.targetScore = smc.game.GameModel.targetScore;
+        // this.targetScore = smc.game.GameModel.targetScore;
+        this.targetScore = 200;
         this.popupType = smc.game.GameModel.popupType;
         this.lab_score.string = this.score.toString();
         this.lab_wxCoin.string = Format.formatWxCoin(this.money);
@@ -361,26 +380,11 @@ export class EliminateViewComp extends CCComp {
         }
     }
 
-    //复活,分数不清零
-    onResurrection() {
-        console.log("复活游戏,分数不清零");
-    }
-
-
 
     startGuideMode() {
         this.isGuideMode = true
         this.guideStep = 1
         this.guideNode.active = true;
-        this.setupGuideStep(this.guideStep)
-    }
-
-    setupGuideStep(step: number) {
-        this.gameState = GameState.PLAYING;
-        this.operateFlag = true
-        this.bricksList.length = 0
-        this.brickNode.destroyAllChildren();
-
         for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
             const currentRow: GridData[] = [];
             this.gridList.push(currentRow);
@@ -402,6 +406,14 @@ export class EliminateViewComp extends CCComp {
             this.rotateNode.destroyAllChildren();
         }
         this.touchStartPos.set(Vec2.ZERO)
+        this.setupGuideStep(this.guideStep)
+    }
+
+    setupGuideStep(step: number) {
+        this.gameState = GameState.PLAYING;
+        this.operateFlag = true
+        this.bricksList.length = 0
+        this.brickNode.destroyAllChildren();
         this.clearAllGuideGrids()
 
         this.guideStep = step
@@ -426,34 +438,33 @@ export class EliminateViewComp extends CCComp {
             this.createGuideBrick([{ row: 0, column: 0 }], "Brick1", 1, 1)
         }
         else if (step === 2) {
-            const emptyRow = this.rows - 1
             for (let r = 0; r < this.rows; r++) {
-                if (r !== emptyRow) {
-                    const g = this.gridList[r][0]
+                if (r !== 0) {
+                    const g = this.gridList[r][3]
                     g.status = 1
                     g.type = 1;
                     this.generateGrid(g)
                 }
             }
+
             this.createGuideBrick([{ row: 0, column: 0 }], "Brick1", 1, 1)
         }
         else if (step === 3) {
             // 填满前两列,除去 [2][0] 这个位置,制造一个L型缺口
             for (let r = 0; r < this.rows; r++) {
-                for (let c = 0; c < 2; c++) {
-                    if (r === 2 && c === 0) continue
-                    if (r === 1 && c === 0) continue
-                    if (r === 3 && c === 0) continue
-                    if (r === 2 && c === 1) continue
-                    if (r === 1 && c === 1) continue
-                    if (r === 3 && c === 1) continue
+                for (let c = 3; c < 5; c++) {
+                    if (r === 2 && c === 3) continue
+                    if (r === 1 && c === 3) continue
+                    if (r === 3 && c === 3) continue
+                    if (r === 2 && c === 4) continue
+                    if (r === 1 && c === 4) continue
+                    if (r === 3 && c === 4) continue
                     const g = this.gridList[r][c]
                     g.status = 1
                     g.type = 1;
                     this.generateGrid(g)
                 }
             }
-
             // 创建一个L型方块,引导玩家旋转后放置
             this.createGuideBrick([
                 { row: 0, column: 0 },

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

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 14:43:24
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-21 16:10:01
+ * @LastEditTime: 2025-04-23 10:54:37
  * @Description: 游戏通关弹窗
  */
 import { Label, Node } from 'cc';
@@ -86,8 +86,6 @@ export class GamePassView extends GameComponent {
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
             smc.game.GameModel.viewType = "pass_reward";
             ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
-            //打开等待
-            // oops.gui.waitOpen();
             oops.gui.remove(UIID.GamePass);
         } else {
             oops.gui.remove(UIID.GamePass);

+ 4 - 2
assets/script/game/view/WithdrawalRecordViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 10:17:49
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-22 16:58:49
+ * @LastEditTime: 2025-04-23 09:57:20
  * @Description: 提现记录
  */
 import { _decorator, Label, Node } from "cc";
@@ -91,7 +91,6 @@ export class WithdrawalRecordViewComp extends CCComp {
 
         const moneyLabel = item.getChildByPath("moneyNode/lab_money")?.getComponent(Label);
         if (moneyLabel) moneyLabel.string = Format.formatRedPacketCoin(data.amount);
-        //TS原生随机数0 或者1
         const statusNode1 = item.getChildByName("record_state1");
         if (statusNode1) statusNode1.active = data.status == 2;
         const statusNode2 = item.getChildByName("record_state2");
@@ -115,6 +114,9 @@ export class WithdrawalRecordViewComp extends CCComp {
         if (oops.gui.has(UIID.RedPacketWithdraw)) {
             oops.gui.remove(UIID.RedPacketWithdraw)
         }
+        if (oops.gui.has(UIID.WechatWithdraw)) {
+            oops.gui.remove(UIID.WechatWithdraw)
+        }
     }