ShopOpenBoxView.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.ShopOpenBoxView = void 0);
  49. const o = t("App"),
  50. a = t("BaseView"),
  51. n = t("ControllerConst"),
  52. r = (t("ADController"), t("BagConst")),
  53. l = t("CostumeConst"),
  54. h = t("GameConst"),
  55. c = t("ShopConst"),
  56. { ccclass: d, property: u, menu: p } = cc._decorator;
  57. t = class extends a.default {
  58. constructor() {
  59. super(...arguments),
  60. (this.icon = null),
  61. (this.typeIcon = null),
  62. (this.bgSpr = null),
  63. (this.nameLab = null),
  64. (this.ani = null),
  65. (this.costBtn = null),
  66. (this.costLab = null),
  67. (this.costIconNode = null),
  68. (this.boxList = []),
  69. (this.itemBase = null),
  70. (this.data = null),
  71. (this.isPlaying = !1),
  72. (this.bgType = 1);
  73. }
  74. initUI() {
  75. super.initUI();
  76. }
  77. open(t, e) {
  78. super.open(),
  79. (this.data = e),
  80. (this.itemBase = o.default.ControllerManager.applyFunc(
  81. n.ControllerConst.Item,
  82. r.BagConst.GET_ITEM,
  83. this.data.cfg.itemId
  84. )),
  85. this.openBox(t);
  86. }
  87. openBox(t) {
  88. (this.bgSpr.node.scale = 0),
  89. (this.bgSpr.node.y = 30),
  90. (this.nameLab.node.active = !1),
  91. (this.costBtn.parent.active = !1),
  92. (this.nameLab.string = t.getName()),
  93. o.default.CommonUtils.setSpriteFrame(l.getRarityUrlByGrade(t.data.grade), this.bgSpr),
  94. o.default.CommonUtils.setSpriteFrameByBundle(h.BundleType.MAP_ICON, t.getIcon(), this.icon),
  95. o.default.CommonUtils.setSpriteFrameByBundle(h.BundleType.MAP_ICON, t.getTypeIcon(), this.typeIcon);
  96. var e = this.data.cfg.icon;
  97. for (let t = 0; t < this.boxList.length; t++) this.boxList[t].active = t == e;
  98. this.ani.once(cc.Animation.EventType.FINISHED, this.onAniFinished, this),
  99. this.updateCost(),
  100. this.ani.play("work"),
  101. (this.isPlaying = !0);
  102. }
  103. updateCost() {
  104. this.data.cfg.ad ?
  105. (this.costBtn.active = !1) :
  106. ((this.costBtn.active = !0),
  107. this.itemBase.cnt ?
  108. ((this.costIconNode.active = !1), (this.costLab.string = `${this.itemBase.cnt}/1`)) :
  109. ((this.costIconNode.active = !0), (this.costLab.string = this.data.cfg.diamond.toString())));
  110. }
  111. onTouchBg() {
  112. this.isPlaying &&
  113. (this.ani.off(cc.Animation.EventType.FINISHED, this.onAniFinished, this),
  114. (this.boxList[0].parent.y = 0),
  115. this.onAniFinished());
  116. }
  117. onAniFinished() {
  118. (this.isPlaying = !1),
  119. (this.costBtn.parent.active = !0),
  120. (this.nameLab.node.active = !0),
  121. cc.tween(this.bgSpr.node).to(0.2, { y: 300, scale: 1 }).start(),
  122. this.ani.play("idle");
  123. }
  124. onTouchCostBtn() {
  125. return s(this, void 0, void 0, function*() {
  126. this.itemBase.cnt ?
  127. o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, c.ShopConst.USE, this.data) :
  128. o.default.ControllerManager.applyFunc(n.ControllerConst.Shop, c.ShopConst.BUY, this.data, 7);
  129. });
  130. }
  131. };
  132. e([u(cc.Sprite)], t.prototype, "icon", void 0),
  133. e([u(cc.Sprite)], t.prototype, "typeIcon", void 0),
  134. e([u(cc.Sprite)], t.prototype, "bgSpr", void 0),
  135. e([u(cc.Label)], t.prototype, "nameLab", void 0),
  136. e([u(cc.Animation)], t.prototype, "ani", void 0),
  137. e([u(cc.Node)], t.prototype, "costBtn", void 0),
  138. e([u(cc.Label)], t.prototype, "costLab", void 0),
  139. e([u(cc.Node)], t.prototype, "costIconNode", void 0),
  140. e([u([cc.Node])], t.prototype, "boxList", void 0),
  141. (t = e([d], t)),
  142. (i.ShopOpenBoxView = t);