AbilityViewItem.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function(t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", { value: !0 });
  17. const o = t("App"),
  18. a = t("GameText"),
  19. n = (t("ViewConst"), t("GlobalAttr")),
  20. r = t("AbilityInfoService"),
  21. { ccclass: s, property: l, menu: h } = cc._decorator;
  22. t = class extends cc.Component {
  23. constructor() {
  24. super(...arguments),
  25. (this.lockNode = null),
  26. (this.lockDescNode = null),
  27. (this.lockIconSpr = null),
  28. (this.unlockBtn = null),
  29. (this.unlockBtnLab = null),
  30. (this.unlockIcon = null),
  31. (this.unlockNode = null),
  32. (this.lvLab = null),
  33. (this.descRichText = null),
  34. (this.rateRichText = null),
  35. (this.costLab = null),
  36. (this.costBtn = null),
  37. (this.maxLabNode = null),
  38. (this.iconSpr = null),
  39. (this.data = null);
  40. }
  41. setData(t) {
  42. (this.data = t).isUnlock() ?
  43. ((this.lockNode.active = !1), (this.unlockNode.active = !0), this.updateUI()) :
  44. ((this.lockNode.active = !0),
  45. (this.unlockNode.active = !1),
  46. o.default.CommonUtils.setSpriteFrame(this.data.getAvilityLockIconUrl(), this.lockIconSpr));
  47. }
  48. showUnlockBtn() {
  49. (this.unlockBtn.active = !0),
  50. (this.lockDescNode.active = !1),
  51. 0 === this.data.cfg.unlock_cost ?
  52. ((this.unlockIcon.active = !1), (this.unlockBtnLab.string = "免费"), (this.unlockBtnLab.node.x = 0)) :
  53. (this.unlockBtnLab.string = this.data.cfg.unlock_cost.toString());
  54. }
  55. updateUI() {
  56. (this.lvLab.string = `Level ${this.data.curLevel}`),
  57. o.default.CommonUtils.setSpriteFrame(this.data.getAvilityIconUrl(), this.iconSpr),
  58. (this.costLab.string = this.data.cost.toString());
  59. var t = this.data.isMaxLevel();
  60. (this.costBtn.active = !t), (this.maxLabNode.active = t);
  61. let e = this.data.value,
  62. i = this.data.nextLvValue;
  63. this.data.cfg.idx == r.PayAbilityType.ad_booster_effect &&
  64. ((i = Math.floor(i - e + 100 * n.default.ins.ad_booster_effect) / 100),
  65. (e = n.default.ins.ad_booster_effect));
  66. let s = "X";
  67. this.data.cfg.idx == r.PayAbilityType.get_tips_chance || this.data.cfg.idx == r.PayAbilityType.gems_chance_at_ad ?
  68. (s = "%") :
  69. this.data.cfg.idx != r.PayAbilityType.ad_booster_effect && ((e /= 100), (i /= 100)),
  70. (this.descRichText.string = a.GameText.getTextByStr(this.data.cfg.desc).format(e)),
  71. t ?
  72. ((this.rateRichText.node.active = !1), (this.descRichText.node.y = -42)) :
  73. (this.rateRichText.string = `<b><color=#aa5252>${e}${s}></c><color=#f25d6b>${i}${s}</color></b>`);
  74. }
  75. onTouchCostBtn() {
  76. r.default.ins.lvUp(this.data.cfg.idx) && this.updateUI();
  77. }
  78. onTouchUnlockBtn() {
  79. if (r.default.ins.unlockAbility(this.data.cfg.idx)) {
  80. (this.lockNode.active = !1), (this.unlockNode.active = !0), this.updateUI();
  81. let t = o.default.ViewManager.getView(22);
  82. t && t.updateUI();
  83. }
  84. }
  85. };
  86. e([l(cc.Node)], t.prototype, "lockNode", void 0),
  87. e([l(cc.Node)], t.prototype, "lockDescNode", void 0),
  88. e([l(cc.Sprite)], t.prototype, "lockIconSpr", void 0),
  89. e([l(cc.Node)], t.prototype, "unlockBtn", void 0),
  90. e([l(cc.Label)], t.prototype, "unlockBtnLab", void 0),
  91. e([l(cc.Node)], t.prototype, "unlockIcon", void 0),
  92. e([l(cc.Node)], t.prototype, "unlockNode", void 0),
  93. e([l(cc.Label)], t.prototype, "lvLab", void 0),
  94. e([l(cc.RichText)], t.prototype, "descRichText", void 0),
  95. e([l(cc.RichText)], t.prototype, "rateRichText", void 0),
  96. e([l(cc.Label)], t.prototype, "costLab", void 0),
  97. e([l(cc.Node)], t.prototype, "costBtn", void 0),
  98. e([l(cc.Node)], t.prototype, "maxLabNode", void 0),
  99. e([l(cc.Sprite)], t.prototype, "iconSpr", void 0),
  100. (t = e([s], t)),
  101. (i.default = t);