AbilityInfoService.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s,
  5. o =
  6. (this && this.__decorate) ||
  7. function (t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", {value: !0}), (i.PayAbilityType = void 0);
  18. const a = t("App"),
  19. n = t("Toast"),
  20. r = t("ControllerConst"),
  21. l = (t("PlatformBase"), t("AdRewardConst")),
  22. h = t("AbilityInfoData"),
  23. c = t("GlobalAttr"),
  24. d = t("BaseService"),
  25. u = t("CurrencyService");
  26. let p = null;
  27. var f,
  28. {ccclass: e} = cc._decorator,
  29. t = (s = class extends d.default {
  30. constructor() {
  31. super(...arguments),
  32. (this.define = null),
  33. (this.datas = null),
  34. (this.dataMap = {}),
  35. (this.cfgs = null),
  36. (this.saveData = null);
  37. }
  38. onLoad() {
  39. (s.ins = this).cfgs = a.default.ConfigManager.getConfig("AbilityInfo");
  40. }
  41. unlockAll() {
  42. this.datas.concat();
  43. }
  44. unlockAbility(t, e = 0) {
  45. const i = this.dataMap[t];
  46. return i.canUnlock()
  47. ? (i.unlock(),
  48. this.updateData(i.cfg.idx),
  49. u.default.ins.diamondChange(-i.installCost),
  50. a.default.AnalyticMgr.recordDiamondCost(4, -i.installCost),
  51. !0)
  52. : (n.default.launch("钻石不足!"), !1);
  53. }
  54. updateData(t) {
  55. switch (t) {
  56. case f.get_tips_chance:
  57. p.calTipChance();
  58. break;
  59. case f.gems_chance_at_ad:
  60. p.calGemsChanceAtAd();
  61. break;
  62. case f.ad_booster_effect:
  63. p.calAdBoosterEffect(),
  64. a.default.ControllerManager.applyFunc(
  65. r.ControllerConst.AdReward,
  66. l.AdRewardConst.UPDATE_AD_RATE
  67. );
  68. break;
  69. case f.offline_revenue:
  70. p.calOfflineRevenue();
  71. break;
  72. case f.tips_rate:
  73. p.calTipRate();
  74. break;
  75. case f.offline_reward_time:
  76. p.calOfflineRewardTime();
  77. break;
  78. case f.ad_booster_duration:
  79. p.calAdBoosterDuration();
  80. break;
  81. case f.customer_move_speed:
  82. p.calCustomerMoveSpeed();
  83. break;
  84. case f.ad_reward_revenue:
  85. p.calAdRewardRevenue();
  86. }
  87. }
  88. lvUp(t, e = !1) {
  89. const i = this.dataMap[t];
  90. if (i.isMaxLevel()) return n.default.launch("已达最大等级!"), !1;
  91. if (i.canLvUp() || e) {
  92. const t = i.cost;
  93. return i.levelUp(), this.updateData(i.cfg.idx), u.default.ins.diamondChange(-t), !0;
  94. }
  95. return n.default.launch("钻石不足!"), !1;
  96. }
  97. init() {
  98. var e = this.cfgs;
  99. this.datas = [];
  100. const i = a.default.ControllerManager.getControllerModel(r.ControllerConst.Game);
  101. i.data.AbilityInfo || (i.data.AbilityInfo = []), (this.saveData = i.data.AbilityInfo);
  102. var s = e.length;
  103. for (let t = 0; t < s; t++) {
  104. const i = new h.default();
  105. (this.datas[t] = i),
  106. (this.dataMap[e[t].idx] = i),
  107. this.saveData[t] || (this.saveData[t] = {lv: 0}),
  108. i.init(e[t], this.saveData[t]);
  109. }
  110. p = c.default.ins;
  111. }
  112. desotrySelf() {}
  113. });
  114. (t.ins = null),
  115. (t = s = o([e], t)),
  116. (i.default = t = s),
  117. ((i = f = i.PayAbilityType || (i.PayAbilityType = {}))[(i.get_tips_chance = 1)] = "get_tips_chance"),
  118. (i[(i.gems_chance_at_ad = 2)] = "gems_chance_at_ad"),
  119. (i[(i.ad_booster_effect = 3)] = "ad_booster_effect"),
  120. (i[(i.offline_revenue = 4)] = "offline_revenue"),
  121. (i[(i.tips_rate = 5)] = "tips_rate"),
  122. (i[(i.offline_reward_time = 6)] = "offline_reward_time"),
  123. (i[(i.ad_booster_duration = 7)] = "ad_booster_duration"),
  124. (i[(i.customer_move_speed = 8)] = "customer_move_speed"),
  125. (i[(i.ad_reward_revenue = 9)] = "ad_reward_revenue");