示例#1
0
        private TaskState Move(Dwarf d, float dt)
        {
            if (State == TaskState.NotActive)
            {
                if (d.MovePath.Count == 1)
                {

                }
                ChangeMoveTo(d);
            }

            Vector2 addition = d.MoveToDirection * d.Speed * dt;
            Vector2 newPosition = new Vector2(d.Position.X, d.Position.Y) + addition ;

            d.DistanceMoved = d.DistanceMoved + addition.Length();

            if (d.DistanceMoved >= d.MoveToDistance)
            {
                if (d.MovePath.Count == 0)
                    return TaskState.Success;
                d.ChangePosition(new Vector3(d.MoveTo.X, d.MoveTo.Y, 5));
                ChangeMoveTo(d);
            }
            else
                d.ChangePosition(new Vector3(newPosition.X, newPosition.Y, 5));

                return TaskState.Running;
        }