| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import { Data } from "../../../mk/data/Data";
- import GuideWeak from "../../module/guideWeak/GuideWeak";
- /**
- * 弱引导数据
- * - 主界面-弱引导
- 1. 弱引导启动:用户在主界面超过10秒未操作【配置】。
- 2. 弱引导效果:自动弹出以下界面中的一种:气泡红包界面、福袋界面、互推界面……【配置】
- 3. 配置需支持配置界面ID和对应的弹出概率。
- - 关卡界面-弱引导
- 1. 弱引导启动:用户在关卡界面超过10秒未操作【配置】。
- 2. 弱引导效果:自动弹出以下界面中的一种:气泡红包界面、福袋界面、互推界面……【配置】
- 3. 配置需支持配置界面ID和对应的弹出概率。
- * @author 薛鸿潇
- */
- export default class GuideWeakData {
- /**
- * 数据初始化
- */
- public init() {
- // this.data_config = data_config;
- if (gData.gameData.configs.ServerConfig.triggerTime)
- this.data_config.triggerTime = parseInt(gData.gameData.configs.ServerConfig.triggerTime);
- if (gData.gameData.configs.ServerConfig.panelWeight) {
- // 8:70,5:30
- this.data_config.panelWeight = {}
- let new_weight = gData.gameData.configs.ServerConfig.panelWeight.split(',')
- for (let i = 0; i < new_weight.length; i++) {
- const item_str = new_weight[i].split(':');
- this.data_config.panelWeight[item_str[0]] = parseInt(item_str[1]);
- }
- }
- }
- /**
- * 星云数据配置
- * - 面板权重
- * - 触发时间
- */
- public data_config = {
- panelWeight: {
- },
- triggerTime: 5
- }
- /** 功能是否启动 */
- public enable: boolean = false;
- /** 引导正在运行 */
- /** 样式类 */
- public guideStyle: GuideWeak = null;
- /**
- * 玩家静默时间
- * - 即:未进行任何操作的时间
- */
- public silent_time: number = 0;
- /** 当前打开的界面id */
- public cur_guide_id: number = 0;
- /** 当前打开的界面名字 */
- public cur_guide_panel: string = null;
- public initGuideId() {
- // 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
- if (gData.gameData.funBtns['btn' + panel_id])
- gData.gameData.funBtns['btn' + panel_id].emit('click')
- }
- public panel_name_config = {
- moreGame: 1,
- turnable: 2,
- none: 3,
- pigBank: 4,
- blessingBag: 5,
- sign: 6,
- redBagCash: 7,
- rewardLuck: 8,
- }
- }
|