BaseMan.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.CharactorState = i.aniMap = void 0);
  18. const o = t("MoveComponent"),
  19. {property: a, ccclass: n} = cc._decorator;
  20. (i.aniMap = {
  21. [o.Dir.Bottom]: "Z_",
  22. [o.Dir.BottomRight]: "Z_",
  23. [o.Dir.BottomLeft]: "Z_",
  24. [o.Dir.Right]: "L_",
  25. [o.Dir.TopRight]: "L_",
  26. [o.Dir.Top]: "B_",
  27. [o.Dir.TopLeft]: "L_",
  28. [o.Dir.Left]: "L_"
  29. }),
  30. ((t = s = i.CharactorState || (i.CharactorState = {}))[(t.stand = 0)] = "stand"),
  31. (t[(t.run = 1)] = "run"),
  32. (t[(t.send_food = 2)] = "send_food"),
  33. (t[(t.sitdown = 3)] = "sitdown"),
  34. (t[(t.cooking = 4)] = "cooking");
  35. t = class extends cc.Component {
  36. constructor() {
  37. super(...arguments),
  38. (this.sp = null),
  39. (this.aniPre = null),
  40. (this.skinName = ""),
  41. (this.moveSpeed = 150),
  42. (this.roleLangBubble = null),
  43. (this._direction = 0),
  44. (this._state = 0),
  45. (this.curAniName = "");
  46. }
  47. start() {
  48. (this.direction = 0), (this.state = s.stand);
  49. }
  50. test() {}
  51. changeSlot(t, e, i) {
  52. let s = this.sp.skeletonData.getRuntimeData(),
  53. o = s.findSkin(t),
  54. a = s.findSlotIndex(e),
  55. n = o.getAttachment(a, i),
  56. r = this.sp.findSlot(e);
  57. r && r.setAttachment(n);
  58. }
  59. get direction() {
  60. return this._direction;
  61. }
  62. set direction(t) {
  63. (this._direction = t),
  64. (this.aniPre = i.aniMap[t]),
  65. (this.sp.node.scaleX = 4 < t ? -1 : 1),
  66. (this.state = this._state);
  67. }
  68. get state() {
  69. return this._state;
  70. }
  71. playAni(t) {
  72. this.sp.setAnimation(0, this.aniPre + t, !0), (this.sp.timeScale = 1);
  73. }
  74. set state(t) {
  75. this._state = t;
  76. let e = "";
  77. switch (this._state) {
  78. case s.stand:
  79. (e = this.aniPre + "idle"), (this.sp.timeScale = 1);
  80. break;
  81. case s.run:
  82. (e = this.aniPre + "walk"), (this.sp.timeScale = this.moveSpeed / 150);
  83. break;
  84. case s.sitdown:
  85. (e = this.aniPre + "idle"), (this.sp.timeScale = 1);
  86. break;
  87. case s.send_food:
  88. (e = this.aniPre + "walk2"), (this.sp.timeScale = this.moveSpeed / 150);
  89. break;
  90. case s.cooking:
  91. (e = this.aniPre + "cook"), (this.sp.timeScale = 1);
  92. }
  93. this.curAniName !== e && (this.sp.setAnimation(0, e, !0), (this.curAniName = e));
  94. }
  95. };
  96. e([a(sp.Skeleton)], t.prototype, "sp", void 0), (t = e([n], t)), (i.default = t);