123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- o =
- (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}), (i.AbilityType = void 0);
- const a = t("App"),
- n = t("RedPointMgr"),
- r = t("Toast"),
- l = t("NotificationConst"),
- h = (t("ViewConst"), t("SystemOpenConst")),
- c = t("RoleUnlockAni"),
- d = t("StageUpgradeData"),
- u = t("GameConst"),
- p = t("GlobalAttr"),
- f = t("BaseService"),
- g = t("CurrencyService"),
- m = t("DeskService"),
- _ = t("MachineService"),
- y = t("MapService"),
- v = t("RoleService");
- n.RedPointMgr.types.StageUpgrade = "StageUpgrade";
- var U,
- {ccclass: e} = cc._decorator,
- t = (s = class extends f.default {
- constructor() {
- super(...arguments),
- (this.define = null),
- (this.datas = null),
- (this.menuprofitValue = null),
- (this.fastermenu = null),
- (this.saveData = null),
- (this.funMap = {}),
- (this.isSysOpen = !1);
- }
- onLoad() {
- ((s.ins = this).funMap[U.menuprofit] = this.onMenuprofit),
- (this.funMap[U.allmenuprofit] = this.onAllmenuprofit),
- (this.funMap[U.fastermenu] = this.onFastermenu),
- (this.funMap[U.chefspeed] = this.onChefspeed),
- (this.funMap[U.cashirespeed] = this.onCashirespeed),
- (this.funMap[U.addchef] = this.onAddchef),
- (this.funMap[U.addcashire] = this.onAddcashire),
- (this.funMap[U.addcustomer1] = this.onAddcustomer1),
- (this.funMap[U.addcustomer2] = this.onAddcustomer2),
- (this.funMap[U.addcar] = this.onAddcar),
- this.initEvent();
- }
- unlockAll() {
- for (const t of this.datas.concat()) this.buy(t.cfg.order, !0);
- }
- buy(t, e = !1, i) {
- for (const s of this.datas)
- if (s.cfg.order === t) {
- if (!e && !g.default.ins.moneyChange(-s.cost)) return r.default.launch("金币不足!"), !1;
- this.funMap[s.cfg.ability_type] && this.funMap[s.cfg.ability_type].call(this, s),
- this.saveData.push(s.cfg.order),
- this.datas.remove(s),
- a.default.NotificationCenter.dispatch(
- l.NotificationConst.STAGE_UPGRADE_UPDATE,
- this.datas.length,
- i
- );
- break;
- }
- return this.onUpdateMoney(), !0;
- }
- init() {
- const e = v.default.ins;
- (e.chefspeed = 100),
- (e.waiterspeed = 100),
- (e.chefCnt = 0),
- (e.waiterCnt = 0),
- (e.customerCnt = 1),
- (e.carCnt = 1),
- (this.menuprofitValue = {}),
- (this.fastermenu = {}),
- (this.datas = []);
- const i = this.getModel().getCurMapData();
- i.stageUpgrade || (i.stageUpgrade = []), (this.saveData = i.stageUpgrade);
- var s = y.default.ins.curCfg.StageUpgrade;
- let o = s.length;
- for (let t = 0; t < o; t++) {
- const e = new d.default(),
- o = s[t];
- e.init(o),
- i.stageUpgrade.includes(o.order)
- ? this.funMap[o.ability_type] && this.funMap[o.ability_type].call(this, e, !0)
- : this.datas.push(e);
- }
- this.onUpdateMoney();
- }
- initEvent() {
- a.default.NotificationCenter.addListener(l.NotificationConst.UPDATE_MONEY, this.onUpdateMoney, this),
- a.default.NotificationCenter.addListener(l.NotificationConst.SYS_OPEN, this.onSysOpen, this);
- }
- onSysOpen(t, e) {
- t == h.OpenTypeConst.STAGE_UPGRADE &&
- e &&
- ((this.isSysOpen = !0),
- a.default.NotificationCenter.removeListener(l.NotificationConst.SYS_OPEN, this.onSysOpen, this));
- }
- onMenuprofit(t, e) {
- this.menuprofitValue[t.cfg.ability_target]
- ? (this.menuprofitValue[t.cfg.ability_target] *= t.cfg.ability_value)
- : (this.menuprofitValue[t.cfg.ability_target] = t.cfg.ability_value),
- e || _.default.ins.reCalFoodValue(t.cfg.ability_target - 1);
- }
- onFastermenu(t, e) {
- this.fastermenu[t.cfg.ability_target]
- ? (this.fastermenu[t.cfg.ability_target] *= t.cfg.ability_value / 100)
- : (this.fastermenu[t.cfg.ability_target] = t.cfg.ability_value / 100),
- e || _.default.ins.machineDatas[t.cfg.ability_target - 1].attr.calFoodFinalTime();
- }
- onAllmenuprofit(t, e) {
- this.menuprofitValue[t.cfg.ability_target]
- ? (this.menuprofitValue[t.cfg.ability_target] *= t.cfg.ability_value)
- : (this.menuprofitValue[t.cfg.ability_target] = t.cfg.ability_value),
- e || _.default.ins.reCalAllFoodValue();
- }
- onCashirespeed(t, e) {
- (v.default.ins.waiterspeed = (v.default.ins.waiterspeed * t.cfg.ability_value) / 100),
- e || p.default.ins.calWaiterSpeed();
- }
- onChefspeed(t, e) {
- (v.default.ins.chefspeed = (v.default.ins.chefspeed * t.cfg.ability_value) / 100),
- e || p.default.ins.calChefSpeed();
- }
- onAddcashire(e, i) {
- if (((v.default.ins.waiterCnt += e.cfg.ability_value), !i)) {
- const i = y.default.ins.layer;
- for (let t = 0; t < e.cfg.ability_value; t++) {
- const e = a.default.NodePoolMsr.catUnlockAni.pop(),
- s = e.getComponent(c.default),
- o = v.default.ins.getNextWaiterPos();
- (e.position = o),
- i.addChild(e),
- s.init(() => {
- var t = v.default.ins.createWaiter(o);
- v.default.ins.showLang(t.node, u.RoleLangType.OPEN_BOX);
- }, this);
- }
- }
- }
- onAddchef(e, i) {
- if (((v.default.ins.chefCnt += e.cfg.ability_value), !i)) {
- const i = y.default.ins.layer;
- for (let t = 0; t < e.cfg.ability_value; t++) {
- const e = a.default.NodePoolMsr.catUnlockAni.pop(),
- s = e.getComponent(c.default),
- o = v.default.ins.getNextChefPos();
- (e.position = o),
- i.addChild(e),
- s.init(() => {
- var t = v.default.ins.createChef(o);
- v.default.ins.showLang(t.node, u.RoleLangType.OPEN_BOX);
- }, this);
- }
- }
- }
- onAddcustomer1(t, e) {
- m.default.ins.unlockDesk2();
- }
- onAddcustomer2(t, e) {
- if (e) m.default.ins.unlockDesk(t.cfg.ability_target);
- else {
- const e = m.default.ins.deskDatas[t.cfg.ability_target],
- i = a.default.NodePoolMsr.cookUnlockAni.pop(),
- s = i.getComponent(c.default),
- o = e.node.position;
- (i.position = o),
- y.default.ins.layer.addChild(i),
- s.init(() => {
- m.default.ins.unlockDesk(t.cfg.ability_target);
- }, this);
- }
- }
- onAddcar(t, e) {
- v.default.ins.carCnt += t.cfg.ability_value;
- }
- desotrySelf() {}
- updateUpgradeDiscount() {
- for (const t of this.datas) t.calCost();
- this.onUpdateMoney();
- }
- onUpdateMoney() {
- let t = !1;
- var e = y.default.ins.mapSaveData.money;
- for (const i of this.datas)
- if (i.cost <= e) {
- t = !0;
- break;
- }
- a.default.RedPointMgr.next(a.default.RedPointMgr.types.StageUpgrade, t), this.updateTipView();
- }
- isUnlock(t) {
- const e = this.getModel().getCurMapData();
- return !!e.stageUpgrade && e.stageUpgrade.includes(t);
- }
- updateTipView() {
- if (this.isSysOpen && !(y.default.ins.curId > a.default.ConfigManager.gameConf.game.stageUpgradeTip)) {
- const e = this.datas[0];
- var t = e && e.canBuy();
- a.default.ViewManager.isShow(21)
- ? t
- ? a.default.ViewManager.getView(21).updateUI(e)
- : a.default.ViewManager.close(21)
- : t && a.default.ViewManager.open(21, e);
- }
- }
- });
- (t.ins = null),
- (t = s = o([e], t)),
- (i.default = t = s),
- ((i = U = i.AbilityType || (i.AbilityType = {}))[(i.menuprofit = 101)] = "menuprofit"),
- (i[(i.allmenuprofit = 102)] = "allmenuprofit"),
- (i[(i.fastermenu = 201)] = "fastermenu"),
- (i[(i.addcustomer1 = 301)] = "addcustomer1"),
- (i[(i.addcustomer2 = 302)] = "addcustomer2"),
- (i[(i.addcar = 303)] = "addcar"),
- (i[(i.addcashire = 401)] = "addcashire"),
- (i[(i.addchef = 402)] = "addchef"),
- (i[(i.cashirespeed = 501)] = "cashirespeed"),
- (i[(i.chefspeed = 502)] = "chefspeed");
|