Przeglądaj źródła

完善提现返利,翻倍惊喜,通关奖励接口逻辑

mojunshou 7 miesięcy temu
rodzic
commit
050a0d6888

+ 7 - 4
assets/bundle/gui/eliminate/prefab/cashRebate.prefab

@@ -709,7 +709,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 200.21484375,
+      "width": 0,
       "height": 90.72
     },
     "_anchorPoint": {
@@ -745,7 +745,7 @@
       "b": 9,
       "a": 255
     },
-    "_string": "15210",
+    "_string": "",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
     "_actualFontSize": 72,
@@ -827,7 +827,7 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 102.607421875,
+      "x": 2.5,
       "y": 0,
       "z": 0
     },
@@ -977,7 +977,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 233.21484375,
+      "width": 33,
       "height": 72
     },
     "_anchorPoint": {
@@ -1939,6 +1939,9 @@
     "__prefab": {
       "__id__": 83
     },
+    "lab_num": {
+      "__id__": 31
+    },
     "_id": ""
   },
   {

Plik diff jest za duży
+ 2063 - 544
assets/bundle/gui/eliminate/prefab/doubleRewards.prefab


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

@@ -25,4 +25,6 @@ export enum GameEvent {
     openView = "openView",
     /**打开提现记录*/
     openRecordView = "openRecordView",
+    /**展示金币动画*/
+    showCoinAnimation = "showCoinAnimation",
 }

+ 24 - 12
assets/script/game/common/manager/ADHandler.ts

@@ -6,6 +6,7 @@ import { UIID } from '../config/GameUIConfig';
 import { smc } from '../SingletonModuleComp';
 import { ServerHandler } from './ServerHandler';
 import { LoginHandler } from './LoginHandler';
+import { GameEvent } from '../config/GameEvent';
 
 export class ADHandler {
     private static _inst: ADHandler;
@@ -18,6 +19,7 @@ export class ADHandler {
     }
 
     showAd = async (id: string) => {
+        smc.game.GameModel.isShowAd = true;
         const { method, param } = this.buildAdParam(id);
         const data: CocosHandlerType = {
             method,
@@ -50,19 +52,21 @@ export class ADHandler {
             case AD_TYPE.Rebates:
             case AD_TYPE.Double_Speed_Close:
                 method = 'ad.interstitial';
-                param.callback.onShowFailed = 'ADHandler.inst.adInterstitialShowFailed';
+                param.callback.onLoadFailed = 'ADHandler.inst.adInterstitialLoadFailed';
                 param.callback.onClose = 'ADHandler.inst.adInterstitialClose';
                 break;
             default:
                 method = 'ad.reward';
                 param.callback.onShow = 'ADHandler.inst.adRewardShow';
                 param.callback.onClose = 'ADHandler.inst.adRewardClose';
-                param.callback.onShowFailed = 'ADHandler.inst.adRewardShowFailed';
+                param.callback.onLoadFailed = 'ADHandler.inst.adRewardLoadFailed';
         }
         return { method, param };
     }
 
+    //启屏广告关闭
     adSplashClose = async () => {
+        smc.game.GameModel.isShowAd = false;
         if (oops.gui.has(UIID.KindTips)) oops.gui.remove(UIID.KindTips);
         if (oops.gui.has(UIID.Retention)) oops.gui.remove(UIID.Retention);
 
@@ -73,21 +77,18 @@ export class ADHandler {
     };
 
     adSplashLoadFailed = () => {
+        smc.game.GameModel.isShowAd = false;
         console.log('[广告] 启屏广告加载失败');
         ServerHandler.inst.getAccountInfo();
     };
 
-    adInterstitialClose = (type: boolean) => {
-        console.log('[广告] 插屏广告关闭', type);
-    };
-
-    adInterstitialShowFailed = () => {
-        console.log('[广告] 插屏广告显示失败');
+    adInterstitialLoadFailed = () => {
+        console.log('[广告] 插屏广告加载失败');
     };
 
-    adRewardClose = (state: boolean) => {
-        console.log("[广告] 激励视频关闭")
-        smc.game.GameModel.isDone = state;
+    adInterstitialClose = (type: boolean) => {
+        smc.game.GameModel.isShowAd = false;
+        console.log('[广告] 插屏广告关闭', type);
     };
 
     adRewardShow = (str: string) => {
@@ -95,8 +96,19 @@ export class ADHandler {
         ServerHandler.inst.getSign(data.price);
     };
 
-    adRewardShowFailed = (str: string) => {
+    adRewardLoadFailed = (str: string) => {
+        smc.game.GameModel.isShowAd = false;
         console.log('[广告] 激励视频展示失败', str);
     };
+
+    adRewardClose = (state: boolean) => {
+        smc.game.GameModel.isShowAd = false;
+        console.log("[广告] 激励视频关闭", state)
+        smc.game.GameModel.isDone = state;
+        if (state) {
+            //发送金币通知--通关sign向服务器请求
+            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+        }
+    };
 }
 window["ADHandler"] = ADHandler;

+ 3 - 11
assets/script/game/common/manager/LoginHandler.ts

@@ -3,6 +3,7 @@ import { oops } from 'db://oops-framework/core/Oops';
 import { smc } from '../SingletonModuleComp';
 import { ServerHandler } from './ServerHandler';
 import { CocosHandler } from './CocosHandler';
+import { ProtocolEvent } from './ProtocolEvent';
 
 export class LoginHandler {
     private static _inst: LoginHandler;
@@ -55,7 +56,8 @@ export class LoginHandler {
 
     wechatLoginSuccess(str: string) {
         console.log('[微信] 登录成功', str);
-        this.wxLogin(str);
+        // this.wxLogin(str);
+        //向服务器申请登录
     }
 
     wechatLoginFail(str: string) {
@@ -63,16 +65,6 @@ export class LoginHandler {
         oops.gui.toast('微信登录失败');
     }
 
-    async wxLogin(code: string) {
-        const param = {
-            method: 'request.post',
-            param: JSON.stringify({ code, url: '/api/wxlogin' }) // 修改为实际接口
-        };
-        const result = await CocosHandler.inst.sendMessageToAndroid(param, '请求服务器微信登录');
-        if (result?.data) {
-            ServerHandler.inst.getAccountInfo();
-        }
-    }
 }
 
 window["LoginHandler"] = LoginHandler;

+ 74 - 4
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 11:34:08
+ * @LastEditTime: 2025-04-11 15:49:20
  * @Description: 
  */
 // ServerHandler.ts
@@ -37,6 +37,24 @@ export class ServerHandler {
         return await CocosHandler.inst.sendMessageToAndroid(data, '服务器请求');
     }
 
+    //微信登录
+    wxLogin(code: string) {
+        const param = {
+            url: ProtocolEvent.WechatLogin,
+            param: {
+                code: code
+            },
+            callback: this.buildCallback('ServerHandler.inst.onWxLoginInfo', 'ServerHandler.inst.onRequestFail')
+        };
+        this.sendMsgToServer(param);
+    }
+
+    onWxLoginInfo(str: string) {
+        console.log('[服务器] 微信登录返回', str);
+
+    }
+
+
     getAccountInfo() {
         const param = {
             url: ProtocolEvent.AccountInfo,
@@ -49,18 +67,15 @@ export class ServerHandler {
         const data = JSON.parse(str);
         const account = smc.account.AccountModel;
         const game = smc.game.GameModel;
-
         account.uid = data.uid;
         account.accountName = data.nickname;
         account.headUrl = data.headImgUrl;
         account.isLogined = data.isBand;
         account.curLevel = data.currentLevelInfo.level;
-
         game.curScore = data.currentLevelInfo.score;
         game.targetScore = data.currentLevelConf.score;
         game.curLevelConfig = data.currentLevelConf;
         game.costInfo = data.handlingChargeConf;
-
         oops.message.dispatchEvent(GameEvent.UserLogin);
     }
 
@@ -77,6 +92,7 @@ export class ServerHandler {
         console.log('[服务器] 每日奖励返回', str);
     }
 
+    //红包币-获取记录
     getDailyTaskReward() {
         this.getUserItemInfo();
         const param = {
@@ -110,6 +126,7 @@ export class ServerHandler {
         game.handlingCharge = props['1009'];
     }
 
+    //获取提现记录
     getRecordList() {
         const param = {
             url: ProtocolEvent.GetWithdrawRecord,
@@ -122,6 +139,7 @@ export class ServerHandler {
         this.sendMsgToServer(param);
     }
 
+    //提现列表
     onRecordList(str: string) {
         const result = JSON.parse(str);
         if (result.count > 0) {
@@ -152,10 +170,15 @@ export class ServerHandler {
         this.sendMsgToServer(param);
     }
 
+    //提现返利
     onRebates(str: string) {
         console.log('[服务器] 提现返利信息', str);
+        let result = JSON.parse(str);
+        smc.game.GameModel.cashNum = result.props["1004"] / 100;
+        oops.message.dispatchEvent(GameEvent.openView, "openRebateView")
     }
 
+    //获取双倍奖励返回
     getDoubleSurprise() {
         const param = {
             url: ProtocolEvent.getDoubleAwardInfo,
@@ -164,10 +187,13 @@ export class ServerHandler {
         this.sendMsgToServer(param);
     }
 
+    //双倍惊喜返回
     onDoubleSurprise(str: string) {
         console.log('[服务器] 恭喜翻倍信息', str);
+        oops.message.dispatchEvent(GameEvent.openView, "openDoubleSurprise");
     }
 
+    //更新消除奖励
     updateEliminationReward(data: { level: number, score: number, count: number }) {
         const param = {
             url: ProtocolEvent.GetEliminationReward,
@@ -200,6 +226,50 @@ export class ServerHandler {
         smc.game.GameModel.sign = result?.sign || "";
     }
 
+    //直接领取通关奖励
+    getPassRewards() {
+        const level = smc.account.AccountModel.curLevel;
+        const param = {
+            url: ProtocolEvent.GetPassReward,
+            param: {
+                level: level,
+            },
+            callback: this.buildCallback('ServerHandler.inst.onGetPassRewards', 'ServerHandler.inst.onRequestFail')
+        }
+        this.sendMsgToServer(param);
+    }
+    //直接领取通关奖励返回
+    onGetPassRewards(str: string) {
+        console.log('[服务器] 直接领取通关奖励成功返回', str);
+        oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+    }
+
+
+
+
+
+
+    //少量领取翻倍奖励
+    getLittleRewards() {
+        const level = smc.account.AccountModel.curLevel;
+        const param = {
+            url: ProtocolEvent.GetLittlePassReward,
+            param: {
+                level: level,
+            },
+            callback: this.buildCallback('ServerHandler.inst.onGetDoubleRewards', 'ServerHandler.inst.onRequestFail')
+        }
+        this.sendMsgToServer(param);
+    }
+
+    //少量领取翻倍奖励返回
+    onGetDoubleRewards(str: string) {
+        console.log('[服务器] 直接领取通关奖励成功返回', str);
+        oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+    }
+
+
+
     onRequestFail(code: number, str: string) {
         console.log('[服务器] 请求失败', code, str);
     }

+ 14 - 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-10 18:24:31
+ * @LastEditTime: 2025-04-11 15:40:36
  * @Description: 
  */
 import { ecs } from "db://oops-framework/libs/ecs/ECS";
@@ -81,6 +81,13 @@ export class GameModelComp extends ecs.Comp {
     /**视频签名*/
     _sign: string = "";
 
+    /**双倍奖励页面信息*/
+
+
+    /**页面类型*/
+
+    /**提现必反*/
+    _cashNum: number = 0;
 
     /** 数据层组件移除时,重置所有数据为默认值 */
     reset() {
@@ -204,6 +211,12 @@ export class GameModelComp extends ecs.Comp {
         this._passViewInfo = value;
     }
 
+    set cashNum(value: number) {
+        this._cashNum = value;
+    }
 
+    get cashNum() {
+        return this._cashNum;
+    }
 
 }

+ 14 - 13
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 11:25:36
+ * @LastEditTime: 2025-04-11 16:00:25
  * @Description: 提现必返
  */
 import { _decorator, Label } from 'cc';
@@ -12,6 +12,8 @@ import { GameComponent } from "db://oops-framework/module/common/GameComponent";
 import { UIID } from '../common/config/GameUIConfig';
 import { CocosHandler } from '../common/manager/CocosHandler';
 import { ADHandler } from '../common/manager/ADHandler';
+import { smc } from '../common/SingletonModuleComp';
+import { GameEvent } from '../common/config/GameEvent';
 
 
 const { ccclass, property } = _decorator;
@@ -19,29 +21,28 @@ const { ccclass, property } = _decorator;
 /** 显示对象控制 */
 @ccclass('CashRebateView')
 export class CashRebateView extends GameComponent {
-    private _num: number = 0;
-    private lab_num: Label = null!;
+    @property(Label)
+    lab_num: Label = null!;
     protected start() {
-        this.lab_num = this.node.getChildByPath("Sprite/lab_num")!.uiLabel;
+        this.setButton();
+        this.setData();
     }
 
+
+    setData() {
+        if (this.lab_num) {
+            this.lab_num.string = smc.game.GameModel.cashNum + "";
+        }
+    }
     private btn_ok() {
         //看广告
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
             ADHandler.inst.showAd("105");
-        } else {
             oops.gui.remove(UIID.CashRebate);
-        }
-    }
+            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
 
-    private btn_close() {
-        //看广告
-        if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
-            ADHandler.inst.showAd("105");
         } else {
             oops.gui.remove(UIID.CashRebate);
         }
-
     }
-
 }

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

@@ -2,21 +2,69 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 11:57:43
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-03-21 14:26:30
+ * @LastEditTime: 2025-04-11 15:23:44
  * @Description: 惊喜翻倍弹窗
  */
+import { Label, Node } from 'cc';
 import { _decorator } from 'cc';
 import { GameComponent } from "db://oops-framework/module/common/GameComponent";
+import { ServerHandler } from '../common/manager/ServerHandler';
+import { oops } from 'db://oops-framework/core/Oops';
+import { UIID } from '../common/config/GameUIConfig';
+import { ADHandler } from '../common/manager/ADHandler';
+import { AD_TYPE } from '../common/config/GameDefine';
+import { ProgressBar } from 'cc';
 
 const { ccclass, property } = _decorator;
 
 /** 显示对象控制 */
 @ccclass('DoubleRewardsView')
 export class DoubleRewardsView extends GameComponent {
+    @property([Label])
+    lab_list: Label[] = [];
+    @property(Label)
+    lab_title: Label = null!;
+
+
+    @property(Label)
+    lab_tips: Label = null!;   //已经赚XXX
+
+    @property(Node)
+    tips_node1: Node = null!;  //进度条
+
+    @property(Node)
+    tips_node2: Node = null!;
+
+    @property(ProgressBar)
+    pro_loadBar1: ProgressBar = null!;
+
+
+
+    @property(ProgressBar)
+    pro_loadBar2: ProgressBar = null!;
+
+
     protected start() {
+        this.setButton();
+    }
+
+
+    btn_alittle() {
+        // ServerHandler.inst.getLittleRewards();
+        oops.gui.remove(UIID.DoubleRewards);
+        //插屏广告
+        ADHandler.inst.showAd(AD_TYPE.Double_Close);
+    }
+
 
+    btn_all() {
+        ADHandler.inst.showAd(AD_TYPE.Double_Receive);
+        oops.gui.remove(UIID.DoubleRewards);
     }
 
 
+    //算出底部进度条位置
+
+
 
 }

+ 224 - 229
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 11:27:37
+ * @LastEditTime: 2025-04-11 15:59:26
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -27,12 +27,6 @@ enum GameState {
     GAME_OVER   // 游戏结束 
 }
 
-// 游戏模式枚举
-enum GameMode {
-    MANUAL,     // 手动模式
-    AUTO        // 自动模式
-}
-
 
 // 格子状态
 enum CellState {
@@ -41,16 +35,6 @@ enum CellState {
     HIGHLIGHTED // 高亮(可放置)
 }
 
-// 新手引导步骤
-enum TutorialStep {
-    NONE,               // 无引导
-    ROW_ELIMINATION,    // 行消除引导
-    COLUMN_ELIMINATION, // 列消除引导
-    ROTATION,           // 旋转引导
-    FINAL_ELIMINATION   // 最终消除引导
-}
-
-
 //网格数据接口
 interface GridData {
     name: string,       // 名称
@@ -171,7 +155,7 @@ export class EliminateViewComp extends CCComp {
     isAutoMode: boolean = false;
     autoModeInterval: number = 1  // 自动模式的间隔时间(秒)
     autoModeTimer: number = 0  // 自动模式计时器
-
+    adShowingFlag: boolean = false;
 
     //网格列表管理列表  
     gridList: GridData[][] = [];
@@ -219,7 +203,8 @@ export class EliminateViewComp extends CCComp {
     addEventList() {
         oops.message.on(GameEvent.RestartGame, this.restartGame, this);
         oops.message.on(GameEvent.DoubleSpeedOpenSuccess, this.doubleSpeedOpenSuccess, this);
-        oops.message.on(GameEvent.openView, this.openView, this)
+        oops.message.on(GameEvent.openView, this.openView, this);
+        oops.message.on(GameEvent.showCoinAnimation, this.showCoinAnimation, this);
     }
 
 
@@ -287,10 +272,48 @@ export class EliminateViewComp extends CCComp {
             case "openPassView":
                 oops.gui.open(UIID.GamePass);
                 break;
+            case "openDoubleSurprise":
+                oops.gui.open(UIID.DoubleRewards);
+                break;
+            case "openRebateView":
+                oops.gui.open(UIID.CashRebate);
+                break;
         }
     }
 
 
+    //显示金币动画
+    showCoinAnimation(event: string, args: string) {
+        //计算中间的坐标就好
+        const lastPos = this.moveNode.getWorldPosition();
+        const score = this.score;
+
+        // 添加回调函数,在金币动画完成后显示微信分数增加
+        this.createCoinFlyAnimation(
+            this.coinPrefab,
+            lastPos,
+            this.amountLb.node.getWorldPosition(),
+            score,
+            () => {
+                // 显示微信分数增加动画
+                this.showWechatScoreAnimation();
+            }
+        );
+
+        // 添加回调函数,在红包动画完成后显示红包分数增加
+        this.createCoinFlyAnimation(
+            this.redPacketPrefab,
+            lastPos,
+            this.awardLb.node.getWorldPosition(),
+            5,
+            () => {
+                // 显示红包分数增加动画
+                this.showRedPacketScoreAnimation();
+            }
+        );
+    }
+
+
 
 
     //初始化网格
@@ -1265,8 +1288,8 @@ export class EliminateViewComp extends CCComp {
     // 显示红包分数增加动画
     private showRedPacketScoreAnimation() {
         if (!this.tweenRedNode) return;
+        //如果有值就是要那个,没有就是取随机
 
-        // 生成随机小数(小于1,保留2位小数)
         const randomValue = Math.random() * 0.99;
         const formattedValue = randomValue.toFixed(2);
 
@@ -1479,6 +1502,21 @@ export class EliminateViewComp extends CCComp {
     }
 
 
+    //更新游戏分数
+    updateGameScore() {
+        if (this.score >= this.targetScore) {
+            //修改游戏状态
+            this.gameState = GameState.GAME_OVER;
+            //弹出恭喜通关
+
+        }
+
+
+    }
+
+
+
+
     /**
      * 清理网格的子节点
      */
@@ -1517,13 +1555,8 @@ export class EliminateViewComp extends CCComp {
 
     //左边微信按钮
     private btn_withdraw() {
-
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
 
-
-
-
-
         } else {
             oops.gui.open(UIID.WechatWithdraw);
         }
@@ -1555,251 +1588,213 @@ export class EliminateViewComp extends CCComp {
         this.initButtonState(this.autoState);
         this.gameState = GameState.PLAYING
         if (this.autoState) {
-            this.startAutoMode();
-        } else {
-            this.stopAutoMode();
+            this.executeAutoPlace();
         }
     }
 
-    private autoModeScheduleKey: number = 0;
-
-    private startAutoMode() {
-        this.stopAutoMode(); // 确保先停止之前的自动模式
-        const interval = this._isDoubleSpeed ? this.autoModeInterval / this._doubleNum : this.autoModeInterval;
-        this.schedule(this.executeAutoPlacement, interval);
-        this.autoModeScheduleKey = 0; // 不再使用返回值
-    }
-
-    private stopAutoMode() {
-        this.unschedule(this.executeAutoPlacement);
-    }
-
-    // 调整自动放置速度
-    public setAutoPlacementSpeed(interval: number) {
-        this.autoModeInterval = interval;
-        if (this.autoState) {
-            this.startAutoMode(); // 重新启动以更新间隔
-        }
-    }
 
     // 执行自动放置
-    private executeAutoPlacement() {
-        if (this.editingFlag || this.gameState !== GameState.PLAYING) return;
+    executeAutoPlace() {
+        if (!this.autoState || this.gameState !== GameState.PLAYING || this.adShowingFlag || this.editingFlag) {
+            return
+        }
 
-        // 查找最佳放置方案
-        const bestPlacement = this.findBestPlacement();
+        const bestPlacement = this.findBestPlacement()
         if (!bestPlacement) {
-            this.gameOver();
-            return;
+            // 所有方块都无法放置,游戏结束
+            this.autoState = false
+            this.gameOver()
+            return
         }
 
-        this.autoPlaceBrick(bestPlacement);
+        // 执行放置
+        this.placeBrickAtPosition(bestPlacement)
     }
 
+    //寻找最佳位置
+    findBestPlacement() {
+        const placements = []
+
+        // 对每个方块计算所有可能的放置位置和分数
+        for (let brickIndex = 0; brickIndex < this.bricksList.length; brickIndex++) {
+            const brickData = this.bricksList[brickIndex]
+
+            // 检查不同旋转状态
+            let gridConfigs = [brickData.gridConfig]
+            let degrees = [brickData.deg]
+
+            // 如果可旋转,计算所有旋转状态
+            if (brickData.rotateFlag) {
+                for (let i = 1; i <= 3; i++) {
+                    const next = this.nextGridRotate(
+                        i === 1 ? brickData.gridConfig : gridConfigs[i - 1],
+                        i === 1 ? brickData.deg : degrees[i - 1]
+                    )
+                    gridConfigs.push(next.gridConfig)
+                    degrees.push(next.deg)
+                }
+            }
+
+            // 遍历所有网格位置
+            for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
+                for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
+                    // 对每个旋转状态检查
+                    for (let rotateIndex = 0; rotateIndex < gridConfigs.length; rotateIndex++) {
+                        const currentGridConfig = gridConfigs[rotateIndex]
+                        const currentDeg = degrees[rotateIndex]
 
-    // 查找最佳放置方案
-    private findBestPlacement() {
-        // 最佳放置方案
-        let bestPlacement: {
-            brickIndex: number,
-            row: number,
-            column: number,
-            rotateCount: number,
-            score: number
-        } | null = null;
-
-        // 遍历所有方块
-        for (let brickI = 0; brickI < this.bricksList.length; brickI++) {
-            const brickData = this.bricksList[brickI];
-
-            // 尝试所有可能的旋转状态
-            let currentGridConfig = [...brickData.gridConfig];
-            let currentDeg = brickData.deg;
-
-            for (let rotateCount = 0; rotateCount < 4; rotateCount++) {
-                // 遍历所有网格位置
-                for (let rowIndex = 0; rowIndex < this.rows; rowIndex++) {
-                    for (let columnIndex = 0; columnIndex < this.cols; columnIndex++) {
                         // 检查是否可以放置
                         if (this.moveIf(rowIndex, columnIndex, currentGridConfig)) {
-                            // 复制网格状态并模拟放置
-                            const gridListCopy = this.copyGridList();
-                            currentGridConfig.forEach((configData) => {
-                                gridListCopy[configData.row + rowIndex][configData.column + columnIndex].status = CellState.FILLED;
-                                gridListCopy[configData.row + rowIndex][configData.column + columnIndex].type = brickData.type;
-                            });
-
-                            // 计算放置后的分数
-                            const eliminateResult = this.gridEliminateCheck(gridListCopy);
-                            const eliminatedCount = eliminateResult.gridEliminateList.length;
-                            const eliminateRowNum = eliminateResult.eliminateRowNum;
-                            const eliminateColumnNum = eliminateResult.eliminateColumnNum;
-
-                            let score = 0;
-                            // 有消除,计算消除分数
-                            if (eliminatedCount > 0) {
-                                // 行消除基础分
-                                for (let i = 1; i <= eliminateRowNum; i++) {
-                                    score += this.eliminateBaseScore; // 每行基础分
-                                    score += (this.cols - 1) * this.extraGridScore; // 额外格子分
-                                }
+                            // 复制网格并模拟放置
+                            const gridList = this.copyGridList()
+                            currentGridConfig.forEach((gridConfigData) => {
+                                const r = gridConfigData.row + rowIndex
+                                const c = gridConfigData.column + columnIndex
+                                gridList[r][c].status = CellState.FILLED
+                                // gridList[r][c].gridColorKey = brickData.gridColorKey
+                                gridList[r][c].type = brickData.type;
+                            })
 
-                                // 列消除基础分
-                                for (let i = 1; i <= eliminateColumnNum; i++) {
-                                    score += this.eliminateBaseScore; // 每列基础分
-                                    score += (this.rows - 1) * this.extraGridScore; // 额外格子分
-                                }
-                            }
+                            // 检查是否可以消除,计算分数
+                            const elimination = this.gridEliminateCheck(gridList)
+                            let score = 0
 
-                            // 如果没有消除,给予放置的块数作为基础分
-                            if (score === 0) {
-                                score = currentGridConfig.length * this.placementBaseScore;
+                            if (elimination.gridEliminateList.length > 0) {
+                                // 计算消除得分
+                                for (let i = 1; i <= elimination.eliminateRowNum; i++) {
+                                    score += this.cols * i
+                                }
+                                for (let i = 1; i <= elimination.eliminateColumnNum; i++) {
+                                    score += this.rows * i
+                                }
                             }
 
-                            // 更新最佳方案
-                            if (!bestPlacement || score > bestPlacement.score) {
-                                bestPlacement = {
-                                    brickIndex: brickI,
-                                    row: rowIndex,
-                                    column: columnIndex,
-                                    rotateCount: rotateCount,
-                                    score: score
-                                };
-                            }
+                            // 记录此放置选项
+                            placements.push({
+                                brickIndex,
+                                brickData,
+                                rowIndex,
+                                columnIndex,
+                                gridConfig: currentGridConfig,
+                                deg: currentDeg,
+                                score,
+                                canEliminate: elimination.gridEliminateList.length > 0
+                            })
                         }
                     }
                 }
-
-                // 旋转方块到下一个状态
-                if (rotateCount < 3 && brickData.rotateFlag) {
-                    const next = this.nextGridRotate(currentGridConfig, currentDeg);
-                    currentGridConfig = next.gridConfig;
-                    currentDeg = next.deg;
-                }
             }
         }
 
-        return bestPlacement;
+        // 按优先级排序:最高分 > 有分数 > 没有分数但可放置
+        placements.sort((a, b) => {
+            // 首先按分数排序
+            if (a.score !== b.score) {
+                return b.score - a.score
+            }
+            // 其次按是否可消除排序
+            if (a.canEliminate !== b.canEliminate) {
+                return a.canEliminate ? -1 : 1
+            }
+            // 最后按照方块优先级排序(底部的方块优先)
+            return a.brickIndex - b.brickIndex
+        })
+
+        return placements.length > 0 ? placements[0] : null
     }
 
-    // 自动放置方块
-    private autoPlaceBrick(placement: { brickIndex: number, row: number, column: number, rotateCount: number, score: number }) {
-        const brickData = this.bricksList[placement.brickIndex];
-        if (!brickData || !brickData.brickNode) return;
-        console.log("brickData>>>>>>", brickData);
-        // 获取方块节点
-        const brickNode = brickData.brickNode;
-
-        // 先将方块移到移动层以便显示动画
-        const originalParent = brickNode.parent;
-        const startPos = brickNode.getWorldPosition().clone();
-        brickNode.setParent(this.moveNode);
-        brickNode.setWorldPosition(startPos);
-
-        // 放大方块
-        tween(brickNode)
-            .to(0.2, { scale: new Vec3(1, 1, 1) })
-            .start();
+    // ... existing code ...
 
-        // 从方块列表中移除该方块
-        this.bricksList.splice(placement.brickIndex, 1);
-
-        // 先应用旋转到实际的brickData中,这样放置和显示保持一致
-        if (placement.rotateCount > 0 && brickData.rotateFlag) {
-            let currentGridConfig = [...brickData.gridConfig];
-            let currentDeg = brickData.deg;
-            for (let i = 0; i < placement.rotateCount; i++) {
-                const next = this.nextGridRotate(currentGridConfig, currentDeg);
-                currentGridConfig = next.gridConfig;
-                currentDeg = next.deg;
-            }
-            // 直接更新brickData的配置
-            brickData.gridConfig = currentGridConfig;
-            brickData.deg = currentDeg;
+    placeBrickAtPosition(placement: any) {
+        const brickData = placement.brickData
+        const index = this.bricksList.findIndex(data => data === brickData)
+        if (index === -1) {
+            console.error("无法找到要放置的方块:", brickData)
+            return
+        }
+        this.editingData.brickData = this.bricksList.splice(index, 1)[0];
+        // 应用旋转
+        if (brickData.deg !== placement.deg) {
+            brickData.gridConfig = placement.gridConfig
+            brickData.deg = placement.deg
+            tween(brickData.brickNode).to(0.1, { angle: placement.deg }).start()
         }
 
-        // 计算目标网格的中心位置
-        const targetGridList: GridData[] = [];
-        let targetPos = new Vec3(0, 0, 0);
-
-        // 计算目标位置,使用更新后的brickData.gridConfig
-        brickData.gridConfig.forEach(configData => {
-            const gridRow = configData.row + placement.row;
-            const gridCol = configData.column + placement.column;
-            if (gridRow >= 0 && gridRow < this.rows && gridCol >= 0 && gridCol < this.cols) {
-                const grid = this.gridList[gridRow][gridCol];
-                if (grid.gridNode) {
-                    targetGridList.push(grid);
-                    targetPos.add(grid.gridNode.getWorldPosition());
-                }
-            }
-        });
+        // 构建对应网格列表
+        this.editingData.gridList = []
+        placement.gridConfig.forEach((gridConfigData) => {
+            const r = gridConfigData.row + placement.rowIndex
+            const c = gridConfigData.column + placement.columnIndex
+            this.editingData.gridList.push(this.gridList[r][c])
+        })
 
-        console.log("this.gridList", this.gridList);
-        if (targetGridList.length > 0) {
-            targetPos.x /= targetGridList.length;
-            targetPos.y /= targetGridList.length;
-        }
-        // 创建动画序列
-        const tweenSequence = tween(brickNode);
 
-        // 1. 先执行旋转动画(如果需要)
-        if (placement.rotateCount > 0 && brickData.rotateFlag) {
-            tweenSequence.to(0.3, { angle: brickData.deg });
+        // 计算移动位置(中点)
+        let centerPos = new Vec3(0, 0, 0)
+        let count = 0
+        for (const grid of this.editingData.gridList) {
+            if (grid.gridNode) {
+                const pos = grid.gridNode.getWorldPosition()
+                centerPos.add(pos)
+                count++
+            }
+        }
+        if (count > 0) {
+            centerPos.x /= count
+            centerPos.y /= count
+            centerPos.z /= count
         }
 
-        // 2. 再执行移动动画
-        tweenSequence.to(0.5, { worldPosition: targetPos });
-
-        // 3. 动画完成后更新网格和执行后续操作
-        tweenSequence.call(() => {
-            // 放置方块到网格
-            targetGridList.forEach(grid => {
-                grid.status = CellState.FILLED;
-                grid.type = brickData.type;
-                //这是对的
-                console.log(">>>>>>>>>>>>>>>>>", grid);
-                this.generateGrid(grid);
-            });
+        const originPos = brickData.brickNode.getWorldPosition()
+        brickData.brickNode.setParent(this.moveNode)
+        brickData.brickNode.setWorldPosition(originPos)
 
-            // 显示得分动画
-            this.showScoreAnimation(targetPos, targetGridList.length);
+        // 动画放置方块
+        tween(brickData.brickNode)
+            .to(0.2, { worldPosition: centerPos })
+            .call(() => {
+                // ✅ 更新格子状态(像手动放置那样)
+                this.editingData.gridList.forEach(gridData => {
+                    gridData.status = CellState.FILLED
+                    // gridData.gridColorKey = brickData.gridColorKey
+                    gridData.type = brickData.type;
+
+                    this.generateGrid(gridData)
+                })
+
+                // ✅ 销毁方块节点
+                brickData.brickNode.destroy()
+
+                // ✅ 补充新的砖块
+                this.addBrick(brickData.index)
+
+                // ✅ 消除检查逻辑保持和手动一致
+                this.scheduleOnce(() => {
+                    this.gridEliminate().then(() => {
+                        this.prompt(false).then((promptFlag) => {
+                            if (!promptFlag) {
+                                this.autoState = false
+                                this.gameOver()
+                            } else if (this.autoState) {
+                                // 继续自动放置
+                                this.scheduleOnce(() => {
+                                    this.executeAutoPlace()
+                                }, 0.3)
+                            }
+                            this.editingFlag = false
+                        })
+                    })
+                })
+            })
+            .start()
+    }
 
-            // 标记需要重置消除计数器
-            this.shouldResetEliminateCount = true;
 
-            // 销毁方块节点
-            brickNode.destroy();
 
-            // 添加新方块到待选区
-            this.addBrick(brickData.index);
 
-            // 检查消除
-            this.scheduleOnce(() => {
-                this.gridEliminate().then((hasElimination) => {
-                    // 如果没有消除,确保下次消除会重置计数
-                    if (!hasElimination) {
-                        this.shouldResetEliminateCount = true;
-                    }
 
-                    // 检查游戏是否结束
-                    this.prompt(false).then(canContinue => {
-                        if (!canContinue) {
-                            this.gameOver();
-                            this.stopAutoMode();
-                        }
-                    });
-                });
-            }, 0.1);
-        });
 
-        // 应用二倍速度
-        // 注意:在当前引擎版本中无法直接调整tween的速度
-        // 如需二倍速效果,应在创建tween时直接调整动画持续时间
 
-        // 启动动画
-        tweenSequence.start();
-    }
 
 
     doubleSpeedOpenSuccess() {

+ 17 - 4
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-11 11:27:19
+ * @LastEditTime: 2025-04-11 14:52:51
  * @Description: 游戏通关弹窗
  */
 import { Label, Node } from 'cc';
@@ -15,6 +15,8 @@ import { UIID } from '../common/config/GameUIConfig';
 import { CocosHandler } from '../common/manager/CocosHandler';
 import { smc } from '../common/SingletonModuleComp';
 import { ADHandler } from '../common/manager/ADHandler';
+import { GameEvent } from '../common/config/GameEvent';
+import { ServerHandler } from '../common/manager/ServerHandler';
 
 
 const { ccclass, property } = _decorator;
@@ -40,8 +42,19 @@ export class GamePassView extends GameComponent {
         this.setButton();
         this.isAuto = true;
         this.setData();
+        this.addEventList();
     }
 
+    addEventList() {
+        oops.message.on(GameEvent.showCoinAnimation, this.showCoinAnimation, this);
+    }
+
+
+    showCoinAnimation() {
+        if (oops.gui.has(UIID.GamePass)) {
+            oops.gui.remove(UIID.GamePass);
+        }
+    }
 
 
     private setData() {
@@ -62,9 +75,10 @@ export class GamePassView extends GameComponent {
 
     //开心收下正常领取
     private btn_none() {
-        //是否展示广告
+        // oops.message.dispatchEvent(GameEvent.showCoinAnimation);
         oops.gui.remove(UIID.GamePass);
-        ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
+        //给服务器发信息--少量领取
+        ServerHandler.inst.getPassRewards();
     }
 
     //十倍领取
@@ -80,7 +94,6 @@ export class GamePassView extends GameComponent {
 
     //设置自动领取
     setAutoReceive() {
-
         let time = this.time;
         this.callback = function () {
             if (time <= 0 && this.isAuto) {

+ 6 - 6
assets/script/game/view/RedPackeItemView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 18:39:37
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-10 15:09:37
+ * @LastEditTime: 2025-04-11 14:06:25
  * @Description: 红包列表item
  */
 import { _decorator, Label, Node, ProgressBar, Sprite } from 'cc';
@@ -75,11 +75,11 @@ export class RedPackeItemView extends VMParent {
             this.receiveNode.active = true;
             this.unReceiveNode.active = false;
         }
-        this.lab_title.string = this.data.title;
-        this.lab_progress.string = `${this.data.current}/${this.data.total}`;
-        this.pro_progress.progress = this.data.current / this.data.total;
-        // this.sp_icon.spriteFrame = oops.res.getSpriteFrame(this.data.goods[0].type);
-        this.lab_num.string = this.data.goods[0].num;
+        // this.lab_title.string = this.data.title;
+        // this.lab_progress.string = `${this.data.current}/${this.data.total}`;
+        // this.pro_progress.progress = this.data.current / this.data.total;
+        // // this.sp_icon.spriteFrame = oops.res.getSpriteFrame(this.data.goods[0].type);
+        // this.lab_num.string = this.data.goods[0].num;
     }