var t = require; var e = module; var i = exports; e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", {value: !0}); const s = t("App"), o = t("HoldEvent"), a = t("PanelAni"), n = t("NotificationConst"), r = t("BagController"), l = t("MyBigLong"), h = t("MachineService"), c = t("MapService"), {ccclass: d, property: u} = cc._decorator; t = class extends cc.Component { constructor() { super(...arguments), (this.bgNode = null), (this.progressBar = null), (this.maxNode = null), (this.diamondNode = null), (this.starListNode = null), (this.lvUpBtn = null), (this.costLab = null), (this.doubleTipBg = null), (this.lvLab = null), (this.nameLab = null), (this.foodValueLab = null), (this.timeLab = null), (this.panelAni = null), (this.machineData = null); } onLoad() { (this.node.zIndex = 10), this.node.removeFromParent(!1); } onTouchLvUpBtn() { console.error('暴力 瞬间升级MAX'); for (let index = 0; index < 50; index++) { s.default.SoundManager.playEffect("clickBtn"), h.default.ins.lvUpkMachine(this.machineData.cfg.machine_num - 1), this.updateData(); } } updateData() { const t = this.machineData; t.attr.isMaxLevel() ? ((this.lvUpBtn.interactable = !1), (this.progressBar.progress = 1), (this.costLab.string = "MAX"), this.updateStar(!0)) : ((this.lvUpBtn.interactable = t.canLevelUp()), (this.progressBar.progress = t.attr.getDoubleProgressRate()), (this.costLab.string = l.default.toString(t.attr.upgradeCost)), this.updateStar(!1)), (this.lvLab.string = "Lv." + t.attr.level), (this.foodValueLab.string = l.default.toString(t.attr.value)), (this.timeLab.string = t.attr.manufactureTime + "s"), (this.nameLab.string = t.name); } onUpdateMoney() { this.machineData.attr.isMaxLevel() || (this.lvUpBtn.interactable = this.machineData.canLevelUp()); } onDisable() { s.default.NotificationCenter.removeListener(n.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this); } showBox(t) { if (t != this.machineData) { s.default.NotificationCenter.addListener(n.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this), (this.machineData = t), this.updateData(), (this.node.scale = 0); const i = t.getPos(); i.y += 0; var e = 100 + this.node.width / 2, t = cc.view.getVisibleSize().width - this.node.width / 2 - 50; i.x < e ? (this.bgNode.x = 80) : i.x > t ? (this.bgNode.x = -80) : (this.bgNode.x = 0), (this.node.position = i), this.node.parent || c.default.ins.mapNode.addChild(this.node), this.panelAni.showPanel(), (this.doubleTipBg.active = !1); } else this.panelAni.hidePanel(() => { this.node.removeFromParent(!1), (this.machineData = null); }); } hideBox() { this.node.parent && this.panelAni.hidePanel(() => { this.node.removeFromParent(!1), (this.machineData = null); }); } updateStar(t = !1) { var e = this.machineData.attr.getMaxStarNum(), i = this.machineData.attr.getCurStarNum(), s = Math.ceil(i / 5), o = t ? f : p[s], a = p[0 === s ? 0 : s - 1]; let n = 5, r; r = e % 5 != 0 && Math.floor(e / 5) == Math.floor(i / 5) ? (n = e % 5) - e + i : i % 5; const l = this.starListNode.children; for (let t = 0; t < l.length; t++) (l[t].children[0].color = t < r ? o : a), (l[t].active = t < n); this.maxNode.active = t; } playGetDiamond() { console.error('免费的两个钻石 不送了'); return if (this.diamondNode.active) { let t = cc.find("Canvas").getChildByName("DefaultCamera").getComponent(cc.Camera), e = this.diamondNode.convertToWorldSpaceAR(cc.Vec2.ZERO), i = t.getWorldToScreenPoint(e); s.default.NotificationCenter.dispatch(n.NotificationConst.PLAY_MONEY_ANI, r.CostType.diamond, 2, i); } this.doubleTipBg.stopAllActions(), (this.doubleTipBg.active = !0), (this.doubleTipBg.scale = 0), cc .tween(this.doubleTipBg) .to(0.2, {scale: 1}) .delay(2) .call(() => { this.doubleTipBg.active = !1; }) .start(); } }; e([u({type: cc.Node})], t.prototype, "bgNode", void 0), e([u({type: cc.ProgressBar})], t.prototype, "progressBar", void 0), e([u({type: cc.Node})], t.prototype, "maxNode", void 0), e([u({type: cc.Node})], t.prototype, "diamondNode", void 0), e([u({type: cc.Node})], t.prototype, "starListNode", void 0), e([u({type: o.default})], t.prototype, "lvUpBtn", void 0), e([u({type: cc.Label})], t.prototype, "costLab", void 0), e([u({type: cc.Node})], t.prototype, "doubleTipBg", void 0), e([u({type: cc.Label})], t.prototype, "lvLab", void 0), e([u({type: cc.Label})], t.prototype, "nameLab", void 0), e([u({type: cc.Label})], t.prototype, "foodValueLab", void 0), e([u({type: cc.Label})], t.prototype, "timeLab", void 0), e([u(a.PanelAni)], t.prototype, "panelAni", void 0), (t = e([d], t)), (i.default = t); const p = [ cc.color().fromHEX("#FFFFFF"), cc.color().fromHEX("#ffc845"), cc.color().fromHEX("#8fdb52"), cc.color().fromHEX("#6be1f6"), cc.color().fromHEX("#ff6c6c") ], f = cc.color().fromHEX("#8fdb52");