CostumeMergeView.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. s = t("ListView"),
  19. a = t("BaseView"),
  20. n = (t("ViewConst"), t("GameUtils")),
  21. r = t("CostumeConst"),
  22. l = t("CostumeController"),
  23. h = t("CostumeBagItem"),
  24. c = t("CostumeMergeItem"),
  25. {ccclass: d, property: u} = cc._decorator;
  26. t = class extends a.default {
  27. constructor() {
  28. super(...arguments),
  29. (this.mergeNode = null),
  30. (this.newItemSpecialSpr = null),
  31. (this.newItemNameLab = null),
  32. (this.newItemCurLab = null),
  33. (this.newItemUpgradeLab = null),
  34. (this.newItemSpecialRichText = null),
  35. (this.mergeBtn = null),
  36. (this.costLab = null),
  37. (this.mergeItemsNode = null),
  38. (this.selectNode = null),
  39. (this.itemList = null),
  40. (this.newItemDisplay = null),
  41. (this.targetDisplay = null),
  42. (this.costItemDisplay1 = null),
  43. (this.costItemDisplay2 = null),
  44. (this.items = null),
  45. (this.bgType = 1),
  46. (this.targetItem = null),
  47. (this._model = null);
  48. }
  49. initUI() {
  50. super.initUI(), this.itemList.node.on(s.ListViewEvent.ITEM_TAP, this.onSelectItem, this);
  51. }
  52. onItemMerge() {
  53. var t = this.itemList.selectedItems.slice(1),
  54. e = l.default.ins.mergeCostume(this.targetItem, t);
  55. e &&
  56. (o.default.ViewManager.open(47, t, this.targetItem, e.refundDiamond),
  57. (this.targetItem = null),
  58. l.default.ins.updateMergeInfo(),
  59. this.toNormalState(),
  60. this.updateList(),
  61. this.itemList.updateViewPort());
  62. }
  63. open() {
  64. super.open(),
  65. (this._model = l.default.ins.getModel()),
  66. l.default.ins.updateMergeInfo(),
  67. this.toNormalState(),
  68. this.updateList();
  69. }
  70. close() {
  71. super.close(), (this._model = null);
  72. }
  73. toNormalState() {
  74. (this.mergeNode.active = !1), (this.selectNode.active = !0);
  75. }
  76. toSelectState() {
  77. (this.mergeNode.active = !0), (this.selectNode.active = !1);
  78. }
  79. onRenderItem(t, e) {
  80. const i = t.getComponent(c.CostumeMergeItem),
  81. s = this.items[e];
  82. i.setData(s);
  83. }
  84. onSelectItem(t, e) {
  85. if (this.targetItem) {
  86. if (t.data === this.targetItem) this.setTarget(null), this.updateList();
  87. else {
  88. const t = this.itemList.selectedItems;
  89. t.length === this.itemList.maxMultipleSelectNum
  90. ? this.updateMergeBtnState(!0)
  91. : this.updateMergeBtnState(!1),
  92. 1 < t.length
  93. ? (this.costItemDisplay1.show(), this.costItemDisplay1.setData(t[1]))
  94. : this.costItemDisplay1.hide(),
  95. 2 < t.length
  96. ? (this.costItemDisplay2.show(), this.costItemDisplay2.setData(t[2]))
  97. : this.costItemDisplay2.hide();
  98. }
  99. } else this.setTarget(t.data), this.toSelectState();
  100. }
  101. setTarget(t) {
  102. if ((this.targetItem = t)) {
  103. this.newItemNameLab.string = t.getName();
  104. const i = t.getNextGradeItem();
  105. this.newItemDisplay.setData(i),
  106. (this.newItemCurLab.string = t.getBaseValueStr()),
  107. (this.newItemUpgradeLab.string = i.getBaseValueStr()),
  108. (this.newItemSpecialSpr.node.active = !0),
  109. i.data.grade === r.RarityType.rare
  110. ? ((this.newItemSpecialRichText.string = i.getSpecialAbilityStr1()),
  111. o.default.CommonUtils.setSpriteFrame(r.getGradeBgByGrade(i.data.grade), this.newItemSpecialSpr))
  112. : i.data.grade === r.RarityType.epic
  113. ? ((this.newItemSpecialRichText.string = i.getSpecialAbilityStr2()),
  114. o.default.CommonUtils.setSpriteFrame(r.getGradeBgByGrade(i.data.grade), this.newItemSpecialSpr))
  115. : i.data.grade === r.RarityType.legendary
  116. ? ((this.newItemSpecialRichText.string = i.getSpecialAbilityStr3()),
  117. o.default.CommonUtils.setSpriteFrame(r.getGradeBgByGrade(i.data.grade), this.newItemSpecialSpr))
  118. : i.data.grade === r.RarityType.mystic
  119. ? ((this.newItemSpecialRichText.string = i.getSpecialAbilityStr4()),
  120. o.default.CommonUtils.setSpriteFrame(r.getGradeBgByGrade(i.data.grade), this.newItemSpecialSpr))
  121. : ((this.newItemSpecialRichText.string = ""), (this.newItemSpecialSpr.node.active = !1)),
  122. this.targetDisplay.setData(t);
  123. var e = t.getMergeCfg();
  124. this.costItemDisplay1.hide(),
  125. 2 === e.costume_count
  126. ? (this.costItemDisplay2.hide(), (this.costItemDisplay2.node.active = !0))
  127. : (this.costItemDisplay2.node.active = !1),
  128. this.updateMergeBtnState(!1),
  129. (this.itemList.maxMultipleSelectNum = 1 + e.costume_count);
  130. const s = this._model.getMergeCostume(t);
  131. s.includes(t) || s.unshift(t),
  132. this.itemList.updateDataSource(s),
  133. this.itemList.select([t]),
  134. this.itemList.updateViewPort();
  135. } else this.toNormalState();
  136. }
  137. updateMergeBtnState(t) {
  138. (this.mergeBtn.interactable = t),
  139. this.mergeBtn.node
  140. .getComponentInChildren(cc.Label)
  141. .setMaterial(0, t ? this.mergeBtn.normalMaterial : this.mergeBtn.grayMaterial);
  142. }
  143. updateList() {
  144. const t = this._model,
  145. e = (this.items = t.items.filter(t => t.data.grade < r.RarityType.mystic));
  146. this.items.sort((t, e) => (t.canMerge === e.canMerge ? n.sortCostume(t, e) : e.canMerge ? 1 : -1)),
  147. this.itemList.updateDataSource(e);
  148. }
  149. onTouchTipBtn() {
  150. o.default.ViewManager.open(35);
  151. }
  152. };
  153. e([u({type: cc.Node})], t.prototype, "mergeNode", void 0),
  154. e([u({type: cc.Sprite})], t.prototype, "newItemSpecialSpr", void 0),
  155. e([u({type: cc.Label})], t.prototype, "newItemNameLab", void 0),
  156. e([u({type: cc.Label})], t.prototype, "newItemCurLab", void 0),
  157. e([u({type: cc.Label})], t.prototype, "newItemUpgradeLab", void 0),
  158. e([u({type: cc.RichText})], t.prototype, "newItemSpecialRichText", void 0),
  159. e([u({type: cc.Button})], t.prototype, "mergeBtn", void 0),
  160. e([u({type: cc.Label})], t.prototype, "costLab", void 0),
  161. e([u({type: cc.Node})], t.prototype, "mergeItemsNode", void 0),
  162. e([u({type: cc.Node})], t.prototype, "selectNode", void 0),
  163. e([u({type: s.ListView})], t.prototype, "itemList", void 0),
  164. e([u(h.CostumeBagItem)], t.prototype, "newItemDisplay", void 0),
  165. e([u(h.CostumeBagItem)], t.prototype, "targetDisplay", void 0),
  166. e([u(h.CostumeBagItem)], t.prototype, "costItemDisplay1", void 0),
  167. e([u(h.CostumeBagItem)], t.prototype, "costItemDisplay2", void 0),
  168. (t = e([d], t)),
  169. (i.default = t);