ShopBankItem.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var 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. s =
  17. (this && this.__awaiter) ||
  18. function (t, n, r, l) {
  19. return new (r = r || Promise)(function (i, e) {
  20. function s(t) {
  21. try {
  22. a(l.next(t));
  23. } catch (t) {
  24. e(t);
  25. }
  26. }
  27. function o(t) {
  28. try {
  29. a(l.throw(t));
  30. } catch (t) {
  31. e(t);
  32. }
  33. }
  34. function a(t) {
  35. var e;
  36. t.done
  37. ? i(t.value)
  38. : ((e = t.value) instanceof r
  39. ? e
  40. : new r(function (t) {
  41. t(e);
  42. })
  43. ).then(s, o);
  44. }
  45. a((l = l.apply(t, n || [])).next());
  46. });
  47. };
  48. Object.defineProperty(i, "__esModule", {value: !0}), (i.ShopBankItem = void 0);
  49. const o = t("App"),
  50. a = t("GameText"),
  51. n = t("EffectUtils"),
  52. r = t("ControllerConst"),
  53. l = t("NotificationConst"),
  54. h = (t("ViewConst"), t("BagController")),
  55. c = t("GlobalAttr"),
  56. d = t("ShopConst"),
  57. {property: u, ccclass: p, menu: f} = cc._decorator;
  58. t = class extends cc.Component {
  59. constructor() {
  60. super(...arguments),
  61. (this.ani = null),
  62. (this.arrowAni = null),
  63. (this.bubbleAni = null),
  64. (this.targetNode = null),
  65. (this.diamondLab = null),
  66. (this.priceLab = null),
  67. (this.progressBar = null),
  68. (this.minLab = null),
  69. (this.maxLab = null),
  70. (this.btnNode = null),
  71. (this.tipLab = null),
  72. (this.isUpgradeView = !1),
  73. (this.showFullAniTime = 0);
  74. }
  75. onLoad() {
  76. this.priceLab && (this.priceLab.string = o.default.Platform.getPrice("shop_bank"));
  77. var t = c.default.ins.define;
  78. this.minLab && (this.minLab.string = "" + t.piggybank_purchase_min_count),
  79. this.maxLab && (this.maxLab.string = "" + t.piggybank_full_count),
  80. this.isUpgradeView &&
  81. (o.default.NotificationCenter.addListener(
  82. l.NotificationConst.STAGE_UPGRADE_UPDATE,
  83. this.onStageUpgradeUpdate,
  84. this
  85. ),
  86. o.default.NotificationCenter.addListener(l.NotificationConst.PAY_SUCCESS, this.onPaySuccess, this));
  87. }
  88. onEnable() {
  89. this.updateUI(),
  90. this.arrowAni && (this.arrowAni.node.active = !1),
  91. this.bubbleAni && ((this.bubbleAni.node.children[0].active = !1), (this.bubbleAni.node.active = !1)),
  92. (this.showFullAniTime = 0);
  93. }
  94. onDisable() {
  95. o.default.NotificationCenter.removeAll(this);
  96. }
  97. onPaySuccess() {
  98. o.default.TimerManager.doFrame(3, 1, this.updateUI, this);
  99. }
  100. onStageUpgradeUpdate(t, e) {
  101. if (e) {
  102. const s = o.default.ViewManager.uiRoot;
  103. e = s.convertToNodeSpaceAR(e);
  104. var i = this.targetNode.convertToWorldSpaceAR(cc.Vec2.ZERO),
  105. i = s.convertToNodeSpaceAR(i);
  106. n.default.instance.playMoneyAni(
  107. e,
  108. i,
  109. h.CostType.diamond,
  110. s,
  111. c.default.ins.define.piggybank_get_count,
  112. () => {
  113. this.ani &&
  114. (o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.GET_BANK_DIAMOND) >=
  115. c.default.ins.define.piggybank_purchase_min_count
  116. ? this.updateUI()
  117. : (this.ani.play("work"),
  118. this.ani.once(cc.Animation.EventType.FINISHED, this.updateUI, this)));
  119. }
  120. );
  121. }
  122. }
  123. updateUI() {
  124. var t = o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.GET_BANK_DIAMOND);
  125. this.diamondLab.string = "" + t;
  126. var e = c.default.ins.define;
  127. this.progressBar.progress = t / e.piggybank_full_count;
  128. var i = t >= e.piggybank_purchase_min_count,
  129. s = t >= e.piggybank_full_count;
  130. (this.btnNode.active = i),
  131. this.tipLab &&
  132. ((this.tipLab.node.active = !i || this.isUpgradeView),
  133. (this.tipLab.string = s ? a.GameText.getText(94) : a.GameText.getText(93))),
  134. t == e.piggybank_full_count ? (this.ani.play("full"), this.playFullAni()) : this.ani.play("idle");
  135. }
  136. onTouchBuyBtn() {
  137. return s(this, void 0, void 0, function* () {
  138. (yield o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.BUY_BANK)) &&
  139. this.updateUI();
  140. });
  141. }
  142. onTouchOpen() {
  143. o.default.ViewManager.open(41);
  144. }
  145. playFullAni() {
  146. this.isUpgradeView &&
  147. !this.showFullAniTime &&
  148. ((this.arrowAni.node.active = !0),
  149. (this.bubbleAni.node.active = !0),
  150. this.arrowAni.play("idle"),
  151. this.bubbleAni.play("idle")),
  152. (this.showFullAniTime = 5);
  153. }
  154. update(t) {
  155. this.isUpgradeView &&
  156. ((this.showFullAniTime -= t),
  157. this.showFullAniTime <= 0 &&
  158. ((this.arrowAni.node.active = !1),
  159. (this.bubbleAni.node.children[0].active = !1),
  160. (this.bubbleAni.node.active = !1),
  161. (this.showFullAniTime = 0)));
  162. }
  163. };
  164. e([u(cc.Animation)], t.prototype, "ani", void 0),
  165. e([u(cc.Animation)], t.prototype, "arrowAni", void 0),
  166. e([u(cc.Animation)], t.prototype, "bubbleAni", void 0),
  167. e([u(cc.Node)], t.prototype, "targetNode", void 0),
  168. e([u(cc.Label)], t.prototype, "diamondLab", void 0),
  169. e([u(cc.Label)], t.prototype, "priceLab", void 0),
  170. e([u(cc.ProgressBar)], t.prototype, "progressBar", void 0),
  171. e([u(cc.Label)], t.prototype, "minLab", void 0),
  172. e([u(cc.Label)], t.prototype, "maxLab", void 0),
  173. e([u(cc.Node)], t.prototype, "btnNode", void 0),
  174. e([u(cc.Label)], t.prototype, "tipLab", void 0),
  175. e([u(cc.Boolean)], t.prototype, "isUpgradeView", void 0),
  176. (t = e([p, f("view/Shop/ShopBankItem")], t)),
  177. (i.ShopBankItem = t);