LvUpBox.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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("HoldEvent"),
  19. a = t("PanelAni"),
  20. n = t("NotificationConst"),
  21. r = t("BagController"),
  22. l = t("MyBigLong"),
  23. h = t("MachineService"),
  24. c = t("MapService"),
  25. {ccclass: d, property: u} = cc._decorator;
  26. t = class extends cc.Component {
  27. constructor() {
  28. super(...arguments),
  29. (this.bgNode = null),
  30. (this.progressBar = null),
  31. (this.maxNode = null),
  32. (this.diamondNode = null),
  33. (this.starListNode = null),
  34. (this.lvUpBtn = null),
  35. (this.costLab = null),
  36. (this.doubleTipBg = null),
  37. (this.lvLab = null),
  38. (this.nameLab = null),
  39. (this.foodValueLab = null),
  40. (this.timeLab = null),
  41. (this.panelAni = null),
  42. (this.machineData = null);
  43. }
  44. onLoad() {
  45. (this.node.zIndex = 10), this.node.removeFromParent(!1);
  46. }
  47. onTouchLvUpBtn() {
  48. console.error('暴力 瞬间升级MAX');
  49. for (let index = 0; index < 50; index++) {
  50. s.default.SoundManager.playEffect("clickBtn"),
  51. h.default.ins.lvUpkMachine(this.machineData.cfg.machine_num - 1),
  52. this.updateData();
  53. }
  54. }
  55. updateData() {
  56. const t = this.machineData;
  57. t.attr.isMaxLevel()
  58. ? ((this.lvUpBtn.interactable = !1),
  59. (this.progressBar.progress = 1),
  60. (this.costLab.string = "MAX"),
  61. this.updateStar(!0))
  62. : ((this.lvUpBtn.interactable = t.canLevelUp()),
  63. (this.progressBar.progress = t.attr.getDoubleProgressRate()),
  64. (this.costLab.string = l.default.toString(t.attr.upgradeCost)),
  65. this.updateStar(!1)),
  66. (this.lvLab.string = "Lv." + t.attr.level),
  67. (this.foodValueLab.string = l.default.toString(t.attr.value)),
  68. (this.timeLab.string = t.attr.manufactureTime + "s"),
  69. (this.nameLab.string = t.name);
  70. }
  71. onUpdateMoney() {
  72. this.machineData.attr.isMaxLevel() || (this.lvUpBtn.interactable = this.machineData.canLevelUp());
  73. }
  74. onDisable() {
  75. s.default.NotificationCenter.removeListener(n.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this);
  76. }
  77. showBox(t) {
  78. if (t != this.machineData) {
  79. s.default.NotificationCenter.addListener(n.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this),
  80. (this.machineData = t),
  81. this.updateData(),
  82. (this.node.scale = 0);
  83. const i = t.getPos();
  84. i.y += 0;
  85. var e = 100 + this.node.width / 2,
  86. t = cc.view.getVisibleSize().width - this.node.width / 2 - 50;
  87. i.x < e ? (this.bgNode.x = 80) : i.x > t ? (this.bgNode.x = -80) : (this.bgNode.x = 0),
  88. (this.node.position = i),
  89. this.node.parent || c.default.ins.mapNode.addChild(this.node),
  90. this.panelAni.showPanel(),
  91. (this.doubleTipBg.active = !1);
  92. } else
  93. this.panelAni.hidePanel(() => {
  94. this.node.removeFromParent(!1), (this.machineData = null);
  95. });
  96. }
  97. hideBox() {
  98. this.node.parent &&
  99. this.panelAni.hidePanel(() => {
  100. this.node.removeFromParent(!1), (this.machineData = null);
  101. });
  102. }
  103. updateStar(t = !1) {
  104. var e = this.machineData.attr.getMaxStarNum(),
  105. i = this.machineData.attr.getCurStarNum(),
  106. s = Math.ceil(i / 5),
  107. o = t ? f : p[s],
  108. a = p[0 === s ? 0 : s - 1];
  109. let n = 5,
  110. r;
  111. r = e % 5 != 0 && Math.floor(e / 5) == Math.floor(i / 5) ? (n = e % 5) - e + i : i % 5;
  112. const l = this.starListNode.children;
  113. for (let t = 0; t < l.length; t++) (l[t].children[0].color = t < r ? o : a), (l[t].active = t < n);
  114. this.maxNode.active = t;
  115. }
  116. playGetDiamond() {
  117. console.error('免费的两个钻石 不送了');
  118. return
  119. if (this.diamondNode.active) {
  120. let t = cc.find("Canvas").getChildByName("DefaultCamera").getComponent(cc.Camera),
  121. e = this.diamondNode.convertToWorldSpaceAR(cc.Vec2.ZERO),
  122. i = t.getWorldToScreenPoint(e);
  123. s.default.NotificationCenter.dispatch(n.NotificationConst.PLAY_MONEY_ANI, r.CostType.diamond, 2, i);
  124. }
  125. this.doubleTipBg.stopAllActions(),
  126. (this.doubleTipBg.active = !0),
  127. (this.doubleTipBg.scale = 0),
  128. cc
  129. .tween(this.doubleTipBg)
  130. .to(0.2, {scale: 1})
  131. .delay(2)
  132. .call(() => {
  133. this.doubleTipBg.active = !1;
  134. })
  135. .start();
  136. }
  137. };
  138. e([u({type: cc.Node})], t.prototype, "bgNode", void 0),
  139. e([u({type: cc.ProgressBar})], t.prototype, "progressBar", void 0),
  140. e([u({type: cc.Node})], t.prototype, "maxNode", void 0),
  141. e([u({type: cc.Node})], t.prototype, "diamondNode", void 0),
  142. e([u({type: cc.Node})], t.prototype, "starListNode", void 0),
  143. e([u({type: o.default})], t.prototype, "lvUpBtn", void 0),
  144. e([u({type: cc.Label})], t.prototype, "costLab", void 0),
  145. e([u({type: cc.Node})], t.prototype, "doubleTipBg", void 0),
  146. e([u({type: cc.Label})], t.prototype, "lvLab", void 0),
  147. e([u({type: cc.Label})], t.prototype, "nameLab", void 0),
  148. e([u({type: cc.Label})], t.prototype, "foodValueLab", void 0),
  149. e([u({type: cc.Label})], t.prototype, "timeLab", void 0),
  150. e([u(a.PanelAni)], t.prototype, "panelAni", void 0),
  151. (t = e([d], t)),
  152. (i.default = t);
  153. const p = [
  154. cc.color().fromHEX("#FFFFFF"),
  155. cc.color().fromHEX("#ffc845"),
  156. cc.color().fromHEX("#8fdb52"),
  157. cc.color().fromHEX("#6be1f6"),
  158. cc.color().fromHEX("#ff6c6c")
  159. ],
  160. f = cc.color().fromHEX("#8fdb52");