Browse Source

完善游戏逻辑,单击可以旋转

mojunshou 1 year ago
parent
commit
991a2ff6f7

+ 2 - 2
assets/bundle/gui/eliminate/eliminate.prefab

@@ -9541,7 +9541,7 @@
     "__prefab": {
       "__id__": 388
     },
-    "_alignFlags": 20,
+    "_alignFlags": 44,
     "_target": null,
     "_left": 0,
     "_right": 0,
@@ -9555,7 +9555,7 @@
     "_isAbsBottom": true,
     "_isAbsHorizontalCenter": true,
     "_isAbsVerticalCenter": true,
-    "_originalWidth": 0,
+    "_originalWidth": 720,
     "_originalHeight": 0,
     "_alignMode": 2,
     "_lockFlags": 0,

+ 2 - 2
assets/bundle/gui/eliminate/prefab/doubleSpeed.prefab

@@ -1604,7 +1604,7 @@
     },
     "clickEvents": [],
     "_interactable": true,
-    "_transition": 2,
+    "_transition": 3,
     "_normalColor": {
       "__type__": "cc.Color",
       "r": 214,
@@ -2065,7 +2065,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1599.9999999999998
+      "height": 1600
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",

+ 11 - 11
assets/script/game/account/model/AccountModelComp.ts

@@ -4,7 +4,7 @@
  * @Author: dgflash
  * @Date: 2021-11-12 10:02:31
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-10 15:24:29
+ * @LastEditTime: 2025-04-11 18:08:50
  */
 import { oops } from "db://oops-framework/core/Oops";
 import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -28,10 +28,10 @@ export class AccountModelComp extends ecs.Comp {
     /**当前关卡--默认从0开始*/
     _curLevel: number = 0;
     /**游戏币*/
-    _gameCoin: number = 0;
+    _wxCoin: number = 0;
 
     /**红包币*/
-    _cashCoin: number = 0;
+    _hbCoin: number = 0;
     /**金块*/
     _goldCoin: number = 0;
     /**是否登录过*/
@@ -103,20 +103,20 @@ export class AccountModelComp extends ecs.Comp {
         this._curLevel = value;
     }
 
-    get gameCoin() {
-        return this._gameCoin;
+    get wxCoin() {
+        return this._wxCoin;
     }
 
-    set gameCoin(value: number) {
-        this._gameCoin = value;
+    set wxCoin(value: number) {
+        this._wxCoin = value;
     }
 
-    get cashCoin() {
-        return this._cashCoin;
+    get hbCoin() {
+        return this._hbCoin;
     }
 
-    set cashCoin(value: number) {
-        this._cashCoin = value;
+    set hbCoin(value: number) {
+        this._hbCoin = value;
     }
 
     get goldCoin() {

+ 3 - 2
assets/script/game/common/config/GameUIConfig.ts

@@ -46,7 +46,8 @@ export enum UIID {
     /**提现记录 */
     WithdrawRecord,
     /** 微信提现 */
-    WechatWithdraw
+    WechatWithdraw,
+    GameView
 }
 
 /** 打开界面方式的配置数据 */
@@ -71,6 +72,6 @@ export var UIConfigData: { [key: number]: UIConfig } = {
     [UIID.Verify]: { layer: LayerType.PopUp, prefab: "gui/eliminate/prefab/verify" },
     [UIID.WithdrawRecord]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/withdrawalRecord" },
     [UIID.WechatWithdraw]: { layer: LayerType.UI, prefab: "gui/eliminate/prefab/wechatWithdrawal" },
-
+    [UIID.GameView]: { layer: LayerType.UI, prefab: "gui/eliminate/gameView" }
 
 }

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

@@ -106,8 +106,7 @@ export class ADHandler {
         console.log("[广告] 激励视频关闭", state)
         smc.game.GameModel.isDone = state;
         if (state) {
-            //发送金币通知--通关sign向服务器请求
-            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+            ServerHandler.inst.getVideorReward();
         }
     };
 }

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

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-07 10:17:16
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-10 17:04:18
+ * @LastEditTime: 2025-04-11 17:38:34
  * @Description: 消息定义
  */
 
@@ -60,6 +60,8 @@ export enum ProtocolEvent {
     GetWithdrawReward = server_url + "/project/playlet/v1/withdraw/rebate",
     /**广告视频开始*/
     AdVideoStart = server_url + "/project/playlet/v1/video/start",
+    /**视频奖励*/
+    getVideorReward = server_url + "/project/playlet/v1/reward/videoReward"
 
 
 

+ 63 - 3
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-11 15:49:20
+ * @LastEditTime: 2025-04-11 19:06:30
  * @Description: 
  */
 // ServerHandler.ts
@@ -64,6 +64,7 @@ export class ServerHandler {
     }
 
     onAccountInfo(str: string) {
+        console.log('[服务器] 获取账号信息返回', str);
         const data = JSON.parse(str);
         const account = smc.account.AccountModel;
         const game = smc.game.GameModel;
@@ -120,8 +121,8 @@ export class ServerHandler {
         const props = result.data.props;
         const account = smc.account.AccountModel;
         const game = smc.game.GameModel;
-        account.gameCoin = props['1005'];
-        account.cashCoin = props['1004'];
+        account.wxCoin = props['1005'];
+        account.hbCoin = props['1004'];
         account.goldCoin = props['1006'];
         game.handlingCharge = props['1009'];
     }
@@ -209,6 +210,20 @@ export class ServerHandler {
 
     onEliminationSuccess(str: string) {
         console.log('[服务器] 消除成功返回', str);
+        let result = JSON.parse(str);
+        if (result?.props && result?.changes) {
+            console.log(">>>>>>>>>>>>>>发放奖励了")
+            const props = result.props;
+            const changes = result.changes;
+            const account = smc.account.AccountModel;
+            const game = smc.game.GameModel;
+            account.wxCoin = props['1005'];
+            account.hbCoin = props['1004'];
+            game.changeHbCoin = changes['1004'] / 100;
+            game.changeWxCoin = changes['1005'] / 1000;
+            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+            //还要知道是不是二倍速的
+        }
     }
 
     getSign(price: number) {
@@ -269,6 +284,51 @@ export class ServerHandler {
     }
 
 
+    //获取视频奖励
+    getVideorReward() {
+        const sign = smc.game.GameModel.sign;
+        const level = smc.account.AccountModel.curLevel;
+        let type = smc.game.GameModel.viewType;
+        const param = {
+            url: ProtocolEvent.getVideorReward,
+            param: {
+                level: level,
+                type: type,
+                transId: "",
+                sign: sign
+            },
+            callback: this.buildCallback('ServerHandler.inst.onGetVideorReward', 'ServerHandler.inst.onRequestFail')
+        }
+        this.sendMsgToServer(param);
+    }
+
+
+
+
+    onGetVideorReward(str: string) {
+        console.log('[服务器] 获取视频奖励放回', str);
+        let result = JSON.parse(str);
+        if (result.tipThreshold) {
+            oops.gui.toast("今日奖励已领取,请明天再来吧")
+            return
+        }
+        if (result?.props && !result.tipThreshold) {
+            console.log(">>>>>>>>>>>>>>发放奖励了")
+            const props = result.props;
+            const changes = result.changes;
+            const account = smc.account.AccountModel;
+            const game = smc.game.GameModel;
+            account.wxCoin = props['1005'];
+            account.hbCoin = props['1004'];
+            game.changeHbCoin = changes['1004'] / 100;
+            game.changeWxCoin = changes['1005'] / 1000;
+            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+            //还要知道是不是二倍速的
+        }
+        //保存需要下发的数值
+    }
+
+
 
     onRequestFail(code: number, str: string) {
         console.log('[服务器] 请求失败', code, str);

+ 3 - 1
assets/script/game/initialize/view/LoadingViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-19 16:23:51
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-11 11:24:58
+ * @LastEditTime: 2025-04-14 11:50:19
  * @Description: loading界面
  */
 import { _decorator, Toggle } from "cc";
@@ -21,6 +21,7 @@ import { EliminateViewComp } from "../../view/EliminateViewComp";
 import { ServerHandler } from "../../common/manager/ServerHandler";
 import { ADHandler } from "../../common/manager/ADHandler";
 import { LoginHandler } from "../../common/manager/LoginHandler";
+import { GameView } from "../../view/core/GameView";
 const { ccclass, property } = _decorator;
 
 /** 游戏资源加载 */
@@ -153,6 +154,7 @@ export class LoadingViewComp extends CCVMParentComp {
         // 获取用户信息的多语言提示文本
         this.data.prompt = oops.language.getLangByID("loading_load_player");
         await ModuleUtil.addViewUiAsync(smc.account, EliminateViewComp, UIID.Eliminate);
+        // await oops.gui.open(UIID.GameView);
         ModuleUtil.removeViewUi(this.ent, LoadingViewComp, UIID.Loading);
     }
 

+ 29 - 8
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-11 15:40:36
+ * @LastEditTime: 2025-04-11 18:13:43
  * @Description: 
  */
 import { ecs } from "db://oops-framework/libs/ecs/ECS";
@@ -80,11 +80,12 @@ export class GameModelComp extends ecs.Comp {
     _passViewInfo: PassViewInfo = null!;
     /**视频签名*/
     _sign: string = "";
-
-    /**双倍奖励页面信息*/
-
-
+    //改变的红包币数
+    _changeHbCoin: number = 0;
+    //微信币数
+    _changeWxCoin: number = 0;
     /**页面类型*/
+    _viewType: string = "";   //1翻倍 2通关 3加速 4复活  
 
     /**提现必反*/
     _cashNum: number = 0;
@@ -98,7 +99,30 @@ export class GameModelComp extends ecs.Comp {
         this.costInfo = null!;
     }
 
+    /**改变的红包币*/
+    set changeHbCoin(value: number) {
+        this._changeHbCoin = value;
+    }
+
+    get changeHbCoin() {
+        return this._changeHbCoin;
+    }
+
+    set changeWxCoin(v: number) {
+        this._changeWxCoin = v;
+    }
+
+    get changeWxCoin() {
+        return this._changeWxCoin;
+    }
+
+    set viewType(value: string) {
+        this._viewType = value;
+    }
 
+    get viewType() {
+        return this._viewType;
+    }
 
     set price(value: number) {
         this._price = value;
@@ -108,7 +132,6 @@ export class GameModelComp extends ecs.Comp {
         return this._price;
     }
 
-
     set isDone(value: boolean) {
         this._isDone = value;
     }
@@ -142,8 +165,6 @@ export class GameModelComp extends ecs.Comp {
         return this._curScore;
     }
 
-
-
     get targetScore() {
         return this._targetScore;
     }

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

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 11:45:43
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-11 16:02:51
+ * @LastEditTime: 2025-04-11 17:51:54
  * @Description: 提现必返
  */
 import { _decorator, Label } from 'cc';
@@ -35,8 +35,8 @@ export class CashRebateView extends GameComponent {
     private btn_ok() {
         //看广告
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-            ADHandler.inst.showAd("105");
             oops.gui.remove(UIID.CashRebate);
+            ADHandler.inst.showAd("105");
             oops.message.dispatchEvent(GameEvent.showCoinAnimation);
 
         } else {

+ 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-11 15:23:44
+ * @LastEditTime: 2025-04-11 17:47:06
  * @Description: 惊喜翻倍弹窗
  */
 import { Label, Node } from 'cc';
@@ -14,6 +14,7 @@ import { UIID } from '../common/config/GameUIConfig';
 import { ADHandler } from '../common/manager/ADHandler';
 import { AD_TYPE } from '../common/config/GameDefine';
 import { ProgressBar } from 'cc';
+import { smc } from '../common/SingletonModuleComp';
 
 const { ccclass, property } = _decorator;
 
@@ -58,6 +59,7 @@ export class DoubleRewardsView extends GameComponent {
 
 
     btn_all() {
+        smc.game.GameModel.viewType = "double_reward";
         ADHandler.inst.showAd(AD_TYPE.Double_Receive);
         oops.gui.remove(UIID.DoubleRewards);
     }

+ 9 - 3
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-11 11:25:47
+ * @LastEditTime: 2025-04-11 17:48:38
  * @Description: 二倍速弹窗
  */
 import { _decorator, Label, RichText } from "cc";
@@ -12,6 +12,8 @@ import { CCComp } from "db://oops-framework/module/common/CCComp";
 import { UIID } from "../common/config/GameUIConfig";
 import { CocosHandler } from "../common/manager/CocosHandler";
 import { ADHandler } from "../common/manager/ADHandler";
+import { smc } from "../common/SingletonModuleComp";
+import { AD_TYPE } from "../common/config/GameDefine";
 
 const { ccclass, property } = _decorator;
 
@@ -67,13 +69,17 @@ export class DoubleSpeedViewComp extends CCComp {
 
     //打开广告
     private openAd() {
+        smc.game.GameModel.viewType = "speed_reward";
+        ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
+    }
 
 
-
+    private btn_no() {
+        oops.gui.remove(UIID.DoubleSpeed);
+        ADHandler.inst.showAd("107");
     }
 
 
-
     private btn_close() {
         oops.gui.remove(UIID.DoubleSpeed);
         //播放插屏广告

+ 119 - 150
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-11 15:59:26
+ * @LastEditTime: 2025-04-14 15:26:29
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -24,7 +24,8 @@ enum GameState {
     READY,      // 准备中
     PLAYING,    // 游戏中
     PAUSED,     // 暂停 --看广告用
-    GAME_OVER   // 游戏结束 
+    GAME_OVER,  // 游戏结束
+    GAME_PASS
 }
 
 
@@ -67,6 +68,7 @@ interface BrickData {
     brickNode: Node | null,
     brickInitPos: Vec3, // 方块初始位置
     type: number,   // 方块类型--gridColorKey
+    rotateNode: Node | null,
 }
 
 interface GridConfigData {
@@ -96,8 +98,6 @@ export class EliminateViewComp extends CCComp {
     private lab_score: Label = null!;
     @property({ type: Label, displayName: "目标分数" })
     private lab_taget: Label = null!;
-    @property({ type: Label, displayName: "第几块金砖" })
-    private lab_brick: Label = null!;
 
     @property({ type: Prefab, displayName: "item预制体列表" })
     private itemPrefabs: Prefab[] = [];
@@ -117,28 +117,29 @@ export class EliminateViewComp extends CCComp {
     @property({ type: Label, displayName: "每次放置添加的分数" })
     private lab_addScore: Label = null!;
 
-
     @property({ type: Button, displayName: "自动按钮" })
     private autoBtn: Button = null!;
-    @property({ type: Button, displayName: "二倍速按钮" })
-    private addSpeedBtn: Button = null!;
 
     //游戏配置行列
     private rows: number = 8;       // 行数
     private cols: number = 8;       // 列数
     private itemSize: number = 76.25;  // 格子大小
     private brickNum: number = 3;   // 砖块数量
+    private yOffset = 0
+    private aniBrickMove = 0
+    private aniBrickRotate = 0
+    private aniBrickEliminate = 0
+
+    private operateFlag: boolean = false
+    private touchStartPos = new Vec2()
 
     private gameState: GameState = GameState.READY;
     private score: number = 0;      //本局分数
     private money: number = 0;      //左边金钱
     private cash: number = 0;       //右边红包钱数
-    private goldNum: number = 0;     //金块数量
 
     private targetScore: number = 0; //目标分数
 
-    private totalNum: number = 0;   //累计消除次数,断了就是又从0开始
-
     private _isDoubleSpeed: boolean = false;  //是否开启二倍速
     private _doubleNum: number = 2;           //除2就是开启了2倍速,除1就是关闭了2倍速
 
@@ -165,24 +166,23 @@ export class EliminateViewComp extends CCComp {
     gridColorList: GridData[] = [];
 
     brickConfig: { bricks?: any } = {}  //方块配置
-    editingFlag = false                 //编辑状态
     editingData: EditingData = {
         brickData: null,
         gridList: [],
     }
 
     //旋转标记
-    rotateFlag = false
-    rotateBrickData: BrickData | null = null
+    // private rotateFlag = false
+    // private rotateBrickData: BrickData | null = null
 
     // 添加新的属性来跟踪是否需要重置消除计数
     private shouldResetEliminateCount: boolean = true;
 
     private autoState: boolean = false;  //自动状态
 
-    private eliminateBaseScore: number = 10;
-    private extraGridScore: number = 1;
-    private placementBaseScore: number = 1;
+    private eliminateBaseScore: number = 10;  //每行得多少分
+    private extraGridScore: number = 1;       //每个格子占用几分
+    private placementBaseScore: number = 1;   //每个格子占用几分
 
     private totalEliminationCount: number = 0;   // 总消除次数(包括行和列)
     private currentCombo: number = 0;            // 当前连击次数
@@ -238,8 +238,8 @@ export class EliminateViewComp extends CCComp {
         this.targetScore = 0;
         this.money = 0;
         this.cash = 0;
-        this.totalNum = 0;
         this.autoState = false;
+        this.operateFlag = true
         this.shouldResetEliminateCount = true;
         this.totalEliminationCount = 0;
         this.currentCombo = 0;
@@ -253,8 +253,8 @@ export class EliminateViewComp extends CCComp {
     //设置数据
     setData() {
         this.score = smc.game.GameModel.curScore || 0;
-        this.money = smc.account.AccountModel.gameCoin;
-        this.cash = smc.account.AccountModel.cashCoin;
+        this.money = smc.account.AccountModel.wxCoin;
+        this.cash = smc.account.AccountModel.hbCoin;
         this.targetScore = smc.game.GameModel.targetScore || 0;
         this.lab_score.string = this.score.toString();
         this.amountLb.string = this.money.toString();
@@ -367,9 +367,7 @@ export class EliminateViewComp extends CCComp {
         }
         // 初始化方块
         if (this.brickNode) {
-            if (this.brickNode) {
-                this.brickNode.children.forEach(node => { node.destroy() });
-            }
+            this.brickNode.destroyAllChildren();
         }
         this.bricksList.length = 0
         for (let i = 1; i <= this.brickNum; i++) {
@@ -377,8 +375,10 @@ export class EliminateViewComp extends CCComp {
         }
         // 清除旋转数据
         if (this.rotateNode) {
-            this.rotateNode.children.forEach(node => { node.destroy() })
+            this.rotateNode.destroyAllChildren();
         }
+        this.operateFlag = false
+        this.touchStartPos.set(Vec2.ZERO)
     }
 
     /**
@@ -511,6 +511,7 @@ export class EliminateViewComp extends CCComp {
             brickNode: null,
             brickInitPos: new Vec3(),
             type: randomIndex,
+            rotateNode: null,
         }
         this.bricksList.push(brickData)
         // 生成方块
@@ -535,8 +536,12 @@ export class EliminateViewComp extends CCComp {
             brickData.brickNode.scale_y = 0.6;
             brickData.brickInitPos = brickData.brickNode.getWorldPosition()
         }
+        if (brickData.rotateFlag) {
+            brickData.rotateNode = instantiate(this.rotatePrefab)
+            this.rotateNode.addChild(brickData.rotateNode)
+            brickData.rotateNode.setWorldPosition(brickNode.getWorldPosition())
+        }
         this.brickAddEvent(brickData);
-        //2508801946299286
     }
 
 
@@ -619,16 +624,6 @@ export class EliminateViewComp extends CCComp {
             console.error("brickNode为空,无法添加事件");
             return
         }
-
-        // 确保节点可交互
-        brickNode.active = true;
-
-        // 移除可能存在的旧事件监听器
-        brickNode.off(Node.EventType.TOUCH_START);
-        brickNode.off(Node.EventType.TOUCH_MOVE);
-        brickNode.off(Node.EventType.TOUCH_END);
-        brickNode.off(Node.EventType.TOUCH_CANCEL);
-
         // 记录初始位置和状态
         let startPos = new Vec3();
         let originalParent: Node | null = null;
@@ -637,28 +632,25 @@ export class EliminateViewComp extends CCComp {
         // 触摸开始事件
         brickNode.on(Node.EventType.TOUCH_START, (event: EventTouch) => {
             // 如果正在编辑其他方块,则忽略
-            if (this.editingFlag) return;
+            if (!this.operateFlag) return;
 
-            // 设置编辑状态
-            this.editingFlag = true;
             isDragging = true;
-            this.touchStartFlag = true;
 
             // 清空编辑中的数据
             this.editingData.brickData = null;
             this.editingData.gridList.length = 0;
 
             // 记录触摸开始位置和方块原始信息
-            this.touchStartLocation.set(event.getUILocation());
+            this.touchStartPos.set(event.getUILocation());
             originalParent = brickNode.parent;
             startPos = brickNode.getWorldPosition().clone();
 
             // 将方块移到移动层并放大
             brickNode.setParent(this.moveNode);
             brickNode.setWorldPosition(startPos);
-            tween(brickNode)
-                .to(0.2, { scale: new Vec3(1, 1, 1) })
-                .start();
+            // tween(brickNode)
+            //     .to(0.2, { scale: new Vec3(1, 1, 1) })
+            //     .start();
 
             // 从方块列表中移除该方块
             const index = this.bricksList.findIndex(item => item === brickData);
@@ -666,40 +658,35 @@ export class EliminateViewComp extends CCComp {
                 this.editingData.brickData = this.bricksList.splice(index, 1)[0];
             } else {
                 console.error("未找到方块数据:", brickData);
-                this.editingData.brickData = brickData;
-            }
-
-            // 清除旋转数据
-            if (this.rotateFlag && this.rotateBrickData !== this.editingData.brickData) {
-                this.rotateFlag = false;
-                this.rotateBrickData = null;
-                if (this.rotateNode) {
-                    this.rotateNode.children.forEach(node => { node.destroy() });
-                }
             }
         }, this);
 
         // 触摸移动事件
         brickNode.on(Node.EventType.TOUCH_MOVE, (event: EventTouch) => {
-            if (!isDragging || !this.editingData.brickData) return;
-
-            // 清除旋转数据
-            if (event.getUILocation().subtract(this.touchStartLocation).length() >= this.rotateFaultTolerant) {
-                this.rotateFlag = false;
-                this.rotateBrickData = null;
-                if (this.rotateNode) {
-                    this.rotateNode.children.forEach(node => { node.destroy() });
+            if (!isDragging || !this.operateFlag) return;
+
+            const movePos: Vec2 = event.getUILocation().subtract(this.touchStartPos)
+            // 挪动很小时,不移动方块组合
+            if (movePos.length() <= this.rotateFaultTolerant) {
+                return
+            }
+            // 隐藏旋转节点
+            if (this.editingData.brickData && this.editingData.brickData.rotateFlag) {
+                if (this.editingData.brickData.rotateNode) {
+                    this.editingData.brickData.rotateNode.active = false
                 }
             }
 
             // 恢复所有网格颜色
             this.gridColorRecovery();
-
             // 移动方块
-            brickNode.setWorldPosition(brickNode.getWorldPosition().add(event.getUIDelta().toVec3()));
-
+            brickNode.setWorldPosition(event.getUILocation().toVec3().add3f(0, this.yOffset, 0))
+            brickNode.scale_x = 1;
+            brickNode.scale_y = 1;
             // 重置编辑中的网格数据
             this.editingData.gridList.length = 0;
+            //
+
 
             // 检查方块每个子网格是否与游戏网格重叠
             const tempGridList: GridData[] = [];
@@ -738,7 +725,6 @@ export class EliminateViewComp extends CCComp {
             if (canPlace) {
                 this.editingData.gridList = [...tempGridList];
             }
-
             // 更新网格颜色提示 - 只改变空网格的颜色
             tempGridList.forEach(grid => {
                 // 只处理空网格
@@ -761,17 +747,29 @@ export class EliminateViewComp extends CCComp {
             isDragging = false;
             this.touchStartFlag = false;
 
-            // 恢复网格颜色
-            this.gridColorRecovery();
-
-            // 防止如放回方块回弹动画时,已经触摸在另一个方块上面
-            if (this.editingData.brickData !== brickData) return;
-
-            // 检查是否可以放置
-            if (this.editingData.brickData && this.editingData.gridList.length > 0) {
+            // 单击旋转
+            if (!this.editingData.brickData) {
+                console.log("没有数据")
+                return
+            }
+            if (
+                this.editingData.brickData.rotateFlag &&
+                event.getUILocation().subtract(this.touchStartPos).length() <= this.rotateFaultTolerant
+            ) {
+                const brickData = this.editingData.brickData
+                // 方块放回待选区
+                if (brickData && brickData.brickNode) {
+                    this.bricksList.push(brickData)
+                    this.brickNode.addChild(brickData.brickNode)
+                    brickData.brickNode.setWorldPosition(brickData.brickInitPos)
+                    // 旋转
+                    this.brickGridRotate(brickData).then(() => {
+                        this.operateFlag = true
+                    })
+                }
+            } else if (this.editingData.brickData && this.editingData.gridList.length > 0) {
                 // 计算放置的格子数量
                 const placedGridCount = this.editingData.gridList.length;
-
                 // 获取中心位置用于显示分数
                 let centerPos = new Vec3(0, 0, 0);
                 if (this.editingData.gridList.length > 0 && this.editingData.gridList[0].gridNode) {
@@ -806,6 +804,7 @@ export class EliminateViewComp extends CCComp {
                 // 销毁方块节点
                 brickNode.destroy();
 
+
                 // 添加新方块到待选区
                 this.addBrick(this.editingData.brickData.index);
 
@@ -822,26 +821,9 @@ export class EliminateViewComp extends CCComp {
                             if (!canContinue) {
                                 this.gameOver();
                             }
-                            this.editingFlag = false;
                         });
                     });
                 }, 0.1);
-            } else if (this.rotateFlag) {
-                // 旋转方块
-                const brickData = this.editingData.brickData;
-                this.brickGridRotate(brickData);
-                // 方块放回待选区
-                this.bricksList.push(brickData);
-                if (this.brickNode && brickData.brickNode) {
-                    this.brickNode.addChild(brickData.brickNode);
-                    tween(brickData.brickNode)
-                        .to(0.2, {
-                            worldPosition: brickData.brickInitPos,
-                            scale: new Vec3(0.6, 0.6, 0.6)
-                        })
-                        .start();
-                }
-                this.editingFlag = false;
             } else {
                 // 无法放置,将方块返回原位置
                 const brickData = this.editingData.brickData;
@@ -859,31 +841,13 @@ export class EliminateViewComp extends CCComp {
                                 brickNode.setParent(originalParent);
                                 brickNode.setWorldPosition(brickData.brickInitPos);
                             }
-                            this.editingFlag = false;
                         })
                         .start();
-                } else {
-                    this.editingFlag = false;
-                }
-            }
-
-            // 检查是否需要处理旋转(短距离移动视为点击)
-            if (!this.rotateFlag &&
-                this.editingData.brickData &&
-                this.editingData.brickData.rotateFlag &&
-                event.getUILocation().subtract(this.touchStartLocation).length() < this.rotateFaultTolerant) {
-                this.rotateFlag = true;
-                this.rotateBrickData = this.editingData.brickData;
-
-                // 显示旋转提示
-                if (this.rotatePrefab && this.rotateNode && brickNode) {
-                    const rotateIndicator = instantiate(this.rotatePrefab);
-                    this.rotateNode.addChild(rotateIndicator);
-                    rotateIndicator.setWorldPosition(brickNode.getWorldPosition());
                 }
             }
+            // 格子颜色恢复
+            this.gridColorRecovery()
         };
-
         brickNode.on(Node.EventType.TOUCH_END, touchEndHandler, this);
         brickNode.on(Node.EventType.TOUCH_CANCEL, touchEndHandler, this);
     }
@@ -903,13 +867,16 @@ export class EliminateViewComp extends CCComp {
     }
 
     brickGridRotate(brickData: BrickData) {
-        const next = this.nextGridRotate(brickData.gridConfig, brickData.deg)
-        brickData.deg = next.deg
-        brickData.gridConfig = next.gridConfig;
-        if (brickData.brickNode) {
-            tween(brickData.brickNode).to(0.1, { angle: next.deg }).start();
-        }
-        // this.audioManager.playRotate()
+        return new Promise((resolve, reject) => {
+            const next = this.nextGridRotate(brickData.gridConfig, brickData.deg)
+            brickData.deg = next.deg
+            brickData.gridConfig = next.gridConfig
+            if (brickData.brickNode) {
+                tween(brickData.brickNode).to(this.aniBrickRotate, { angle: next.deg }).call(() => {
+                    resolve(true)
+                }).start()
+            }
+        })
     }
 
     //下一个旋转
@@ -1108,7 +1075,15 @@ export class EliminateViewComp extends CCComp {
 
                 this.score += score;
                 this.lab_score.string = this.score.toString();
+                if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
+                    ServerHandler.inst.updateEliminationReward({
+                        count: 1,
+                        score: this.score,
+                        level: 1
+                    })
+                }
 
+                //要服务器请求完了出了数据才展示动画
                 const lastGrid = gridEliminateList[gridEliminateList.length - 1];
                 if (lastGrid?.gridNode && this.coinPrefab && this.amountLb?.node) {
                     const lastPos = lastGrid.gridNode.getWorldPosition();
@@ -1137,15 +1112,6 @@ export class EliminateViewComp extends CCComp {
                         }
                     );
                 }
-
-                if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-                    ServerHandler.inst.updateEliminationReward({
-                        count: 1,
-                        score: this.score,
-                        level: 1
-                    })
-                }
-
                 // 告诉调用者有消除发生
                 resolve(true)
                 // 检查是否需要继续消除
@@ -1200,7 +1166,7 @@ export class EliminateViewComp extends CCComp {
         if (!prefab) return;
 
         let completedCount = 0;
-        const totalCoins = Math.min(count, 10); // 限制最大数量
+        const totalCoins = Math.min(count, 6); // 限制最大数量
 
         for (let i = 0; i < totalCoins; i++) {
             const coin = instantiate(prefab);
@@ -1241,10 +1207,10 @@ export class EliminateViewComp extends CCComp {
     // 显示微信分数增加动画
     private showWechatScoreAnimation() {
         if (!this.tweenWechatNode) return;
-
         // 生成随机小数(小于1,保留2位小数)
-        const randomValue = Math.random() * 0.99;
-        const formattedValue = randomValue.toFixed(2);
+        const changeNum = smc.game.GameModel.changeWxCoin;
+        if (!changeNum) return;
+        const formattedValue = changeNum;
 
         // 获取并设置分数标签
         const scoreLabel = this.tweenWechatNode.getChildByName("lab_num")?.getComponent(Label);
@@ -1271,15 +1237,21 @@ export class EliminateViewComp extends CCComp {
             .to(0.2, { opacity: 0 })
             .call(() => {
                 // 重置位置
-                this.tweenWechatNode.setPosition(originalPosition);
+                this.tweenWechatNode.setPosition(new Vec3(
+                    originalPosition.x,
+                    originalPosition.y - 50,
+                    originalPosition.z
+                ));
                 this.tweenWechatNode.active = false;
 
                 // 更新总金额
                 if (this.amountLb) {
-                    const currentAmount = parseFloat(this.amountLb.string);
-                    const newAmount = currentAmount + parseFloat(formattedValue);
+                    const currentAmount = this.money;
+                    const newAmount = currentAmount + formattedValue;
                     this.money = newAmount;
-                    this.amountLb.string = newAmount.toFixed(2);
+                    this.amountLb.changeTo(0.5, newAmount, () => {
+                    })
+
                 }
             })
             .start();
@@ -1290,8 +1262,9 @@ export class EliminateViewComp extends CCComp {
         if (!this.tweenRedNode) return;
         //如果有值就是要那个,没有就是取随机
 
-        const randomValue = Math.random() * 0.99;
-        const formattedValue = randomValue.toFixed(2);
+        const changeNum = smc.game.GameModel.changeHbCoin;
+        if (!changeNum) return;
+        const formattedValue = changeNum;
 
         // 获取并设置分数标签
         const scoreLabel = this.tweenRedNode.getChildByName("lab_num")?.getComponent(Label);
@@ -1319,15 +1292,20 @@ export class EliminateViewComp extends CCComp {
             .to(0.2 / num, { opacity: 0 })
             .call(() => {
                 // 重置位置
-                this.tweenRedNode.setPosition(originalPosition);
+                this.tweenRedNode.setPosition(new Vec3(
+                    originalPosition.x,
+                    originalPosition.y - 50,
+                    originalPosition.z
+                ));
                 this.tweenRedNode.active = false;
 
                 // 更新总红包金额
                 if (this.awardLb) {
-                    const currentAmount = parseFloat(this.awardLb.string);
-                    const newAmount = currentAmount + parseFloat(formattedValue);
+                    const currentAmount = this.cash;
+                    const newAmount = currentAmount + formattedValue;
                     this.cash = newAmount;
-                    this.awardLb.string = newAmount.toFixed(2);
+                    this.awardLb.changeTo(0.5, newAmount, () => {
+                    })
                 }
             })
             .start();
@@ -1506,12 +1484,10 @@ export class EliminateViewComp extends CCComp {
     updateGameScore() {
         if (this.score >= this.targetScore) {
             //修改游戏状态
-            this.gameState = GameState.GAME_OVER;
+            this.gameState = GameState.GAME_PASS;
             //弹出恭喜通关
 
         }
-
-
     }
 
 
@@ -1781,7 +1757,6 @@ export class EliminateViewComp extends CCComp {
                                     this.executeAutoPlace()
                                 }, 0.3)
                             }
-                            this.editingFlag = false
                         })
                     })
                 })
@@ -1791,12 +1766,6 @@ export class EliminateViewComp extends CCComp {
 
 
 
-
-
-
-
-
-
     doubleSpeedOpenSuccess() {
         this._isDoubleSpeed = true;
         //3分钟后关闭

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

@@ -10,6 +10,9 @@ import { oops } from 'db://oops-framework/core/Oops';
 import { GameComponent } from "db://oops-framework/module/common/GameComponent";
 import { UIID } from '../common/config/GameUIConfig';
 import { GameEvent } from '../common/config/GameEvent';
+import { smc } from '../common/SingletonModuleComp';
+import { ADHandler } from '../common/manager/ADHandler';
+import { AD_TYPE } from '../common/config/GameDefine';
 
 const { ccclass, property } = _decorator;
 
@@ -29,7 +32,8 @@ export class GameOverView extends GameComponent {
     private btn_resurrection() {
         //打开广告
         //我这调你登录,你登录后,返回给我,可以登录,我这边加载资源,userinfo-头像,UID nickname,关卡,还有配置,
-
+        //复活
+        smc.game.GameModel.viewType = "revive_reward";
 
     }
 }

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

@@ -85,6 +85,7 @@ export class GamePassView extends GameComponent {
     private btn_more() {
         this.isAuto = false;
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
+            smc.game.GameModel.viewType = "double_reward";
             ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
         } else {
             oops.gui.remove(UIID.GamePass);