CustomerAI.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s,
  5. e =
  6. (this && this.__decorate) ||
  7. function (t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", {value: !0});
  18. const o = t("App"),
  19. a = t("GameConst"),
  20. n = t("DeskService"),
  21. r = t("MapService"),
  22. l = t("OrderService"),
  23. h = t("RoleService"),
  24. c = t("BaseMan"),
  25. d = t("Customer"),
  26. u = t("OrderDisplay"),
  27. p = t("MoveComponent");
  28. ((t = s = s || {})[(t.NONE = 0)] = "NONE"),
  29. (t[(t.MOVE_TO_SIT = 1)] = "MOVE_TO_SIT"),
  30. (t[(t.SIT_DOWN = 2)] = "SIT_DOWN"),
  31. (t[(t.MOVE_TO_EXIT = 3)] = "MOVE_TO_EXIT");
  32. var {ccclass: t} = cc._decorator,
  33. t = e(
  34. [t],
  35. (t = class extends cc.Component {
  36. constructor() {
  37. super(...arguments), (this.man = null), (this.move = null), (this.state = s.NONE);
  38. }
  39. onLoad() {
  40. (this.man = this.getComponent(d.default)), (this.move = this.getComponent(p.default));
  41. var t = o.default.RandomUtils.limit(3e3, 5e3);
  42. (this.man.talkCnt = 0), o.default.TimerManager.doTimer(t, 1, this.showLang, this);
  43. }
  44. showLang() {
  45. h.default.ins.showLang(this.node, a.RoleLangType.COSTUMER_ENTER) && this.man && (this.man.talkCnt = 1);
  46. }
  47. update(t) {
  48. if (this.man.state === c.CharactorState.stand)
  49. switch (this.state) {
  50. case s.SIT_DOWN:
  51. this.man.isEixt &&
  52. ((this.state = s.MOVE_TO_EXIT),
  53. n.default.ins.empPosList.push(this.man.posData),
  54. this.move.moveTo(h.default.ins.exit),
  55. (this.man.posData = null));
  56. break;
  57. case s.NONE:
  58. (this.state = s.MOVE_TO_SIT), this.move.moveTo(this.man.posData.sit.pos);
  59. break;
  60. case s.MOVE_TO_SIT:
  61. this.man.sitDown(),
  62. l.default.ins.waitOrderList.push({
  63. target: this,
  64. cb: this.orderFinish,
  65. pos: this.man.posData.staff.pos,
  66. direction: this.man.posData.staff.direction
  67. }),
  68. (this.state = s.SIT_DOWN);
  69. break;
  70. case s.MOVE_TO_EXIT:
  71. h.default.ins.customers.remove(this.man), this.man.destroySelf();
  72. }
  73. }
  74. orderFinish() {
  75. const t = l.default.ins.createOrder(),
  76. e = l.default.ins.orderPool.pop();
  77. (e.x = this.node.x + 10),
  78. (e.y = this.node.y + this.node.height + 50),
  79. r.default.ins.uiLayer.addChild(e);
  80. const i = e.addComponent(u.default);
  81. (t.display = i), (t.customer = this.man), i.setData(t);
  82. var s = r.default.ins.langLayer.children[0];
  83. s && s.x == this.node.x && o.default.NodePoolMsr.roleLangPool.push(s);
  84. }
  85. })
  86. );
  87. i.default = t;