Pārlūkot izejas kodu

弱引导权重添加

薛鸿潇 5 gadi atpakaļ
vecāks
revīzija
25e541fec2

+ 12 - 0
assets/resources/data/guide_weak_data.json

@@ -0,0 +1,12 @@
+{
+	"panelWeight": {
+		"1": 10,
+		"2": 10,
+		"4": 10,
+		"5": 10,
+		"6": 10,
+		"7": 10,
+		"8": 10
+	},
+	"triggerTime": 10
+}

+ 5 - 0
assets/resources/data/guide_weak_data.json.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "1.0.0",
+  "uuid": "6395adfa-2f63-47cf-9b41-4641bb2d41e1",
+  "subMetas": {}
+}

+ 6 - 118
assets/resources/module/guideWeak/GuideWeak.prefab

@@ -16,81 +16,13 @@
     "_name": "GuideWeak",
     "_objFlags": 0,
     "_parent": null,
-    "_children": [
-      {
-        "__id__": 2
-      }
-    ],
+    "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 5
+        "__id__": 2
       },
       {
-        "__id__": 6
-      }
-    ],
-    "_prefab": {
-      "__id__": 7
-    },
-    "_opacity": 255,
-    "_color": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_contentSize": {
-      "__type__": "cc.Size",
-      "width": 750,
-      "height": 1334
-    },
-    "_anchorPoint": {
-      "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
-    },
-    "_trs": {
-      "__type__": "TypedArray",
-      "ctor": "Float64Array",
-      "array": [
-        0,
-        0,
-        0,
-        0,
-        0,
-        0,
-        1,
-        1,
-        1,
-        1
-      ]
-    },
-    "_eulerAngles": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
-      "z": 0
-    },
-    "_skewX": 0,
-    "_skewY": 0,
-    "_is3DNode": false,
-    "_groupIndex": 0,
-    "groupIndex": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.Node",
-    "_name": "New Label",
-    "_objFlags": 0,
-    "_parent": {
-      "__id__": 1
-    },
-    "_children": [],
-    "_active": true,
-    "_components": [
-      {
         "__id__": 3
       }
     ],
@@ -107,8 +39,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 240,
-      "height": 50.4
+      "width": 750,
+      "height": 1334
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -119,8 +51,8 @@
       "__type__": "TypedArray",
       "ctor": "Float64Array",
       "array": [
-        0,
-        611.691,
+        375,
+        667,
         0,
         0,
         0,
@@ -145,50 +77,6 @@
     "_id": ""
   },
   {
-    "__type__": "cc.Label",
-    "_name": "",
-    "_objFlags": 0,
-    "node": {
-      "__id__": 2
-    },
-    "_enabled": true,
-    "_materials": [
-      {
-        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
-      }
-    ],
-    "_srcBlendFactor": 770,
-    "_dstBlendFactor": 771,
-    "_string": "弱引导运行中",
-    "_N$string": "弱引导运行中",
-    "_fontSize": 40,
-    "_lineHeight": 40,
-    "_enableWrapText": true,
-    "_N$file": null,
-    "_isSystemFontUsed": true,
-    "_spacingX": 0,
-    "_batchAsBitmap": false,
-    "_styleFlags": 1,
-    "_underlineHeight": 0,
-    "_N$horizontalAlign": 1,
-    "_N$verticalAlign": 1,
-    "_N$fontFamily": "Arial",
-    "_N$overflow": 0,
-    "_N$cacheMode": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.PrefabInfo",
-    "root": {
-      "__id__": 1
-    },
-    "asset": {
-      "__uuid__": "ba2e33b2-5a64-424b-8b08-247fed4be0f0"
-    },
-    "fileId": "9bpVbHl+FJeqHz4I/c2T/+",
-    "sync": false
-  },
-  {
     "__type__": "cc.Widget",
     "_name": "",
     "_objFlags": 0,

+ 0 - 1
assets/script/game/component/BtnClosePanel.ts

@@ -30,7 +30,6 @@ export default class BtnClosePanel extends cc.Component {
     private async closePanel() {
         mk.audio.playEffect("button");
         if (this.block_click) return;
-        cc.log(111)
         if (this.node_panel) {
             mk.ui.closePanel(this.node_panel.name);
             mk.event.emit('close-panel', this.node_panel.name);

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

@@ -68,6 +68,7 @@ export class GameData {
         this.initPlayerProp(response.data)
         this.initProps(response.data.gameUserData);
         gData.guideData.init();
+        gData.guideWeakData.init();
         gData.moduleData.forEach(element => {
             element.init();
         });

+ 38 - 8
assets/script/game/data/module/GuideWeakData.ts

@@ -12,16 +12,30 @@ import GuideWeak from "../../module/guideWeak/GuideWeak";
     3. 配置需支持配置界面ID和对应的弹出概率。
  * @author 薛鸿潇
  */
-export default class GuideWeakData extends Data {
+export default class GuideWeakData {
 
     /**
      * 数据初始化
      */
     public init() {
-
+        // this.data_config = data_config;
+    }
+    /**
+     * 星云数据配置
+     * - 面板权重
+     * - 触发时间
+     */
+    public data_config = {
+        "panelWeight": {
+            "1": 10,
+            "2": 10,
+            "4": 10,
+            "5": 10,
+            "6": 10,
+            "7": 10
+        },
+        "triggerTime": 5
     }
-    /** 测试配置 */
-    public test_config = [1, 2, 3]
     /** 功能是否启动 */
     public enable: boolean = false;
     /** 引导正在运行 */
@@ -35,16 +49,32 @@ export default class GuideWeakData extends Data {
      */
     public silent_time: number = 0;
 
-    /** 弱引导触发时间 */
-    public check_time: number = 10;
-
     /** 当前打开的界面id */
     public cur_guide_id: number = 0;
     /** 当前打开的界面名字 */
     public cur_guide_panel: string = null;
 
     public initGuideId() {
-        gData.guideWeakData.cur_guide_id = 1 + 1;
+        // gData.guideWeakData.cur_guide_id = 1 + 1;
+        const panelWeight = this.data_config.panelWeight;
+        let p_count = 0;
+        let total_weight = 0;
+        for (const key in panelWeight) {
+            total_weight += panelWeight[key];
+            p_count++;
+        }
+        /** 累计零时权重 */
+        let temp_weight_sum = 0;
+        // 根据奖池权重随机物品
+        let random = mk.math.random(1, total_weight);
+        for (const key in panelWeight) {
+            temp_weight_sum += panelWeight[key];
+            if (random < temp_weight_sum) {
+                // 中奖了
+                gData.guideWeakData.cur_guide_id = parseInt(key);
+                break;
+            }
+        }
     }
     public openPanelByBtn() {
         const panel_id = gData.guideWeakData.cur_guide_id

+ 2 - 2
assets/script/game/module/guideWeak/GuideWeak.ts

@@ -17,7 +17,7 @@ export default class GuideWeak extends cc.Component {
         if (gData.guideWeakData.cur_guide_id) return;
 
         gData.guideWeakData.silent_time += dt;
-        if (gData.guideWeakData.silent_time >= gData.guideWeakData.check_time) {
+        if (gData.guideWeakData.silent_time >= gData.guideWeakData.data_config.triggerTime) {
             gData.guideWeakData.initGuideId();
             gData.guideWeakData.openPanelByBtn();
         }
@@ -37,7 +37,7 @@ export default class GuideWeak extends cc.Component {
         cc.log('弱引导计时重置');
         gData.guideWeakData.silent_time = 0;
     }
-    
+
     ///////////////// 自定义触摸监听 /////////////////
     private _eventManager = cc["internal"]["eventManager"];
     private _touchListener: any;