CostumeBagView.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 s = t("App"),
  18. o = t("List"),
  19. a = t("BaseView"),
  20. n = (t("ViewConst"), t("GameConst")),
  21. r = t("GameUtils"),
  22. l = t("MainCat"),
  23. h = t("RoleService"),
  24. c = t("CostumeConst"),
  25. d = t("CostumeController"),
  26. u = t("CostumeBagEquipItem"),
  27. p = t("CostumeBagItem"),
  28. {ccclass: f, property: g} = cc._decorator;
  29. t = class extends a.default {
  30. constructor() {
  31. super(...arguments),
  32. (this.itemList = null),
  33. (this.equipCostumeNode = null),
  34. (this.moneyRateLab = null),
  35. (this.mergeBtn = null),
  36. (this.catNode = null),
  37. (this.MoneyRateTipNode = null),
  38. (this.mainCat = null),
  39. (this.bgType = 0),
  40. (this.items = null),
  41. (this.costumeBagEquipItems = []);
  42. }
  43. initUI() {
  44. super.initUI();
  45. for (const e of this.equipCostumeNode.children)
  46. this.costumeBagEquipItems.push(e.getComponent(u.CostumeBagEquipItem));
  47. const t = h.default.ins.getNewMainCat();
  48. this.catNode.addChild(t), (t.position = cc.Vec2.ZERO), (this.mainCat = t.getComponent(l.default));
  49. }
  50. open() {
  51. super.open(), this.updateList(!0), this.updateEquip(), this.addEvent();
  52. }
  53. close() {
  54. super.close(),
  55. s.default.NotificationCenter.removeAll(this),
  56. h.default.ins.removeNewMainCat(this.mainCat.node),
  57. (this.mainCat = null);
  58. }
  59. addEvent() {
  60. s.default.NotificationCenter.addListener(n.GameNotificationConst.LV_UP_COSTUME, this.onLvUpCostume, this),
  61. s.default.NotificationCenter.addListener(n.GameNotificationConst.EQUIP_COSTUME, this.onEquipCostume, this),
  62. s.default.NotificationCenter.addListener(
  63. n.GameNotificationConst.UNEQUIP_COSTUME,
  64. this.onUnequipCostume,
  65. this
  66. ),
  67. s.default.NotificationCenter.addListener(
  68. n.GameNotificationConst.REFUND_COSTUME,
  69. this.onUnequipCostume,
  70. this
  71. ),
  72. s.default.NotificationCenter.addListener(n.GameNotificationConst.MERGE_COSTUME, this.onMergeCostume, this);
  73. }
  74. onEquipCostume(t) {
  75. this.updateEquipCostumeByParts(t.cfg.parts), this.updateList(!0);
  76. }
  77. onMergeCostume(t, e) {
  78. this.updateList(), this.updateEquip();
  79. }
  80. updateEquipCostumeByParts(t) {
  81. const e = d.default.ins.getModel();
  82. this.costumeBagEquipItems[t - 1].setData(e.equipItems[t]),
  83. (this.moneyRateLab.string = `+${e.attr.getAttrValue(c.CostumeAbilityType.base, 0)}%`);
  84. }
  85. onRefundCostume(t) {
  86. t.isEquip ? this.updateEquipCostumeByParts(t.cfg.parts) : this.updateList();
  87. }
  88. onUnequipCostume(t) {
  89. this.updateEquipCostumeByParts(t.cfg.parts), this.updateList(!0);
  90. }
  91. onLvUpCostume(t) {
  92. t.isEquip ? this.updateEquipCostumeByParts(t.cfg.parts) : this.updateList();
  93. }
  94. updateEquip() {
  95. const e = d.default.ins.getModel();
  96. let i = this.costumeBagEquipItems.length;
  97. for (let t = 0; t < i; t++) {
  98. const i = this.costumeBagEquipItems[t],
  99. s = e.equipItems[t + 1];
  100. i.setData(s);
  101. }
  102. (this.MoneyRateTipNode.active = 0 < i),
  103. (this.moneyRateLab.string = `+${e.attr.getAttrValue(c.CostumeAbilityType.base, 0)}%`);
  104. }
  105. onTouchMergeBtn() {
  106. s.default.ViewManager.open(27);
  107. }
  108. updateList(t = !1) {
  109. const e = d.default.ins.getModel(),
  110. i = (this.items = e.items.concat());
  111. for (const s in e.equipItems) this.items.remove(e.equipItems[s]);
  112. this.items.sort(r.sortCostume), (this.itemList.numItems = i.length), t && this.mainCat.updateSlot(e.equipItems);
  113. }
  114. onRenderItem(t, e) {
  115. const i = t.getComponent(p.CostumeBagItem),
  116. s = this.items[e];
  117. (i.recommendNode.active = s.recommend), i.setData(s);
  118. }
  119. onTouchMoneyRateTip() {
  120. s.default.ViewManager.open(46);
  121. }
  122. };
  123. e([g({type: o.default})], t.prototype, "itemList", void 0),
  124. e([g({type: cc.Node})], t.prototype, "equipCostumeNode", void 0),
  125. e([g({type: cc.Label})], t.prototype, "moneyRateLab", void 0),
  126. e([g({type: cc.Button})], t.prototype, "mergeBtn", void 0),
  127. e([g(cc.Node)], t.prototype, "catNode", void 0),
  128. e([g(cc.Node)], t.prototype, "MoneyRateTipNode", void 0),
  129. (t = e([f], t)),
  130. (i.default = t);