MachineUnlockBox.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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("PanelAni"),
  19. a = t("NotificationConst"),
  20. n = t("MachineService"),
  21. r = t("MapService"),
  22. {ccclass: l, property: h} = cc._decorator;
  23. t = class extends cc.Component {
  24. constructor() {
  25. super(...arguments),
  26. (this.btnLab = null),
  27. (this.btn = null),
  28. (this.bgNode = null),
  29. (this.panelAni = null),
  30. (this.machineData = null);
  31. }
  32. onLoad() {
  33. (this.node.zIndex = 10), this.node.removeFromParent(!1);
  34. }
  35. onTouchBtn() {
  36. s.default.SoundManager.playEffect("clickBtn"),
  37. n.default.ins.unlockMachine(this.machineData.cfg.machine_num - 1),
  38. this.node.removeFromParent(!1),
  39. (this.machineData = null);
  40. }
  41. onUpdateMoney() {
  42. this.btn.interactable = this.machineData.canUnlock();
  43. }
  44. onDisable() {
  45. s.default.NotificationCenter.removeListener(a.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this);
  46. }
  47. showBox(t) {
  48. if (t != this.machineData) {
  49. s.default.NotificationCenter.addListener(a.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this),
  50. (this.btn.interactable = t.canUnlock()),
  51. (this.machineData = t),
  52. (this.btnLab.string = t.cfg.install_cost),
  53. (this.node.scale = 0);
  54. const i = t.getPos();
  55. i.y += 0;
  56. var e = 100 + this.node.width / 2,
  57. t = cc.view.getVisibleSize().width - this.node.width / 2 - 50;
  58. i.x < e ? (this.bgNode.x = 60) : i.x > t ? (this.bgNode.x = -60) : (this.bgNode.x = 0),
  59. (this.node.position = i),
  60. this.node.parent || r.default.ins.mapNode.addChild(this.node),
  61. this.playShowAni();
  62. } else this.playHideAni();
  63. }
  64. playShowAni() {
  65. this.panelAni.showPanel();
  66. }
  67. playHideAni() {
  68. this.panelAni.hidePanel(() => {
  69. this.node.removeFromParent(!1), (this.machineData = null);
  70. });
  71. }
  72. };
  73. e([h(cc.Label)], t.prototype, "btnLab", void 0),
  74. e([h(cc.Button)], t.prototype, "btn", void 0),
  75. e([h(cc.Node)], t.prototype, "bgNode", void 0),
  76. e([h(o.PanelAni)], t.prototype, "panelAni", void 0),
  77. (t = e([l], t)),
  78. (i.default = t);