123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- var t = require;
- var e = module;
- var i = exports;
- Object.defineProperty(i, "__esModule", {value: !0});
- const o = t("App"),
- u = t("GameText"),
- a = t("Toast"),
- n = t("RedPoinAnim"),
- r = t("MachineLvUpAni"),
- l = t("RoleUnlockAni"),
- h = t("GameConst"),
- p = t("MachineAttr"),
- c = t("CurrencyService"),
- s = t("MachineService"),
- f = t("MapService"),
- g = t("SlotData");
- i.default = class {
- constructor() {
- (this.cfg = null),
- (this.menu = null),
- (this.unlockFrameBg = null),
- (this.foodBg = null),
- (this.slots = []),
- (this.unlockSlots = []),
- (this.unlockCnt = 0),
- (this.attr = null),
- (this.foodImg = null),
- (this.name = ""),
- (this.tipNode = null);
- }
- getPos() {
- const t = this.foodBg.node.position;
- return (t.x += this.foodBg.node.parent.x), (t.y += this.foodBg.node.parent.y + this.foodBg.node.height / 2), t;
- }
- updateMoney() {
- this.attr.isUnlock ? (this.tipNode.active = this.canLevelUp()) : (this.tipNode.active = this.canUnlock());
- }
- setMemento(e) {
- const i = (this.attr = new p.default()),
- s = f.default.ins.define,
- t = f.default.ins.curCfg;
- i.init(
- e,
- this.cfg,
- t.machine_max_lv,
- t.machine_slot_max,
- t.stage < 1e4 ? s.machine_slot_add_lv : s.event_machine_slot_add_lv,
- s.machine_value_doubleup_lv
- );
- var o = this.slots.length;
- for (let t = 0; t < o; t++) {
- const e = this.slots[t],
- s = i.slotCnt > t;
- s && ((this.unlockSlots[t] = e), (this.unlockCnt = t + 1)), e.setActive(s);
- }
- i.isUnlock ? (this.foodBg.spriteFrame = this.unlockFrameBg) : (this.foodImg.node.active = !1),
- this.foodBg.node.on(cc.Node.EventType.TOUCH_END, this.onTouchUnlock, this),
- this.updateMoney();
- }
- onTouchUnlock() {
- (this.attr.isUnlock ? s.default.ins.lvUpBox : s.default.ins.machineUnlockBox).showBox(this);
- }
- canUnlock() {
- return f.default.ins.mapSaveData.money >= this.attr.installCost;
- }
- canLevelUp() {
- return !this.attr.isMaxLevel() && f.default.ins.mapSaveData.money >= this.attr.upgradeCost;
- }
- unlockSlot(t) {
- const e = this.slots[t];
- this.unlockCnt = t + 1;
- const i = o.default.NodePoolMsr.cookUnlockAni.pop(),
- s = i.getComponent(l.default);
- (i.position = e.selfPos),
- f.default.ins.uiLayer.addChild(i),
- s.init(() => {
- e.unlock(), this.unlockSlots.push(e);
- for (const t of this.slots) t.updateSiblingIndex();
- o.default.NotificationCenter.dispatch(h.GameNotificationConst.UNLOCK_SLOT, e);
- }, this);
- }
- unlock() {
- this.attr.unlockSelf(),
- this.unlockSlot(0),
- (this.foodImg.node.active = !0),
- (this.foodBg.spriteFrame = this.unlockFrameBg);
- }
- lvUp() {
- if (!this.attr.isMaxLevel()) {
- var e = -this.attr.upgradeCost;
- if (c.default.ins.checkMoneyEnough(e)) {
- var i = this.attr.levelUp();
- this.attr.slotCnt > this.unlockCnt && this.unlockSlot(this.attr.slotCnt - 1),
- c.default.ins.moneyChange(e);
- const s = this.tipNode.parent;
- let t = o.default.NodePoolMsr.machineLvUpAni.pop();
- return s.addChild(t), t.getComponent(r.default).playAni(), i;
- }
- return a.default.launch("金币不足!"), !1;
- }
- a.default.launch("已经是最大等级!");
- }
- replacBtn(t, e) {
- let i = t.getChildByName("FoodOrder");
- (this.unlockFrameBg = i.getComponent(cc.Sprite).spriteFrame),
- i.parent.addChild(e),
- (e.x = i.x),
- (e.y = i.y),
- i.destroy();
- let s = i.children[0];
- s ? s.removeFromParent(!1) : (s = new cc.Node()), e.addChild(s);
- let o = s.getComponent(cc.Sprite);
- (o = o || s.addComponent(cc.Sprite)),
- (this.foodImg = o),
- (this.foodBg = e.getComponent(cc.Sprite)),
- (this.tipNode = e.getChildByName("arrow")),
- this.tipNode.getComponent(n.RedPoinAnim) || this.tipNode.addComponent(n.RedPoinAnim);
- }
- parse(e, i, s) {
- this.replacBtn(e, i),
- (this.menu = s),
- (this.name = u.GameText.getTextByStr(s.name)),
- (this.attr = new p.default());
- const o = e.getChildByName("slots"),
- a = e.x + o.x,
- n = e.y + o.y,
- r = -e.width * e.anchorX,
- l = e.width - e.width * e.anchorX,
- h = o.children,
- c = f.default.ins.layer;
- for (let t = h.length - 1; 0 <= t; t--) {
- const e = h[t],
- i = new g.default();
- i.machineData = this;
- const s = e.children[0];
- if (
- ((i.direction = parseInt(s.name.slice(5))),
- e.children[1] && ((i.ani = e.children[1].getComponent(cc.Animation)), i.ani && 6 === i.direction))
- ) {
- const e = i.ani.node;
- 1 < e.children.length ? (e.children[1].scaleX = -1) : (e.scaleX = -1);
- }
- (i.chefPos = cc.v2(s.x + a + e.x, s.y + n + e.y)), (i.selfPos = cc.v2(a + e.x, n + e.y)), s.destroy();
- const p = parseInt(e.name.split("_")[1]);
- (this.slots[p] = i), i.stopCook(), (i.node = e), (i.siblingIndex = t);
- var d = o.x + e.x;
- e.getComponent(cc.Sprite) && (d < r || l < d)
- ? (e.removeFromParent(!1), c.addChild(e), (e.x = a + e.x), (e.y = n + e.y), (i.parentNode = c))
- : (i.parentNode = e.parent);
- }
- }
- getEmpSlot() {
- for (const t of this.unlockSlots) if (!t.isWorking) return t;
- return null;
- }
- };
|