GuideWeakData.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { Data } from "../../../mk/data/Data";
  2. import GuideWeak from "../../module/guideWeak/GuideWeak";
  3. /**
  4. * 弱引导数据
  5. * - 主界面-弱引导
  6. 1. 弱引导启动:用户在主界面超过10秒未操作【配置】。
  7. 2. 弱引导效果:自动弹出以下界面中的一种:气泡红包界面、福袋界面、互推界面……【配置】
  8. 3. 配置需支持配置界面ID和对应的弹出概率。
  9. - 关卡界面-弱引导
  10. 1. 弱引导启动:用户在关卡界面超过10秒未操作【配置】。
  11. 2. 弱引导效果:自动弹出以下界面中的一种:气泡红包界面、福袋界面、互推界面……【配置】
  12. 3. 配置需支持配置界面ID和对应的弹出概率。
  13. * @author 薛鸿潇
  14. */
  15. export default class GuideWeakData {
  16. /**
  17. * 数据初始化
  18. */
  19. public init() {
  20. // this.data_config = data_config;
  21. if (gData.gameData.configs.ServerConfig.triggerTime)
  22. this.data_config.triggerTime = gData.gameData.configs.ServerConfig.triggerTime;
  23. if (gData.gameData.configs.ServerConfig.panelWeight) {
  24. }
  25. }
  26. /**
  27. * 星云数据配置
  28. * - 面板权重
  29. * - 触发时间
  30. */
  31. public data_config = {
  32. panelWeight: {
  33. "1": 10,
  34. "2": 10,
  35. "4": 10,
  36. "5": 10,
  37. "6": 10,
  38. "7": 10
  39. },
  40. triggerTime: 5
  41. }
  42. /** 功能是否启动 */
  43. public enable: boolean = false;
  44. /** 引导正在运行 */
  45. /** 样式类 */
  46. public guideStyle: GuideWeak = null;
  47. /**
  48. * 玩家静默时间
  49. * - 即:未进行任何操作的时间
  50. */
  51. public silent_time: number = 0;
  52. /** 当前打开的界面id */
  53. public cur_guide_id: number = 0;
  54. /** 当前打开的界面名字 */
  55. public cur_guide_panel: string = null;
  56. public initGuideId() {
  57. // gData.guideWeakData.cur_guide_id = 1 + 1;
  58. const panelWeight = this.data_config.panelWeight;
  59. let p_count = 0;
  60. let total_weight = 0;
  61. for (const key in panelWeight) {
  62. total_weight += panelWeight[key];
  63. p_count++;
  64. }
  65. /** 累计零时权重 */
  66. let temp_weight_sum = 0;
  67. // 根据奖池权重随机物品
  68. let random = mk.math.random(1, total_weight);
  69. for (const key in panelWeight) {
  70. temp_weight_sum += panelWeight[key];
  71. if (random < temp_weight_sum) {
  72. // 中奖了
  73. gData.guideWeakData.cur_guide_id = parseInt(key);
  74. break;
  75. }
  76. }
  77. }
  78. public openPanelByBtn() {
  79. const panel_id = gData.guideWeakData.cur_guide_id
  80. gData.gameData.funBtns['btn' + panel_id].emit('click')
  81. }
  82. public panel_name_config = {
  83. moreGame: 1,
  84. turnable: 2,
  85. none: 3,
  86. pigBank: 4,
  87. blessingBag: 5,
  88. sign: 6,
  89. redBagCash: 7,
  90. }
  91. }