|
|
@@ -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
|