PassSectionData.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const s = t("App"),
  6. o = t("GameUtils"),
  7. a = t("MyBigLong"),
  8. n = t("DeskService");
  9. i.default = class {
  10. constructor() {
  11. (this.chef = null),
  12. (this.waiter = null),
  13. (this.passSectionDesk = null),
  14. (this.foodPos = null),
  15. (this.cookDatas = []),
  16. (this.showSpr = null),
  17. (this.moneyLab = null);
  18. }
  19. addCookData(t) {
  20. if ((this.cookDatas.push(t), this.showSpr)) this.showSpr.node.active = !0;
  21. else {
  22. const t = s.default.NodePoolMsr.passSectionFoodPool.pop();
  23. (t.zIndex = 4),
  24. this.passSectionDesk.addChild(t),
  25. (t.position = this.foodPos),
  26. (t.x -= this.passSectionDesk.x),
  27. (t.y -= this.passSectionDesk.y),
  28. (this.showSpr = t.getComponent(cc.Sprite)),
  29. (this.moneyLab = t.getComponentInChildren(cc.Label));
  30. }
  31. n.default.ins.addCookData(t),
  32. (this.showSpr.spriteFrame = t.order.display.food.spriteFrame),
  33. (this.moneyLab.string = a.default.toString(this.getAllMoneyCnt()));
  34. }
  35. getAllMoneyCnt() {
  36. let t = 0;
  37. for (const e of this.cookDatas) t += e.foodValue;
  38. return t;
  39. }
  40. removeCookData(t) {
  41. if ((this.cookDatas.remove(t), this.cookDatas.length)) {
  42. const t = this.cookDatas.last();
  43. (this.moneyLab.string = a.default.toString(this.getAllMoneyCnt())),
  44. (this.showSpr.spriteFrame = t.order.display.food.spriteFrame);
  45. } else this.showSpr.node.active = !1;
  46. }
  47. parse(t) {
  48. var e = t.x,
  49. i = t.y;
  50. (this.foodPos = t.getChildByName("Foodsprite").position), (this.foodPos.x += e), (this.foodPos.y += i);
  51. let s = t.getChildByName("Chef").position;
  52. (s.x += e),
  53. (s.y += i),
  54. (this.chef = {pos: s, direction: o.getDirection(s, this.foodPos)}),
  55. ((s = t.getChildByName("Cashier").position).x += e),
  56. (s.y += i),
  57. (this.waiter = {pos: s, direction: o.getDirection(s, this.foodPos)});
  58. }
  59. };