var t = require; var e = module; var i = exports; 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.Dir = void 0); const s = t("MapService"), o = t("BaseMan"); ((t = i.Dir || (i.Dir = {}))[(t.Bottom = 0)] = "Bottom"), (t[(t.BottomLeft = 1)] = "BottomLeft"), (t[(t.TopLeft = 3)] = "TopLeft"), (t[(t.Left = 2)] = "Left"), (t[(t.Top = 4)] = "Top"), (t[(t.TopRight = 5)] = "TopRight"), (t[(t.Right = 6)] = "Right"), (t[(t.BottomRight = 7)] = "BottomRight"); var {ccclass: t} = cc._decorator, t = e( [t], (t = class extends cc.Component { constructor() { super(...arguments), (this.moving = !1), (this._nodeIndex = 0), (this._roadNodeArr = []), (this._moveAngle = 0), (this.man = null), (this._cb = null), (this._cbTarget = null); } onLoad() { this.man || (this.man = this.getComponent(o.default)); } update(t) { var e, i, s, o; this.moving && ((i = (e = this._roadNodeArr[this._nodeIndex]).px - this.node.x), (s = e.py - this.node.y), (t = this.man.moveSpeed * t) * t < i * i + s * s ? (0 == this._moveAngle && ((this._moveAngle = Math.atan2(s, i)), (o = Math.round((-this._moveAngle + Math.PI) / (Math.PI / 4))), (this.man.direction = 5 < o ? o - 6 : o + 2)), (o = Math.cos(this._moveAngle) * t), (t = Math.sin(this._moveAngle) * t), (this.node.x += o), (this.node.y += t)) : ((this._moveAngle = 0), this._nodeIndex == this._roadNodeArr.length - 1 ? ((this.node.x = e.px), (this.node.y = e.py), this.stop()) : this.walk())); } walkByRoad(t) { (this._roadNodeArr = t), (this._nodeIndex = 0), (this._moveAngle = 0), this.walk(), this.move(); } moveTo(t, e, i) { (this._cb = e), (this._cbTarget = i); t = s.default.ins.getPaths(this.node.position, t); t.length && this.walkByRoad(t); } walk() { this._nodeIndex < this._roadNodeArr.length - 1 && this._nodeIndex++; } move() { (this.moving = !0), (this.man.state = o.CharactorState.run); } stop() { (this.moving = !1), (this.man.state = o.CharactorState.stand), this._cb && this._cb.call(this._cbTarget); } }) ); i.default = t;