123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- 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}), (i.AI_STATE = void 0);
- const o = t("GameConst"),
- a = t("OrderService"),
- n = t("RoleService"),
- r = t("BaseMan"),
- l = t("MoveComponent");
- ((t = s = i.AI_STATE || (i.AI_STATE = {}))[(t.NONE = 0)] = "NONE"),
- (t[(t.MOVE_TO_REST = 1)] = "MOVE_TO_REST"),
- (t[(t.REST = 2)] = "REST"),
- (t[(t.DEEP_REST = 3)] = "DEEP_REST"),
- (t[(t.ORDERING = 4)] = "ORDERING"),
- (t[(t.MOVE_TO_ORDERING = 5)] = "MOVE_TO_ORDERING"),
- (t[(t.COOKING = 6)] = "COOKING"),
- (t[(t.MOVE_TO_COOKING = 7)] = "MOVE_TO_COOKING"),
- (t[(t.SEND_FOOD = 8)] = "SEND_FOOD"),
- (t[(t.MOVE_TO_SEND_FOOD = 9)] = "MOVE_TO_SEND_FOOD");
- var {ccclass: t} = cc._decorator,
- t = e(
- [t],
- (t = class extends cc.Component {
- constructor() {
- super(...arguments),
- (this.man = null),
- (this.move = null),
- (this.waitOrderData = null),
- (this.leftTime = 0),
- (this.maxTime = 0),
- (this.orderDataList = null),
- (this.cookData = null),
- (this.state = s.NONE);
- }
- onLoad() {
- (this.man = this.getComponent(r.default)),
- (this.move = this.getComponent(l.default)),
- (this.orderDataList = a.default.ins.orders[o.MachineType.type2]);
- }
- think() {
- if (this.orderDataList.hasEmp) {
- const t = (this.cookData = this.orderDataList.cookOrder());
- return t.init(this.man), this.move.moveTo(t.slot.chefPos), void (this.state = s.MOVE_TO_COOKING);
- }
- this.state !== s.MOVE_TO_REST &&
- this.state !== s.REST &&
- this.state !== s.DEEP_REST &&
- (this.move.moveTo(this.man.basePos), (this.state = s.MOVE_TO_REST));
- }
- update(t) {
- if (this.man.state === r.CharactorState.stand)
- switch (this.state) {
- case s.NONE:
- this.think();
- break;
- case s.DEEP_REST:
- this.think(),
- this.state !== s.DEEP_REST && n.default.ins.showLang(this.node, o.RoleLangType.WALK_UP);
- break;
- case s.REST:
- if ((this.think(), this.state !== s.REST)) break;
- (this.leftTime -= t),
- this.leftTime < 0 && (this.man.playAni("sleep2"), (this.state = s.DEEP_REST));
- break;
- case s.MOVE_TO_COOKING:
- this.onMoveToCookingFinish();
- break;
- case s.COOKING:
- this.onCooking(t);
- break;
- case s.SEND_FOOD:
- this.cookData.passSectionData.addCookData(this.cookData),
- (this.man.direction = this.cookData.passSectionData.chef.direction),
- (this.cookData = null),
- this.man.hideFood(),
- (this.state = s.NONE);
- break;
- case s.MOVE_TO_REST:
- this.moveToRest();
- }
- else this.man.state === r.CharactorState.run && this.state === s.MOVE_TO_REST && this.think();
- }
- moveToRest() {
- (this.state = s.REST), (this.leftTime = 5), (this.man.direction = 2), this.man.playAni("sleep");
- }
- onMoveToCookingFinish() {
- var t = this.man.getInstaCompletedDishRate();
- t && t > Math.random()
- ? (this.man.showInstaCompletedDishEffect(), (this.maxTime = 0.3))
- : (this.maxTime = this.cookData.getCookTime()),
- (this.leftTime = 0),
- (this.man.progress.progress = this.leftTime / this.maxTime),
- (this.man.progress.node.active = !0),
- (this.state = s.COOKING),
- (this.man.direction = this.cookData.slot.direction),
- this.man.playAni("cook"),
- this.cookData.slot.playCookAni(),
- this.man.showFire();
- }
- onCooking(t) {
- (this.leftTime += t),
- this.leftTime < this.maxTime
- ? (this.man.progress.progress = this.leftTime / this.maxTime)
- : ((this.man.progress.node.active = !1),
- (t = this.man.getPerfectDishRate()),
- this.cookData.finishCook(t && t > Math.random()),
- this.orderDataList.checkHasEmp(),
- this.move.moveTo(this.cookData.passSectionData.chef.pos),
- (this.state = s.SEND_FOOD),
- this.man.showFood(this.cookData.order.display.food.spriteFrame, this.cookData.foodValue),
- (this.man.state = r.CharactorState.send_food),
- this.man.removeFire(),
- n.default.ins.showLang(this.node, o.RoleLangType.MACHINE_FINISH));
- }
- })
- );
- i.default = t;
|