Selaa lähdekoodia

[FC][v2.0.1]红包倒计时功能

fengcong 4 vuotta sitten
vanhempi
commit
f39fd1d93e
24 muutettua tiedostoa jossa 2264 lisäystä ja 226 poistoa
  1. BIN
      assets/res/game/ui/common/tip_bg.png
  2. 36 0
      assets/res/game/ui/common/tip_bg.png.meta
  3. 917 79
      assets/resources/game/prefab/game.prefab
  4. 657 111
      assets/resources/game/prefab/gameplay.prefab
  5. 5 0
      assets/script/game/data/GData.ts
  6. 1 1
      assets/script/game/data/HttpData.ts
  7. 1 0
      assets/script/game/data/LoginData.ts
  8. 131 0
      assets/script/game/data/module/RedBagData.ts
  9. 9 0
      assets/script/game/data/module/RedBagData.ts.meta
  10. 12 0
      assets/script/game/module/redBagItem.meta
  11. 120 0
      assets/script/game/module/redBagItem/RedBagItem.ts
  12. 9 0
      assets/script/game/module/redBagItem/RedBagItem.ts.meta
  13. BIN
      build/jsb-link/assets/main/index.jsc
  14. 0 0
      build/jsb-link/assets/resources/config.json
  15. 0 0
      build/jsb-link/assets/resources/import/4c/4c49ec9e-c64a-4921-84eb-9bdd737656e5.json
  16. 1 0
      build/jsb-link/assets/resources/import/5f/5f0578bd-beaf-4dd3-9ca6-84385c863c66.json
  17. 1 0
      build/jsb-link/assets/resources/import/a1/a1af2f71-6f88-496f-9cce-30ff329bd195.json
  18. 0 0
      build/jsb-link/assets/resources/import/b4/b4dea4a9-29c8-46bc-a50d-5754afa7a2bd.json
  19. BIN
      build/jsb-link/assets/resources/native/5f/5f0578bd-beaf-4dd3-9ca6-84385c863c66.png
  20. 1 1
      build/jsb-link/assets/resources/native/9e/9ed98385-f23f-41b7-a2bc-27a1d4ad9fd6.manifest
  21. 0 0
      build/jsb-link/assets/resources/native/a8/a81eb395-718d-4f3b-958c-cb871f7dd5fa.manifest
  22. BIN
      build/jsb-link/frameworks/runtime-src/proj.android-studio/app/release/EasyEliminate-release.apk
  23. 360 31
      build/jsb-link/js backups (useful for debugging)/main.index.js
  24. 3 3
      packages-hot-update/cfg.json

BIN
assets/res/game/ui/common/tip_bg.png


+ 36 - 0
assets/res/game/ui/common/tip_bg.png.meta

@@ -0,0 +1,36 @@
+{
+  "ver": "2.3.5",
+  "uuid": "5f0578bd-beaf-4dd3-9ca6-84385c863c66",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "genMipmaps": false,
+  "packable": true,
+  "width": 262,
+  "height": 148,
+  "platformSettings": {},
+  "subMetas": {
+    "tip_bg": {
+      "ver": "1.0.4",
+      "uuid": "a1af2f71-6f88-496f-9cce-30ff329bd195",
+      "rawTextureUuid": "5f0578bd-beaf-4dd3-9ca6-84385c863c66",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": 0,
+      "offsetY": 0,
+      "trimX": 0,
+      "trimY": 0,
+      "width": 262,
+      "height": 148,
+      "rawWidth": 262,
+      "rawHeight": 148,
+      "borderTop": 18,
+      "borderBottom": 61,
+      "borderLeft": 110,
+      "borderRight": 29,
+      "subMetas": {}
+    }
+  }
+}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 917 - 79
assets/resources/game/prefab/game.prefab


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 657 - 111
assets/resources/game/prefab/gameplay.prefab


+ 5 - 0
assets/script/game/data/GData.ts

@@ -27,6 +27,7 @@ import SafeDepositBoxData from "./module/SafeDepositBoxData";
 import TipPanelDta from "./module/TipPanelData";
 import GuideToWxData from "./module/GuideToWxData";
 import WarnTipData from "./module/WarnTipData";
+import RedBagData from "./module/RedBagData";
 
 /**
  * 数据集合全局类
@@ -78,6 +79,9 @@ class GData {
     public guideToWxData: GuideToWxData;
     public warnTipData: WarnTipData;
 
+    /**气泡红包数据 */
+    public redBagData: RedBagData;
+
     public moduleData: Map<number, Data>;
 
     init() {
@@ -110,6 +114,7 @@ class GData {
         this.tipPanelData = new TipPanelDta();
         this.guideToWxData = new GuideToWxData();
         this.warnTipData = new WarnTipData();
+        this.redBagData = new RedBagData();
 
         this.moduleData = new Map<number, Data>();
         this.moduleData.set(Fun.moreGame, this.moreGame);

+ 1 - 1
assets/script/game/data/HttpData.ts

@@ -5,7 +5,7 @@
 export class HttpData {
 
     /** 服务器类型 0测试服 1正式服 2李扬服 3悍国服 */
-    public serverType: number = 1;
+    public serverType: number = 0;
 
     public getServerUrl(): string {
         switch (this.serverType) {

+ 1 - 0
assets/script/game/data/LoginData.ts

@@ -278,6 +278,7 @@ export class LoginData {
             "appVersion": gData.appData.appVersion,
             "mac": gData.appData.machineInfo.mac,
             "login_ticket": this.loginTicket,
+            "tfChannel": gData.appData.tfChannel,
             "szlm_did": mk.shuzilmM.szlm_did,
             "black_box": mk.tongdunM.tdEquipID,
         };

+ 131 - 0
assets/script/game/data/module/RedBagData.ts

@@ -0,0 +1,131 @@
+// Learn TypeScript:
+//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
+// Learn Attribute:
+//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
+// Learn life-cycle callbacks:
+//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
+
+import { Timer } from "../../../mk/system/TimerSystem";
+import RedBagItem from "../../module/redBagItem/RedBagItem";
+
+const { ccclass, property } = cc._decorator;
+
+/**气泡数据 */
+@ccclass
+export default class RedBagData extends cc.Component {
+
+    /** 是否开启 */
+    public ifOpen: boolean = false;
+    /** 倒计时时间 */
+    public countTime: number = 300;
+    private storageKey_startCountTime: string = "startCountTime";
+    // LIFE-CYCLE CALLBACKS:
+
+    /** 是否初始化了 */
+    public ifInit: boolean = false;
+    /** 气泡红包列表 */
+    private redBagItemArr: RedBagItem[] = [];
+    /** 当前倒计时剩余时间 */
+    public curLeftTime: number = 0;
+
+    /**
+     *
+     */
+    constructor() {
+        super();
+    }
+
+    /**初始化 */
+    public init() {
+
+        if (this.ifInit) {
+            return;
+        }
+        console.log("===[v2.0.1] 初始化");
+        this.ifInit = true;
+        this.checkOfflineTime();
+    }
+
+    /** 检测离线时间 */
+    public checkOfflineTime() {
+        let curDate = new Date().getTime();
+        let lastDate = mk.storage.getStorage(this.storageKey_startCountTime);
+        console.log("===[v2.0.1] lastDat", lastDate);
+        if (lastDate) {
+            let gapTime = Math.floor((curDate - lastDate) * 0.001);
+            console.log("===[v2.0.1] gapTime", gapTime);
+            let leftTime = Math.floor(this.countTime - gapTime);
+            console.log("===[v2.0.1] leftTime", leftTime);
+            if (leftTime >= 5) {
+                this.curLeftTime = leftTime;
+                this.startCountDown(this.curLeftTime);
+            }
+            else {
+
+            }
+        }
+        else {
+
+        }
+    }
+
+    /** 添加进数组 */
+    public addRedBagItem(redBadItem: RedBagItem) {
+        this.redBagItemArr.push(redBadItem);
+    }
+
+    /** 从数组中移除 */
+    public removeRedBagItem(redBagItem: RedBagItem) {
+        if (this.redBagItemArr.length >= 1) {
+            let index = this.redBagItemArr.indexOf(redBagItem);
+            if (index != -1) {
+                this.redBagItemArr.splice(index, 1);
+            }
+        }
+        else {
+
+        }
+    }
+
+    /** 开始倒计时 */
+    public startCountDown(leftTime: number) {
+        this.curLeftTime = leftTime;
+        mk.tip.pop("气泡红包数据开始倒计时");
+        let date = new Date().getTime();
+        mk.storage.setStorage(this.storageKey_startCountTime, date);
+
+        this.schedule(this.countDown, 1);
+    }
+
+    /** 倒计时 */
+    countDown() {
+        let time = --this.curLeftTime;
+        if (time <= 0) {
+            this.curLeftTime = 0;
+            this.stopCountDown();
+            return;
+        }
+        let timeStr = mk.time.format(time, "m:s");
+        for (var i = 0; i < this.redBagItemArr.length; i++) {
+            let redBagItem: RedBagItem = this.redBagItemArr[i];
+            redBagItem.countDown(timeStr);
+        }
+    }
+
+    /** 结束倒计时 */
+    public stopCountDown() {
+        this.unschedule(this.countDown);
+        for (var i = 0; i < this.redBagItemArr.length; i++) {
+            let redBagItem: RedBagItem = this.redBagItemArr[i];
+            redBagItem.stopCountDown();
+        }
+    }
+
+    public showTip() {
+
+    }
+
+    public showNewTip(curIndex: number) {
+
+    }
+}

+ 9 - 0
assets/script/game/data/module/RedBagData.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "0e855b4c-1f56-4096-8fb4-4d6d8a38da81",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 12 - 0
assets/script/game/module/redBagItem.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.1.2",
+  "uuid": "ba568d86-9c49-4c82-a862-eec2eb59fb31",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 120 - 0
assets/script/game/module/redBagItem/RedBagItem.ts

@@ -0,0 +1,120 @@
+// Learn TypeScript:
+//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
+// Learn Attribute:
+//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
+// Learn life-cycle callbacks:
+//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
+
+import { OpenActionType } from "../../../mk/system/UISystem";
+import TimeUtil from "../../../mk/utils/TimeUtil";
+
+const { ccclass, property } = cc._decorator;
+
+@ccclass
+export default class RedBagItem extends cc.Component {
+
+    @property(cc.Label)
+    public label_tip: cc.Label = null;
+    @property(cc.Node)
+    public node_qipaoBg: cc.Node = null;
+    @property(cc.Node)
+    public node_tip: cc.Node = null;
+    @property(cc.Integer)
+    public index: number = 0;
+    @property({ displayName: '点击回调', tooltip: "点击时触发", type: cc.Component.EventHandler })
+    public onComplete: cc.Component.EventHandler[] = [];
+
+    /** 存储的key */
+    public stroageKey: string = "";
+
+    // LIFE-CYCLE CALLBACKS:
+
+    // onLoad () {}
+
+    start() {
+        this.node.on(cc.Node.EventType.TOUCH_START, this.onClick, this);
+
+        this.init();
+    }
+
+    // update (dt) {}
+
+    /** 初始化 */
+    init() {
+
+        //显示之后再初始化
+        gData.redBagData.init();
+
+        this.stroageKey = `RedBagItem${this.index}`
+        // this.reset();
+        let ifClicked = mk.storage.getStorage(this.stroageKey);
+        /** 有值 且 为1(0 也会被判定为有值) */
+        if (ifClicked && ifClicked == 1) {
+            this.hide();
+        }
+        else {
+            console.log("===[v2.0.1]", "RedBagItem active" + this.node.active + "inxdex:" + this.index);
+            gData.redBagData.addRedBagItem(this);
+        }
+    }
+
+    /** 重设 */
+    reset() {
+        mk.storage.setStorage(this.stroageKey, 0);
+    }
+
+    /** 被点击 */
+    async onClick() {
+        console.log("===[v2.0.1] 点击点击");
+        mk.tip.pop("点击气泡红包");
+
+        //如果未开启,则不操作
+        if (!gData.redBagData.ifOpen) {
+            await mk.ui.openPanel("module/reward/rewardLuck", OpenActionType.normal);
+            this.callBack();
+        }
+        else {
+            //倒计时未结束,则不操作
+            if (gData.redBagData.curLeftTime >= 1) {
+                mk.tip.pop("请等待倒计时结束之后领取红包");
+                return;
+            }
+            await mk.ui.openPanel("module/reward/rewardLuck", OpenActionType.normal);
+            this.callBack();
+
+            this.hide();
+            mk.storage.setStorage(this.stroageKey, 1);
+            gData.redBagData.removeRedBagItem(this);
+            gData.redBagData.startCountDown(gData.redBagData.countTime);
+        }
+    }
+
+    /** 倒计时 */
+    countDown(time: string) {
+        this.label_tip.string = time;
+        this.node.color = cc.Color.GRAY;
+        this.node_qipaoBg.color = cc.Color.GRAY;
+    }
+
+    /** 停止倒计时 */
+    stopCountDown() {
+        this.label_tip.string = "可领";
+        this.node.color = cc.Color.WHITE;
+        this.node_qipaoBg.color = cc.Color.WHITE;
+    }
+
+    /** 隐藏 */
+    hide() {
+        this.node.active = false;
+        if (this.node_tip.active) {
+            this.node_tip.active = false;
+        }
+    }
+
+    callBack() {
+        const c_count = this.onComplete.length;
+        for (let i = 0; i < c_count; i++) {
+            if (this.onComplete[i].handler) this.onComplete[i].emit([])
+        }
+    }
+}

+ 9 - 0
assets/script/game/module/redBagItem/RedBagItem.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "c9bb3d11-fc17-44af-ab69-2774acbf42b8",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

BIN
build/jsb-link/assets/main/index.jsc


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
build/jsb-link/assets/resources/config.json


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
build/jsb-link/assets/resources/import/4c/4c49ec9e-c64a-4921-84eb-9bdd737656e5.json


+ 1 - 0
build/jsb-link/assets/resources/import/5f/5f0578bd-beaf-4dd3-9ca6-84385c863c66.json

@@ -0,0 +1 @@
+[1,0,0,["cc.Texture2D"],0,["0,9729,9729,33071,33071,0,0,1",-1],[0],0,[],[],[]]

+ 1 - 0
build/jsb-link/assets/resources/import/a1/a1af2f71-6f88-496f-9cce-30ff329bd195.json

@@ -0,0 +1 @@
+[1,["5fBXi9vq9N05ymhDhchjxm"],["_textureSetter"],["cc.SpriteFrame"],0,[{"name":"tip_bg","rect":[0,0,262,148],"offset":[0,0],"originalSize":[262,148],"capInsets":[110,18,29,61]}],[0],0,[0],[0],[0]]

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
build/jsb-link/assets/resources/import/b4/b4dea4a9-29c8-46bc-a50d-5754afa7a2bd.json


BIN
build/jsb-link/assets/resources/native/5f/5f0578bd-beaf-4dd3-9ca6-84385c863c66.png


+ 1 - 1
build/jsb-link/assets/resources/native/9e/9ed98385-f23f-41b7-a2bc-27a1d4ad9fd6.manifest

@@ -1 +1 @@
-{"version":"1.0.8","packageUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/","remoteManifestUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/project.manifest","remoteVersionUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/version.manifest"}
+{"version":"1.0.9","packageUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/","remoteManifestUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/project.manifest","remoteVersionUrl":"https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/version.manifest"}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
build/jsb-link/assets/resources/native/a8/a81eb395-718d-4f3b-958c-cb871f7dd5fa.manifest


BIN
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/release/EasyEliminate-release.apk


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 360 - 31
build/jsb-link/js backups (useful for debugging)/main.index.js


+ 3 - 3
packages-hot-update/cfg.json

@@ -1,6 +1,6 @@
 {
     "version": "1.0.9",
-    "serverRootDir": "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/",
+    "serverRootDir": "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote/",
     "resourceRootDir": "D:\\App\\mk_framework\\build\\jsb-link",
     "genManifestDir": "",
     "hotAddressArray": [
@@ -18,7 +18,7 @@
         "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote5/",
         "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminate/baseRemote6/"
     ],
-    "buildTime": 1638276307585,
-    "genTime": 1638276307585,
+    "buildTime": 1638529122618,
+    "genTime": 1638529122618,
     "genVersion": null
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä