Quellcode durchsuchen

全局变量替换

薛鸿潇 vor 5 Jahren
Ursprung
Commit
0a44dd3ea4

+ 23 - 1
assets/script/game/data/EnumData.ts

@@ -2,7 +2,7 @@
  * 全局枚举数据
  * 全局枚举数据
  * @author
  * @author
  */
  */
-export class EnumData {
+export class GEnum {
 
 
     /** 奖励状态 */
     /** 奖励状态 */
     rewardState = {
     rewardState = {
@@ -13,4 +13,26 @@ export class EnumData {
         /** 可领取 */
         /** 可领取 */
         unlock: 3
         unlock: 3
     }
     }
+    GameProp = {
+        /** ------------------ 游戏核心数据 --------------------------- */
+
+
+        /** ------------------ 转盘数据 ------------------------------ */
+        turnable_leftTimes: 20,
+
+
+        /** ------------------ 存钱罐数据 ----------------------------- */
+
+
+        /** ------------------ 签到数据 ----------------------------- */
+        /** 上次签到进度 */
+        sign_last_bar: 120,
+        /** 当前能否签到 */
+        sign_can: 121,
+    }
+}
+
+declare global {
+    const GEnum: GEnum;
 }
 }
+window['GEnum'] = new GEnum();

+ 3 - 6
assets/script/game/data/g.ts

@@ -15,14 +15,13 @@ import { FissionData } from "./module/FissionData";
 import { LuckyBagData } from "./module/LuckyBagData";
 import { LuckyBagData } from "./module/LuckyBagData";
 import { CashNormalData } from "./module/CashNormalData";
 import { CashNormalData } from "./module/CashNormalData";
 import { CashPigData } from "./module/CashPigData";
 import { CashPigData } from "./module/CashPigData";
-import { EnumData } from "./EnumData";
 
 
 /**
 /**
  * 数据集合全局类
  * 数据集合全局类
  * @description 所有数据都通过这个类创建,修改,删除
  * @description 所有数据都通过这个类创建,修改,删除
  * @author 邹勇
  * @author 邹勇
  */
  */
-class g {
+class GData {
     constructor() {
     constructor() {
         this.init();
         this.init();
     }
     }
@@ -33,7 +32,6 @@ class g {
     public wechatData: WechatData;
     public wechatData: WechatData;
     public httpData: HttpData;
     public httpData: HttpData;
     public adData: AdData;
     public adData: AdData;
-    public enum: EnumData;
     public storageData: StorageData;
     public storageData: StorageData;
 
 
     //module
     //module
@@ -54,7 +52,6 @@ class g {
         this.wechatData = new WechatData();
         this.wechatData = new WechatData();
         this.httpData = new HttpData();
         this.httpData = new HttpData();
         this.adData = new AdData();
         this.adData = new AdData();
-        this.enum = new EnumData();
         this.storageData = new StorageData();
         this.storageData = new StorageData();
 
 
         this.help = new HelpData();
         this.help = new HelpData();
@@ -85,9 +82,9 @@ export enum Fun {
 }
 }
 
 
 declare global {
 declare global {
-    const g: g;
+    const gData: GData;
 }
 }
-window['g'] = new g();
+window['gData'] = new GData();
 
 
 
 
 
 

+ 22 - 22
assets/script/game/data/module/SignData.ts

@@ -6,27 +6,27 @@ export class SignData {
     /** 标志位:是否需要刷新数据 */
     /** 标志位:是否需要刷新数据 */
     public init_data: boolean = false;
     public init_data: boolean = false;
 
 
-    /** 签到配置 */
+    /** 配置数据 签到 */
     public c_sign = [];
     public c_sign = [];
 
 
-    // 假数据 当前签到天数
-    private _cur_sign_day = 3;
-    set cur_sign_day(value: number) {
-        this._cur_sign_day = value;
+    // 服务端数据 上次签到天数
+    private _sign_last_bar = 3;
+    set sign_last_bar(value: number) {
+        this._sign_last_bar = value;
         this.init_data = true;
         this.init_data = true;
     }
     }
-    get cur_sign_day(): number {
-        return this._cur_sign_day;
+    get sign_last_bar(): number {
+        return this._sign_last_bar;
     }
     }
 
 
-    // 数据 能够签到
-    private _can_sign = 1;
-    set can_sign(value: number) {
-        this._can_sign = value;
+    // 服务端数据 能够签到
+    private _sign_can = 1;
+    set sign_can(value: number) {
+        this._sign_can = value;
         this.init_data = true;
         this.init_data = true;
     }
     }
-    get can_sign(): number {
-        return this._can_sign;
+    get sign_can(): number {
+        return this._sign_can;
     }
     }
 
 
     /** 签到列表数据 */
     /** 签到列表数据 */
@@ -62,24 +62,24 @@ export class SignData {
         }
         }
         return c_sign;
         return c_sign;
     }
     }
-    
+
     /**
     /**
      * 获取奖励状态
      * 获取奖励状态
      * @param login_day 登陆日 
      * @param login_day 登陆日 
      * @returns 状态123
      * @returns 状态123
      */
      */
     public getStateByDay(login_day: number) {
     public getStateByDay(login_day: number) {
-        let _state = g.enum.rewardState.none;
-        if (login_day < this.cur_sign_day) {
-            _state = g.enum.rewardState.none;
-        } else if (login_day == this.cur_sign_day) {
-            if (!this.can_sign) {
-                _state = g.enum.rewardState.none;
+        let _state = GEnum.rewardState.none;
+        if (login_day <= this.sign_last_bar) {
+            _state = GEnum.rewardState.none;
+        } else if (login_day == (this.sign_last_bar + 1)) {
+            if (!this.sign_can) {
+                _state = GEnum.rewardState.none;
             } else {
             } else {
-                _state = g.enum.rewardState.unlock;
+                _state = GEnum.rewardState.unlock;
             }
             }
         } else {
         } else {
-            _state = g.enum.rewardState.lock;
+            _state = GEnum.rewardState.lock;
         }
         }
         return _state;
         return _state;
     }
     }

+ 13 - 2
assets/script/game/module/module/sign/Sign.ts

@@ -1,5 +1,10 @@
+import { GameProp } from "../../../data/GameData";
+
 /**
 /**
  * 签到界面
  * 签到界面
+ * - 每天第一次上线默认弹出一次【除首日】
+ * - 全部签完后,不可再签到。此处需要判断上次签到天数。
+ * - 签到数据几点刷新?什么方式刷新? 与后端沟通
  * @author 薛鸿潇
  * @author 薛鸿潇
  */
  */
 const { ccclass, property } = cc._decorator;
 const { ccclass, property } = cc._decorator;
@@ -17,6 +22,7 @@ export default class Sign extends cc.Component {
     }
     }
 
 
     start() {
     start() {
+        g.sign.sign_can = g.gameData.getProp(GEnum.GameProp.sign_can)
         g.sign.initListData();
         g.sign.initListData();
         g.sign.init_data = true;
         g.sign.init_data = true;
     }
     }
@@ -33,8 +39,9 @@ export default class Sign extends cc.Component {
      * 点击领取按钮
      * 点击领取按钮
      */
      */
     private clickReceiveReward() {
     private clickReceiveReward() {
-        g.sign.can_sign = 0;
+        g.sign.sign_can = 0;
     }
     }
+
     update(dt) {
     update(dt) {
         if (g.sign.init_data) {
         if (g.sign.init_data) {
             g.sign.init_data = false;
             g.sign.init_data = false;
@@ -42,8 +49,12 @@ export default class Sign extends cc.Component {
             this.initBtnStyle();
             this.initBtnStyle();
         }
         }
     }
     }
+
+    /**
+     * 初始化按钮样式
+     */
     private initBtnStyle() {
     private initBtnStyle() {
-        if (g.sign.can_sign) {
+        if (g.sign.sign_can) {
             this.anim_btn.play();
             this.anim_btn.play();
             this.anim_btn.getComponent('SetGray').setGray(false);
             this.anim_btn.getComponent('SetGray').setGray(false);
         } else {
         } else {

+ 4 - 5
assets/script/game/module/module/sign/SignIconItem.ts

@@ -5,7 +5,6 @@ const { ccclass, property } = cc._decorator;
  * @author 薛鸿潇
  * @author 薛鸿潇
  * - 红包icon:用红包样式
  * - 红包icon:用红包样式
  * - 现金、金猪现金:用提现样式
  * - 现金、金猪现金:用提现样式
- * 签到数据几点刷新?什么方式刷新? 与后端沟通
  */
  */
 @ccclass
 @ccclass
 export default class SignIconItem extends cc.Component {
 export default class SignIconItem extends cc.Component {
@@ -30,7 +29,7 @@ export default class SignIconItem extends cc.Component {
         count: 0,
         count: 0,
         login_day: 0,
         login_day: 0,
         video_limit: 0,
         video_limit: 0,
-        state: g.enum.rewardState.none,
+        state: GEnum.rewardState.none,
     }
     }
 
 
     /**
     /**
@@ -63,14 +62,14 @@ export default class SignIconItem extends cc.Component {
 
 
         // 状态样式
         // 状态样式
         let state = g.sign.getStateByDay(icon_data.login_day);
         let state = g.sign.getStateByDay(icon_data.login_day);
-        if (state == g.enum.rewardState.none) {
+        if (state == GEnum.rewardState.none) {
             this.node_mask.active = true;
             this.node_mask.active = true;
             this.node_gou.active = true;
             this.node_gou.active = true;
             this.node_money.active = false;
             this.node_money.active = false;
-        } else if (state == g.enum.rewardState.unlock) {
+        } else if (state == GEnum.rewardState.unlock) {
             this.node_mask.active = false;
             this.node_mask.active = false;
             this.node_gou.active = false;
             this.node_gou.active = false;
-        } else if (state == g.enum.rewardState.lock) {
+        } else if (state == GEnum.rewardState.lock) {
             this.node_mask.active = false;
             this.node_mask.active = false;
             this.node_gou.active = false;
             this.node_gou.active = false;
         }
         }