| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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.funOpenData[`${panel_id}`] == '1')
- 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,
- }
- }
|