DeskService.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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}), (i.DeskPosData = i.CarPosData = i.DeskData = void 0);
  18. const u = t("PassSectionData"),
  19. p = t("TipData"),
  20. f = t("GameConst"),
  21. g = t("GameUtils"),
  22. o = t("BaseService"),
  23. m = t("MapService"),
  24. {ccclass: a} = cc._decorator;
  25. (s = class extends o.default {
  26. constructor() {
  27. super(...arguments),
  28. (this.mapNode = null),
  29. (this.empPosList = null),
  30. (this.passSectionDatas = null),
  31. (this.cookDatas = null),
  32. (this.carCookDatas = null),
  33. (this.deskDatas = null),
  34. (this.carPosData = null),
  35. (this.stageType = null);
  36. }
  37. onLoad() {
  38. s.ins = this;
  39. }
  40. hasEmpPos() {
  41. return 0 < this.empPosList.length;
  42. }
  43. init() {
  44. (this.stageType = m.default.ins.curCfg.type), this.stageType !== f.StageType.CAR && this.unlockDesk2();
  45. }
  46. addCookData(t) {
  47. (this.stageType !== f.StageType.CAR || t.order.customer.isReadyReceive
  48. ? this.cookDatas
  49. : this.carCookDatas
  50. ).push(t);
  51. }
  52. carCookDataFinish(e) {
  53. for (let t = this.carCookDatas.length - 1; 0 <= t; t--)
  54. if (this.carCookDatas[t].order.customer === e) {
  55. const e = this.carCookDatas.splice(t, 1)[0];
  56. this.cookDatas.push(e);
  57. }
  58. }
  59. unlockDesk(t) {
  60. this.deskDatas[t].unlock(), this.empPosList.push(...this.deskDatas[t].customers);
  61. }
  62. unlockDesk2() {
  63. this.empPosList.push(this.deskDatas[0].customers.pop());
  64. }
  65. parse(t) {
  66. if (
  67. ((this.cookDatas = []),
  68. (this.empPosList = []),
  69. (this.carCookDatas = []),
  70. (this.passSectionDatas = []),
  71. m.default.ins.curCfg.type === f.StageType.CAR)
  72. ) {
  73. const o = t.getChildByName("DriveFront"),
  74. a = o.getChildByName("OrderTrans").position,
  75. n = o.getChildByName("valueUpTrans").position,
  76. r = (this.carPosData = new y()),
  77. u = (r.posData = new v());
  78. u.tipAndValueUp = new p.default(n);
  79. const f = o.getChildByName("Desk");
  80. f
  81. ? ((u.tipAndValueUp.deskNode = f), f.removeFromParent(!1), m.default.ins.layer.addChild(f))
  82. : (u.tipAndValueUp.deskNode = m.default.ins.uiLayer),
  83. (r.order = a),
  84. (r.receiveTrans = []);
  85. var e = o.getChildByName("ReceiveTrans"),
  86. i = e.x,
  87. s = e.y;
  88. for (const t of e.children) {
  89. const o = t.position;
  90. (o.x += i), (o.y += s), r.receiveTrans.push(o);
  91. }
  92. e = o.getChildByName("ReceiveStaffTrans").position;
  93. u.staff = {pos: e, direction: g.getDirection(e, r.receiveTrans[0])};
  94. e = o.getChildByName("StaffTrans").position;
  95. (r.staffTrans = {pos: e, direction: g.getDirection(e, a)}), o.destroy();
  96. } else {
  97. const o = t.getChildByName("Desk"),
  98. a = o.children.concat(),
  99. l = (this.deskDatas = []),
  100. h = a.length;
  101. for (let t = 0; t < h; t++) {
  102. const o = a[t],
  103. c = new _();
  104. 0 < t && o.removeFromParent(!1), (c.node = o), c.parse(o), (l[t] = c);
  105. }
  106. l[0].showNode(), o.destroy();
  107. }
  108. const o = t.getChildByName("PassSection");
  109. let a = o.getChildByName("Desk");
  110. a && a.removeFromParent(!1);
  111. for (const d of o.children) {
  112. const t = new u.default();
  113. if (((t.passSectionDesk = m.default.ins.uiLayer), t.parse(d), a))
  114. for (const o of a.children)
  115. if (o.getBoundingBox().contains(t.foodPos)) {
  116. t.passSectionDesk = o;
  117. break;
  118. }
  119. this.passSectionDatas.push(t);
  120. }
  121. if (a) {
  122. for (let t = a.children.length - 1; 0 <= t; t--) {
  123. const o = a.children[t];
  124. o.removeFromParent(!1), m.default.ins.layer.addChild(o);
  125. }
  126. a.destroy();
  127. }
  128. o.destroy();
  129. }
  130. }),
  131. (s = e([a], s));
  132. i.default = s;
  133. const d = cc.v2();
  134. class _ {
  135. constructor() {
  136. (this.customers = []), (this.isUnlock = !1), (this.node = null);
  137. }
  138. parse(e) {
  139. const i = e.x,
  140. s = e.y,
  141. t = e.getChildByName("Staff"),
  142. o = [];
  143. let a = i + t.x,
  144. n = s + t.y;
  145. for (const p of t.children) {
  146. const e = p.position;
  147. (e.x += a), (e.y += n), o.push({pos: e, direction: 0});
  148. }
  149. t.destroy();
  150. const r = e.getChildByName("TipAndValueUp"),
  151. l = e.children.filter(t => "Desk" === t.name),
  152. h = [];
  153. (a = i + r.x), (n = s + r.y);
  154. for (const g of r.children) {
  155. const e = g.position;
  156. (e.x += a), (e.y += n);
  157. const t = new p.default(e);
  158. (t.deskNode = m.default.ins.uiLayer), h.push(t);
  159. for (const o of l) {
  160. const a = o.getBoundingBox();
  161. (a.x += i), (a.y += s), a.contains(e) && (t.deskNode = o);
  162. }
  163. }
  164. r.destroy();
  165. const c = e.getChildByName("Customer");
  166. (a = i + c.x), (n = s + c.y);
  167. for (const p of c.children) {
  168. const e = p.position;
  169. (e.x += a), (e.y += n);
  170. const i = {pos: e, direction: 0},
  171. s = new v();
  172. (s.sit = i), this.customers.push(s);
  173. let t = 1e6;
  174. for (const o of h) {
  175. const e = i.pos.sub(o.pos, d).magSqr();
  176. t > e && ((s.tipAndValueUp = o), (t = e));
  177. }
  178. (i.direction = g.getDirection(i.pos, s.tipAndValueUp.pos)), (t = 1e6);
  179. for (const a of o) {
  180. const e = s.sit.pos.sub(a.pos, d).magSqr();
  181. t > e && ((t = e), (s.staff = a));
  182. }
  183. s.staff.direction = g.getDirection(s.staff.pos, s.tipAndValueUp.pos);
  184. }
  185. c.destroy(), this.node.removeFromParent(!1);
  186. }
  187. showNode() {
  188. const e = this.node,
  189. i = m.default.ins.layer,
  190. s = e.x,
  191. o = e.y;
  192. for (let t = e.children.length - 1; 0 <= t; t--) {
  193. const a = e.children[t];
  194. a.removeFromParent(!1), i.addChild(a), (a.x += s), (a.y += o);
  195. }
  196. e.destroy(), (this.node = null);
  197. }
  198. unlock() {
  199. (this.isUnlock = !0), this.showNode();
  200. }
  201. }
  202. i.DeskData = _;
  203. class y {
  204. constructor() {
  205. (this.receiveTrans = null), (this.order = null), (this.staffTrans = null), (this.posData = null);
  206. }
  207. }
  208. i.CarPosData = y;
  209. class v {
  210. constructor() {
  211. (this.sit = null), (this.staff = null), (this.tipAndValueUp = null);
  212. }
  213. }
  214. i.DeskPosData = v;