示例#1
0
        public override void Start(int tickCounter)
        {
            var distance    = MovementHelpers.GetDistance(this.Owner.Position, this.Heading);
            var facingAngle = MovementHelpers.GetFacingAngle(this.Owner, this.Heading);

            this.Owner.Move(this.Heading, facingAngle);

            //Logger.Trace("Heading: " + this.Heading);
            //Logger.Trace("Start point: " + this.Owner.Position);

            this.Timer = new SteppedRelativeTickTimer(this.Owner.World.Game, 6, (int)(distance / this.Owner.WalkSpeed),
                                                      (tick) =>
            {
                this.Owner.Position = MovementHelpers.GetMovementPosition(this.Owner.Position, this.Owner.WalkSpeed, facingAngle, 6);
                //Logger.Trace("Step: " + this.Owner.Position);
            },
                                                      (tick) =>
            {
                this.Owner.Position = Heading;
                //Logger.Trace("Completed: " + this.Owner.Position);
                this.Done = true;
            });

            this.Started = true;
        }
        public override void Start(int tickCounter)
        {
            // Just wait, path request hasnt been processed yet, idealy this would be null or something instead - Darklotus
            if (!_pathRequestTask.PathFound)
            {
                return;
            }

            // No path found, so end Action.
            if (_pathRequestTask.Path.Count < 1)
            {
                this.Started = true;
                this.Done    = true;
                return;
            }
            _path = _pathRequestTask.Path;
            // Each path step will be 2.5f apart roughly, not sure on the math to get correct walk speed for the timer.
            // mobs sometimes skip a bit, pretty sure this is because timing isnt correct.  :( - DarkLotus


            //this.Timer = new SteppedRelativeTickTimer(this.Owner.World.Game, 18, (int)(_path.Count * 2 / this.Owner.WalkSpeed),
            this.Timer = new SteppedRelativeTickTimer(this.Owner.World.Game, 6, (int)(_path.Count * 2 / this.Owner.WalkSpeed),
                                                      (tick) =>
            {
                //this.Owner.Position = MovementHelpers.GetMovementPosition(this.Owner.Position, this.Owner.WalkSpeed, facingAngle, 6);
                if (_path.Count >= 1)
                {
                    this.Owner.Move(this._path.First(), MovementHelpers.GetFacingAngle(this.Owner, this._path.First()));
                    this.Owner.Position = _path.First();
                    _path.RemoveAt(0);
                    //Logger.Trace("Step left in Queue: " + Path.Count);
                }
                else
                {
                    this.Owner.Position = Heading; //Logger.Trace("Ticking with no path steps left");
                    this.Done           = true;
                }
            },
                                                      (tick) =>
            {
                this.Owner.Position = Heading;
                //Logger.Trace("Completed! Path contains :" + this.Path.Count);
                this.Done = true;
            });

            this.Started = true;
        }