Exemplo n.º 1
0
        protected override void DoExecute(WowPlayer Entity)
        {
            //on execute, first verify we have a waypoit to follow, else exit
            if (CurrentWaypoint == null)
            {
                Exit(Entity); return;
            }

            //verify we are moving, if we aren't then start moving
            if (!Entity.IsMoving())
            {
                Entity.MoveForward();
            }

            //get distances to waypoint
            float fDistance = MathFuncs.GetDistance(
                WaypointVector3DHelper.LocationToVector3D(CurrentWaypoint),
                Entity.Location, false);

            //if distance is growing instead of shrinking them face again
            if (fDistance > _LastDistance)
            {
                Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z));
            }

            //if distance to current waypoint is less then / equal to our tolerance, then move to the next waypoint if it exists, else stop/finish.
            if (fDistance <= Tolerance)
            {
                //if another waypoint exists, then switch to it
                if (TravelPath.GetFirst() != null)
                {
                    CurrentWaypoint = TravelPath.RemoveFirst();
                    Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z));
                }
                else
                {
                    Exit(Entity);
                    Finish(Entity);
                }
            }



            _LastDistance = fDistance;
        }
Exemplo n.º 2
0
        protected Location GetNextWayPoint()
        {
            Location Next = null;

            //get the next waypoint
            // The only criteria is that the next waypoint be at least 3 yards away from current
            // if all fail then skip to end
            while (TravelPath.GetFirst() != null)
            {
                //get next waypoint and remove it from the list at the same time
                Next = TravelPath.RemoveFirst();

                //check distance to the waypoint
                float distance = CurrentWaypoint.GetDistanceTo(Next);

                //if distance greater then 3f then return this waypoint
                if (distance > 10f)
                {
                    break;
                }
            }

            return(Next);
        }