소스 검색

【功能】设置代码逻辑完成99%

mojunshou 8 달 전
부모
커밋
69dca59d96

+ 10 - 8
assets/bundle/gui/eliminate/eliminate.prefab

@@ -2717,7 +2717,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 44.4921875,
+      "width": 11.123046875,
       "height": 50.4
     },
     "_anchorPoint": {
@@ -2753,7 +2753,7 @@
       "b": 182,
       "a": 255
     },
-    "_string": "1000",
+    "_string": "0",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
     "_actualFontSize": 20,
@@ -4690,7 +4690,7 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -151.01998901367188,
+      "x": -123.89999389648438,
       "y": 0,
       "z": 0
     },
@@ -4867,7 +4867,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 105.03997802734375,
+      "width": 50.79998779296875,
       "height": 110.8
     },
     "_anchorPoint": {
@@ -4903,7 +4903,7 @@
       "b": 135,
       "a": 255
     },
-    "_string": "10",
+    "_string": "1",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
     "_actualFontSize": 80,
@@ -4988,7 +4988,7 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 90.01998901367188,
+      "x": 62.899993896484375,
       "y": 0,
       "z": 0
     },
@@ -5115,7 +5115,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 377.03997802734375,
+      "width": 322.79998779296875,
       "height": 100
     },
     "_anchorPoint": {
@@ -9373,6 +9373,9 @@
     "awardLb": {
       "__id__": 61
     },
+    "goldNumLb": {
+      "__id__": 194
+    },
     "tweenWechatNode": {
       "__id__": 152
     },
@@ -9481,7 +9484,6 @@
     "addSpeedBtn": {
       "__id__": 340
     },
-    "eliminateBaseScore": 10,
     "_id": ""
   },
   {

+ 5 - 2
assets/script/game/account/Account.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: dgflash
  * @Date: 2021-11-11 17:45:23
- * @LastEditors: dgflash
- * @LastEditTime: 2022-08-01 13:49:37
+ * @LastEditors: mojunshou 1637302775@qq.com
+ * @LastEditTime: 2025-04-09 16:26:41
  */
 import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
 import { AccountModelComp } from "./model/AccountModelComp";
@@ -15,4 +15,7 @@ export class Account extends ecs.Entity {
     protected init() {
         this.addComponents<ecs.Comp>(AccountModelComp);
     }
+
+
+
 }

+ 127 - 29
assets/script/game/account/model/AccountModelComp.ts

@@ -4,8 +4,9 @@
  * @Author: dgflash
  * @Date: 2021-11-12 10:02:31
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-09 14:12:47
+ * @LastEditTime: 2025-04-09 16:31:00
  */
+import { oops } from "db://oops-framework/core/Oops";
 import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
 
 /** 
@@ -38,31 +39,33 @@ interface CostInfo {
 @ecs.register('AccountModel')
 export class AccountModelComp extends ecs.Comp {
     /** 账号名 */
-    accountName: string = null!;
+    _accountName: string = null!;
     /**玩家UID */
-    uid: number = -1;
+    _uid: number = -1;
     /**玩家头像*/
-    headUrl: string = null!
+    _headUrl: string = null!
     /**当前关卡--默认从0开始*/
-    curLevel: number = 0;
+    _curLevel: number = 0;
     /**游戏币*/
-    gameCoin: number = 0;
+    _gameCoin: number = 0;
     /**红包币*/
-    cashCoin: number = 0;
+    _cashCoin: number = 0;
+    /**金块*/
+    _goldCoin: number = 0;
+    /**手续费*/
+    _handlingCharge: number = 0;
     /**目标分数*/
-    targetScore: number = 0;
+    _targetScore: number = 0;
     /**协议类型 1隐私 2用户*/
-    protocolType: number = 1;
+    _protocolType: number = 1;
     //当前关卡信息
-    curLevelInfo: CurLevelInfo = null!;
+    _curLevelInfo: CurLevelInfo = null!;
     /**当前关卡配置*/
-    curLevelConfig: CurLevelConfig = null!;
+    _curLevelConfig: CurLevelConfig = null!;
     /**游戏费用配置*/
-    costInfo: CostInfo = null!;
+    _costInfo: CostInfo = null!;
     /**是否登录过*/
-    isLogined: boolean = false;
-
-
+    _isLogined: boolean = false;
 
     reset() {
         this.accountName = null!;
@@ -78,21 +81,116 @@ export class AccountModelComp extends ecs.Comp {
     }
 
 
-    //保存微信数据
-    setWechatInfo(data: any) {
-        this.accountName = data.nickname;
-        this.uid = data.uid;
-        this.headUrl = data.headImgUrl;
+    get accountName() {
+
+        return this._accountName;
+    }
+
+    set accountName(value: string) {
+        this._accountName = value;
+    }
+
+    get uid() {
+        return this._uid;
+    }
+
+    set uid(value: number) {
+        this._uid = value;
+    }
+
+    get headUrl() {
+        return this._headUrl;
+    }
+
+    set headUrl(value: string) {
+        this._headUrl = value;
+    }
+
+    get curLevel() {
+        return this._curLevel;
+    }
+
+    set curLevel(value: number) {
+        this._curLevel = value;
+    }
+
+    get gameCoin() {
+        return this._gameCoin;
+    }
+
+    set gameCoin(value: number) {
+        this._gameCoin = value;
     }
 
+    get cashCoin() {
+        return this._cashCoin;
+    }
+
+    set cashCoin(value: number) {
+        this._cashCoin = value;
+    }
+
+    get goldCoin() {
+        return this._goldCoin;
+    }
+
+    set goldCoin(value: number) {
+        this._goldCoin = value;
+    }
 
-    //设置账号数据
-    setAccountInfo(data: any) {
-        // this.AccountName = data.accountName;
-        this.uid = data.uid;
-        this.curLevelInfo = data.currentLevelInfo;
-        this.curLevelConfig = data.currentLevelConfig;
-        this.costInfo = data.handlingChargeConf;
-        this.isLogined = data.logined;
+    get handlingCharge() {
+        return this._handlingCharge;
     }
-}
+
+    set handlingCharge(value: number) {
+        this._handlingCharge = value;
+    }
+
+    get targetScore() {
+        return this._targetScore;
+    }
+
+    set targetScore(value: number) {
+        this._targetScore = value;
+    }
+
+    get protocolType() {
+        return this._protocolType;
+    }
+
+    set protocolType(value: number) {
+        this._protocolType = value;
+    }
+
+    get curLevelInfo() {
+        return this._curLevelInfo;
+    }
+
+    set curLevelInfo(value: CurLevelInfo) {
+        this._curLevelInfo = value;
+    }
+
+    get curLevelConfig() {
+        return this._curLevelConfig;
+    }
+
+    set curLevelConfig(value: CurLevelConfig) {
+        this._curLevelConfig = value;
+    }
+
+    get costInfo() {
+        return this._costInfo;
+    }
+
+    set costInfo(value: CostInfo) {
+        this._costInfo = value;
+    }
+
+    get isLogined() {
+        return this._isLogined;
+    }
+
+    set isLogined(value: boolean) {
+        this._isLogined = value;
+    }
+}

+ 76 - 18
assets/script/game/common/manager/CocosHandler.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-31 10:45:44
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-09 14:33:13
+ * @LastEditTime: 2025-04-09 16:41:09
  * @Description: CocosHandler 处理类负责与安卓交互
  */
 import { native } from 'cc';
@@ -123,7 +123,6 @@ export class CocosHandler {
             "code": code,
             "url": ProtocolEvent.WechatLogin
         }
-
         const data: CocosHandlerType = {
             method: "request.post",
             param: JSON.stringify(param)
@@ -132,8 +131,6 @@ export class CocosHandler {
         let result = await this.sendMessageToAndroid(data);
         console.log("微信登录结果", result);
         if (result.data) {
-            smc.account.AccountModel.setWechatInfo(result.data);
-            //然后登录获取用户信息
             this.getAccountInfo();
         }
     }
@@ -149,19 +146,23 @@ export class CocosHandler {
             }
 
         }
-        const data: CocosHandlerType = {
-            method: "request.post",
-            param: JSON.stringify(param)
-        }
-        this.sendMessageToAndroid(data);
+        this.sendMsgToServer(param);
     }
 
     //获取账号信息成功回调
     getAccountInfo_success(str: string) {
         console.log("获取账号信息成功回调", str);
         //保存账号信息
-        let result = JSON.parse(str);
-        smc.account.AccountModel.setAccountInfo(result);
+        let data = JSON.parse(str);
+        smc.account.AccountModel.uid = data.uid;
+        console.log("uid>>>>>>>", data.uid);
+        smc.account.AccountModel.curLevelInfo = data.currentLevelInfo;
+        smc.account.AccountModel.curLevelConfig = data.currentLevelConf;
+        smc.account.AccountModel.costInfo = data.handlingChargeConf;
+        smc.account.AccountModel.isLogined = data.logined;
+        smc.account.AccountModel.accountName = data.nickname;
+        smc.account.AccountModel.uid = data.uid;
+        smc.account.AccountModel.headUrl = data.headImgUrl;
         oops.message.dispatchEvent(GameEvent.UserLogin);
     }
 
@@ -183,11 +184,7 @@ export class CocosHandler {
                 "onFail": "CocosHandler.inst.request_fail"
             }
         }
-        const data: CocosHandlerType = {
-            method: "request.post",
-            param: JSON.stringify(param)
-        }
-        this.sendMessageToAndroid(data);
+        this.sendMsgToServer(param);
     }
 
     //领取每日奖励成功回调
@@ -197,14 +194,75 @@ export class CocosHandler {
 
 
 
-    request_fail(code: number, str: string) {
-        console.log("请求失败回调", code, str);
+
+
+    //======获取红包提现列表数据
+    getDailyTaskReward() {
+        //先请求一遍用户道具信息
+        this.getUserItemInfo();
+        const param = {
+            "url": ProtocolEvent.GetDailyTask,
+            "callback": {
+                "onSuccess": "CocosHandler.inst.getDailyTaskReward_success",
+                "onFail": "CocosHandler.inst.request_fail"
+            }
+        }
+        this.sendMsgToServer(param);
+    }
+
+    //获取红包提现列表数据成功回调
+    getDailyTaskReward_success(str: string) {
+        console.log("获取红包提现列表数据成功回调", str);
+    }
+
+    //获取用户道具信息
+    getUserItemInfo() {
+        const param = {
+            "url": ProtocolEvent.UserItemInfo,
+            "callback": {
+                "onSuccess": "CocosHandler.inst.getUserItemInfo_success",
+                "onFail": "CocosHandler.inst.request_fail"
+            }
+        }
+        this.sendMsgToServer(param);
+    }
+
+    //获取用户道具信息成功
+    getUserItemInfo_success(str: string) {
+        console.log("获取用户道具信息成功回调", str);
+        //保存用户道具信息
+        let result = JSON.parse(str);
+        // smc.account.AccountModel.setUserItemInfo(result);
+        smc.account.AccountModel.gameCoin = result.data.props["1005"];
+        smc.account.AccountModel.cashCoin = result.data.props["1004"];
+        smc.account.AccountModel.handlingCharge = result.data.props["1009"];
+        smc.account.AccountModel.goldCoin = result.data.propsp["1006"];
     }
 
 
 
 
 
+
+    //发送信息给服务器
+    sendMsgToServer(param: any) {
+        const data: CocosHandlerType = {
+            method: "request.post",
+            param: JSON.stringify(param)
+        }
+        this.sendMessageToAndroid(data);
+    }
+
+
+
+
+
+
+
+
+    request_fail(code: number, str: string) {
+        console.log("请求失败回调", code, str);
+    }
     //=================================以下是广告方法====================
     //每次启动都加载一次启屏广告
     async ad_interstitial_start() {

+ 2 - 2
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-08 18:35:54
+ * @LastEditTime: 2025-04-09 15:29:28
  * @Description: 消息定义
  */
 
@@ -18,7 +18,7 @@ export enum ProtocolEvent {
     ModifySetting = server_url + "/project/playlet/v1/user/updateSetting",
     /**领取每日奖励*/
     GetDailyReward = server_url + "/project/playlet/v1/daily/eliminationTsk/gain",
-    /**获取每日任务情况*/
+    /**获取获取红包提现列表数据*/
     GetDailyTask = server_url + "/project/playlet/v1/daily/eliminationTsk/info",
     /**用户道具信息*/
     UserItemInfo = server_url + "/project/playlet/v1/props/all",

+ 9 - 10
assets/script/game/common/setting/SettingViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:40:20
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-09 11:53:23
+ * @LastEditTime: 2025-04-09 16:55:59
  * @Description:设置界面 
  */
 import { _decorator } from "cc";
@@ -16,6 +16,8 @@ import { Account } from "../../account/Account";
 import { ImageAsset, Texture2D, SpriteFrame, Sprite } from "cc";
 import { IRemoteOptions, resLoader } from "db://oops-framework/core/common/loader/ResLoader";
 import { Button } from "cc";
+import { smc } from "../SingletonModuleComp";
+import { CocosHandler } from "../manager/CocosHandler";
 const { ccclass, property } = _decorator;
 
 /** 视图层对象 */
@@ -109,9 +111,8 @@ export class SettingViewComp extends CCVMParentComp {
 
     //更新头像
     private updateHead() {
-        let account = ecs.getEntity<Account>(Account);
-        this.data.uid = account.AccountModel.uid;
-        let url = account.AccountModel.headUrl;
+        this.data.uid = smc.account.AccountModel.uid;
+        let url = smc.account.AccountModel.headUrl;
         // let sprite = this.node.getChildByPath("Bg/btn_head/sp_head")!.uiSprite;
         // let url = "http://www.kuaipng.com/Uploads/pic/w/2020/07-16/89010/water_89010_698_698_.png"
         // var opt: IRemoteOptions = { ext: ".png" };
@@ -153,16 +154,14 @@ export class SettingViewComp extends CCVMParentComp {
 
     //隐私协议
     private btn_privacy() {
-
-
-
+        smc.account.AccountModel.protocolType = 1;
+        CocosHandler.inst.openAgreement();
     }
 
-
-
     //用户协议
     private btn_protocol() {
-
+        smc.account.AccountModel.protocolType = 2;
+        CocosHandler.inst.openAgreement();
     }
 
 }

+ 17 - 31
assets/script/game/eliminate/view/EliminateViewComp.ts

@@ -2,18 +2,16 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:01:09
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-09 12:03:13
+ * @LastEditTime: 2025-04-09 16:46:12
  * @Description: 消除游戏主场景
  */
-import { _decorator, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, Toggle, tween, UITransform, Vec2, Vec3, Widget } from "cc";
-import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
+import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
 import { oops } from "db://oops-framework/core/Oops";
 import { ecs } from "db://oops-framework/libs/ecs/ECS";
 import { LabelChange } from "db://oops-framework/libs/gui/label/LabelChange";
 import { CCComp } from "db://oops-framework/module/common/CCComp";
 import { GameEvent } from "../../common/config/GameEvent";
 import { UIID } from "../../common/config/GameUIConfig";
-import { Button } from "cc";
 import { smc } from "../../common/SingletonModuleComp";
 
 const { ccclass, property } = _decorator;
@@ -144,7 +142,6 @@ export class EliminateViewComp extends CCComp {
     private addSpeedBtn: Button = null!;
 
 
-
     //游戏配置行列
     private rows: number = 8;       // 行数
     private cols: number = 8;       // 列数
@@ -155,6 +152,8 @@ export class EliminateViewComp extends CCComp {
     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开始
@@ -162,11 +161,6 @@ export class EliminateViewComp extends CCComp {
     private _isDoubleSpeed: boolean = false;  //是否开启二倍速
     private _doubleNum: number = 2;           //除2就是开启了2倍速,除1就是关闭了2倍速
 
-    //网格列表
-    // gridsNode: Node | null = null;          //中间网格区域
-    // brickNode: Node | null = null;           //底部三个item块区域
-    // moveNode: Node | null = null;           //移动层Node
-    // rotateNode: Node | null = null;         //旋转Node吧     
 
     //没使用颜色
     notUseColor = new Color(255, 255, 255, 255)
@@ -176,7 +170,6 @@ export class EliminateViewComp extends CCComp {
     unavailableColor = new Color(255, 0, 0, 100)
     //旋转容错
     rotateFaultTolerant = 10;
-    private _isAutoFunc: (() => void) | null = null;
 
     isAutoMode: boolean = false;
     autoModeInterval: number = 1  // 自动模式的间隔时间(秒)
@@ -204,18 +197,6 @@ export class EliminateViewComp extends CCComp {
     // 添加新的属性来跟踪是否需要重置消除计数
     private shouldResetEliminateCount: boolean = true;
 
-    // 添加配置属性 - 消除基础分
-    @property({ displayName: "消除一行/列基础分" })
-    private eliminateBaseScore: number = 10;
-
-    //当前局数
-    private curGameNum: number = 0;
-    //第一通关开始新人模式
-    //第二局开始马上播放新的弹窗
-    //往后根据每局需要弹窗就弹窗
-    //通关一局算一块金砖
-    //通关比例算金砖比例
-
     private autoState: boolean = false;  //自动状态
 
     /** 视图层逻辑代码分离演示 */
@@ -226,6 +207,7 @@ export class EliminateViewComp extends CCComp {
         await this.loadConfig();
         this.initGrid();
         this.initData();
+        this.setData();
         this.addEventList();
     }
 
@@ -263,24 +245,29 @@ export class EliminateViewComp extends CCComp {
     private initData() {
         // this.gameMode = GameMode.MANUAL;
         this.score = 0;
-        this.targetScore = smc.account.AccountModel.curLevelConfig.score;
+        this.targetScore = 0;
         this.money = 0;
         this.cash = 0;
         this.totalNum = 0;
-        // this._doubleNum = 2;
         this.autoState = false;
         this.shouldResetEliminateCount = true;
         this.lab_score.string = this.score.toString();
         this.amountLb.string = this.money.toString();
         this.awardLb.string = this.cash.toString();
+        this.lab_taget.string = this.targetScore.toString();
     }
 
-    //初始化关卡信息
-    private initLevelInfo() {
-        //关卡通关服务器或者本地读出来
-        // const level = 
-
 
+    //设置数据
+    setData() {
+        this.score = smc.account.AccountModel.curLevelInfo.score;
+        this.money = smc.account.AccountModel.gameCoin;
+        this.cash = smc.account.AccountModel.cashCoin;
+        this.targetScore = smc.account.AccountModel.curLevelConfig.score;
+        this.lab_score.string = this.score.toString();
+        this.amountLb.string = this.money.toString();
+        this.awardLb.string = this.cash.toString();
+        this.lab_taget.string = this.targetScore.toString();
     }
 
 
@@ -1477,7 +1464,6 @@ export class EliminateViewComp extends CCComp {
     }
 
 
-
     //========================打开其他界面和按钮逻辑=======================
 
     /** 视图对象通过 ecs.Entity.remove(eliminateViewComp) 删除组件是触发组件处理自定义释放逻辑 */