123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- var t = require;
- var e = module;
- var i = exports;
- var s,
- 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 a = t("App"),
- o = t("NodePool"),
- n = t("CostumeController"),
- r = t("GameConst"),
- l = t("Car"),
- h = t("Chef"),
- c = t("CarAI"),
- d = t("ChefAI"),
- u = t("CustomerAI"),
- p = t("RoleSpeakComponent"),
- f = t("WaiterAI"),
- g = t("Customer"),
- m = t("MainCat"),
- _ = t("Waiter"),
- y = t("BaseService"),
- v = t("DeskService"),
- U = t("MapService"),
- {ccclass: Z, property: C} = cc._decorator;
- t = s = class extends y.default {
- constructor() {
- super(...arguments),
- (this.layer = null),
- (this.deskService = null),
- (this.nextTime = 0),
- (this.customerPool = null),
- (this.carPool = null),
- (this.chefPool = null),
- (this.waiterPool = null),
- (this.mainCatPool = null),
- (this.chefs = []),
- (this.waiters = []),
- (this.customers = []),
- (this.cars = []),
- (this.testMan = null),
- (this.enter = null),
- (this.exit = null),
- (this.canCreateCar = !0),
- (this.chefspeed = 100),
- (this.waiterspeed = 100),
- (this.chefCnt = 0),
- (this.customerCnt = 1),
- (this.waiterCnt = 0),
- (this.carCnt = 1),
- (this.waiterPosIdx = 0),
- (this.chefPosIdx = 0),
- (this.rapidCats = null),
- (this.isTalking = !1),
- (this._mainCat = null);
- }
- onLoad() {
- (s.ins = this).roleLang = a.default.ConfigManager.getConfig("RoleLang");
- }
- getNextWaiterPos() {
- return this.waiterPosIdx == this.waiterPosList.length
- ? this.waiterPosList[this.waiterPosIdx - 1]
- : this.waiterPosList[this.waiterPosIdx++];
- }
- getNextChefPos() {
- return this.chefPosIdx == this.chefPosList.length
- ? this.chefPosList[this.chefPosIdx - 1]
- : this.chefPosList[this.chefPosIdx++];
- }
- updateChefSpeed() {
- for (const t of this.chefs) t.calSpeed();
- }
- updateWaiterSpeed() {
- for (const t of this.waiters) t.calSpeed();
- }
- removeEmployee(t) {
- this.chefs.remove(t), this.waiters.remove(t), t.node.destroy();
- }
- tempUpdate(t) {
- if (this.nextTime < 0) {
- if (this.deskService.empPosList.length) {
- const t = this.deskService.empPosList.pop(),
- e = this.createCustomer();
- e.addComponent(u.default),
- (e.posData = t),
- (e.node.position = this.enter),
- this.layer.addChild(e.node),
- e.ranSkin(),
- this.customers.push(e);
- }
- this.nextTime = 1;
- } else this.nextTime -= t;
- }
- tempCarUpdate(t) {
- if (this.nextTime < 0) {
- if (this.canCreateCar && this.cars.length < this.carCnt) {
- const t = this.createCar();
- t.addComponent(c.default),
- (t.posData = v.default.ins.carPosData.posData),
- (t.carPosData = v.default.ins.carPosData),
- (t.node.position = this.enter),
- this.layer.addChild(t.node),
- this.cars.push(t);
- }
- this.nextTime = 1;
- } else this.nextTime -= t;
- }
- createManCat(t, e) {
- const i = this.mainCatPool.pop(),
- s = i.getComponent(m.default);
- return (
- void 0 !== e && (s.skinName = e),
- (s.selfAttr = t),
- 1 === U.default.ins.curCfg.type
- ? ((s.isWaiter = !0),
- i.addComponent(f.default),
- this.waiters.push(s),
- (s.basePos = i.position = this.getNextWaiterPos()))
- : ((s.basePos = i.position = this.getNextChefPos()), i.addComponent(d.default), this.chefs.push(s)),
- this.layer.addChild(i),
- s.calSpeed(),
- s
- );
- }
- createRapidCat() {
- const t = this.mainCatPool.pop(),
- e = (this._mainCat = t.getComponent(m.default));
- (e.selfAttr = n.default.ins.getModel().attr),
- 1 === U.default.ins.curCfg.type
- ? ((e.isWaiter = !0),
- t.addComponent(f.default),
- this.waiters.push(e),
- (e.basePos = t.position = this.getNextWaiterPos()))
- : ((e.basePos = t.position = this.getNextChefPos()), t.addComponent(d.default), this.chefs.push(e)),
- this.layer.addChild(t),
- e.calSpeed();
- }
- createTestMan() {
- var t = this.mainCatPool.pop().getComponent(m.default);
- (this.testMan = t),
- (this.testMan.node.position = this.enter),
- this.layer.addChild(this.testMan.node),
- this.testMan.updateSlot(n.default.ins.getModel().equipItems);
- }
- createCustomer() {
- return this.customerPool.pop().getComponent(g.default);
- }
- createCar() {
- return this.carPool.pop().getComponent(l.default);
- }
- createWaiter(t) {
- const e = this.waiterPool.pop(),
- i = e.getComponent(_.default);
- return (
- i.calSpeed(),
- e.addComponent(f.default),
- (i.basePos = e.position = t || this.getNextWaiterPos()),
- this.layer.addChild(e),
- this.waiters.push(i),
- i
- );
- }
- createChef(t) {
- const e = this.chefPool.pop(),
- i = e.getComponent(h.default);
- return (
- (i.basePos = e.position = t || this.getNextChefPos()),
- i.calSpeed(),
- this.layer.addChild(e),
- i.addComponent(d.default),
- this.chefs.push(i),
- i
- );
- }
- update(t) {}
- parse(t) {
- const e = t.getChildByName("CustomerTrans");
- (this.enter = e.getChildByName("EnterTrans").position),
- (this.exit = e.getChildByName("ExitTrans").position),
- e.destroy();
- const i = t.getChildByName("CashierSpawnTrans");
- (this.waiterPosList = i.children.map(t => t.position)), i.destroy();
- const s = t.getChildByName("SpawnTrans");
- (this.chefPosList = s.children.map(t => t.position)), s.destroy();
- }
- destroySelf() {
- (this.chefs = []),
- (this.waiters = []),
- (this.customers = []),
- (this.testMan = null),
- (this._mainCat = null),
- (this.canCreateCar = !0),
- (this.waiterPosIdx = 0),
- (this.chefPosIdx = 0),
- (this.update = () => {});
- }
- init() {
- U.default.ins.curCfg.type === r.StageType.CAR
- ? (this.update = this.tempCarUpdate)
- : (this.update = this.tempUpdate),
- (this.deskService = v.default.ins),
- (this.layer = U.default.ins.layer);
- var t = U.default.ins.curCfg.type;
- if (
- ((this._mainCat = this.createManCat(n.default.ins.getModel().attr)),
- this.onEquipOrUnEquipCostume(),
- 1 === t)
- ) {
- var e = this.waiterCnt;
- for (let t = 0; t < e; t++) this.createWaiter();
- } else if (2 === t || 3 === t) {
- this.waiterCnt++;
- let e = this.waiterCnt;
- for (let t = 0; t < e; t++) this.createWaiter();
- e = this.chefCnt;
- for (let t = 0; t < e; t++) this.createChef();
- }
- a.default.NotificationCenter.addListener(
- r.GameNotificationConst.EQUIP_COSTUME,
- this.onEquipOrUnEquipCostume,
- this
- ),
- a.default.NotificationCenter.addListener(
- r.GameNotificationConst.UNEQUIP_COSTUME,
- this.onEquipOrUnEquipCostume,
- this
- );
- }
- onEquipOrUnEquipCostume() {
- this._mainCat.updateSlot(n.default.ins.getModel().equipItems),
- this.testMan && this.testMan.updateSlot(n.default.ins.getModel().equipItems);
- }
- getNewMainCat() {
- return this.mainCatPool.pop();
- }
- removeNewMainCat(t) {
- this.mainCatPool.push(t);
- }
- talkingFinish() {
- this.isTalking = !1;
- }
- showLang(t, e) {
- if (this.isTalking) return !1;
- var i = this.roleLang[e];
- if (a.default.RandomUtils.limit(0, 100) > i.rate) return !1;
- this.isTalking = !0;
- const s = a.default.RandomUtils.randomArray(this.roleLang[e].lang),
- o = a.default.NodePoolMsr.roleLangPool.pop();
- return U.default.ins.langLayer.addChild(o), o.getComponent(p.RoleSpeakComponent).init(t, s.lang), !0;
- }
- };
- e([C(o.default)], t.prototype, "customerPool", void 0),
- e([C(o.default)], t.prototype, "carPool", void 0),
- e([C(o.default)], t.prototype, "chefPool", void 0),
- e([C(o.default)], t.prototype, "waiterPool", void 0),
- e([C(o.default)], t.prototype, "mainCatPool", void 0),
- (t = s = e([Z], t)),
- (i.default = t = s);
|