Beispiel #1
0
        // 11Apr2013-04:42UTC chinajade
        public static HuntingGroundsType GetOrCreate(XElement parentElement, string elementName,
                                                     WaypointType defaultHuntingGroundCenter = null, double?forcedTolerance = null)
        {
            var huntingGrounds = new HuntingGroundsType(parentElement
                                                        .Elements()
                                                        .DefaultIfEmpty(new XElement(elementName))
                                                        .FirstOrDefault(elem => (elem.Name == elementName)));

            if (!huntingGrounds.IsAttributeProblem)
            {
                if (forcedTolerance.HasValue)
                {
                    foreach (var waypoint in huntingGrounds.Waypoints)
                    {
                        waypoint.ArrivalTolerance = forcedTolerance.Value;
                    }
                }

                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!huntingGrounds.Waypoints.Any() && (defaultHuntingGroundCenter != null))
                {
                    huntingGrounds.Waypoints.Add(defaultHuntingGroundCenter);
                }

                if (!huntingGrounds.Waypoints.Any())
                {
                    QBCLog.Error("Neither the X/Y/Z attributes nor the <{0}> sub-element has been specified.",
                                 elementName);
                    huntingGrounds.IsAttributeProblem = true;
                }
            }

            return(huntingGrounds);
        }
Beispiel #2
0
            public override int FindIndexOfNextWaypoint(HuntingGroundsType huntingGrounds, int currentWaypointIndex = InvalidWaypointIndex)
            {
                // Current waypoint index is invalid?
                if (currentWaypointIndex == InvalidWaypointIndex)
                {
                    // If no waypoints defined, then nothing to choose from...
                    if (huntingGrounds.Waypoints.Count <= 0)
                    {
                        return(InvalidWaypointIndex);
                    }

                    // Pick initial waypoint--fall through to pick initial waypoint...
                }

                // Determine 'next' waypoint based on visit strategy...
                // NB: If we have more than one point to select from, make certain we don't re-select
                // the current point.
                int newWaypointIndex;

                do
                {
                    newWaypointIndex = StyxWoW.Random.Next(0, huntingGrounds.Waypoints.Count);
                } while ((huntingGrounds.Waypoints.Count > 1) && (currentWaypointIndex == newWaypointIndex));

                return(newWaypointIndex);
            }
Beispiel #3
0
            public override int FindIndexOfNextWaypoint(HuntingGroundsType huntingGrounds, int currentWaypointIndex = InvalidWaypointIndex)
            {
                // Current waypoint index is invalid?
                if (currentWaypointIndex == InvalidWaypointIndex)
                {
                    // If no waypoints defined, then nothing to choose from...
                    if (huntingGrounds.Waypoints.Count <= 0)
                    {
                        return(InvalidWaypointIndex);
                    }

                    // Pick initial waypoint--a random waypoint from those available on the list...
                    return(StyxWoW.Random.Next(0, huntingGrounds.Waypoints.Count));
                }

                // Once waypoint is selected, we continue to use it...
                return(currentWaypointIndex);
            }
        // 11Apr2013-04:42UTC chinajade
        public static HuntingGroundsType GetOrCreate(XElement parentElement, string elementName, WoWPoint?defaultHuntingGroundCenter = null)
        {
            var huntingGrounds = new HuntingGroundsType(parentElement
                                                        .Elements()
                                                        .DefaultIfEmpty(new XElement(elementName))
                                                        .FirstOrDefault(elem => (elem.Name == elementName)));

            if (!huntingGrounds.IsAttributeProblem)
            {
                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!huntingGrounds.Waypoints.Any() && defaultHuntingGroundCenter.HasValue)
                {
                    huntingGrounds.AppendWaypoint(defaultHuntingGroundCenter.Value, "hunting ground center", Navigator.PathPrecision);
                }

                if (!huntingGrounds.Waypoints.Any())
                {
                    QuestBehaviorBase.LogError("Neither the X/Y/Z attributes nor the <{0}> sub-element has been specified.", elementName);
                    huntingGrounds.IsAttributeProblem = true;
                }
            }

            return(huntingGrounds);
        }
Beispiel #5
0
            public override int FindIndexOfNextWaypoint(HuntingGroundsType huntingGrounds, int currentWaypointIndex = InvalidWaypointIndex)
            {
                // Current waypoint index is invalid?
                if (currentWaypointIndex == InvalidWaypointIndex)
                {
                    // If no waypoints defined, then nothing to choose from...
                    if (huntingGrounds.Waypoints.Count <= 0)
                    {
                        return(InvalidWaypointIndex);
                    }

                    // Pick initial waypoint--the nearest one from the list of available waypoints...
                    return(huntingGrounds.FindIndexOfNearestWaypoint(WoWMovement.ActiveMover.Location));
                }

                // Waypoint is simply next one in the list, and wrap around if we've reached the end...
                ++currentWaypointIndex;
                if (currentWaypointIndex >= huntingGrounds.Waypoints.Count)
                {
                    currentWaypointIndex = 0;
                }

                return(currentWaypointIndex);
            }
Beispiel #6
0
        // We must support 'implied containers' for backward compatibility purposes.
        // An 'implied container' is just a list of <Hotspot> without the <HuntingGrounds> container.  As such, we use defaults.
        // This method will first look for the 'new style' (with container), and if that fails, looks for just a list of hotspots with
        // which we can construct the object.
        // 22Apr2013-10:29UTC chinajade
        public static HuntingGroundsType GetOrCreate_ImpliedContainer(XElement parentElement, string elementName, WaypointType defaultHuntingGroundCenter = null)
        {
            var huntingGrounds = GetOrCreate(parentElement, elementName, defaultHuntingGroundCenter);

            // If 'new form' succeeded, we're done...
            if (!huntingGrounds.IsAttributeProblem)
            {
                return(huntingGrounds);
            }

            // 'Old form' we have to dig out the Hotspots manually...
            huntingGrounds = new HuntingGroundsType(new XElement(elementName));
            if (!huntingGrounds.IsAttributeProblem)
            {
                var waypoints = new List <WaypointType>();

                int unnamedWaypointNumber = 0;
                foreach (XElement childElement in parentElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        if (string.IsNullOrEmpty(waypoint.Name))
                        {
                            waypoint.Name = string.Format("UnnamedWaypoint{0}", ++unnamedWaypointNumber);
                        }
                        waypoints.Add(waypoint);
                    }

                    huntingGrounds.IsAttributeProblem |= waypoint.IsAttributeProblem;
                }
            }

            return(huntingGrounds);
        }
Beispiel #7
0
 public abstract int FindIndexOfNextWaypoint(HuntingGroundsType huntingGrounds, int currentWaypointIndex = InvalidWaypointIndex);
        // 11Apr2013-04:42UTC chinajade
        public static HuntingGroundsType GetOrCreate(XElement parentElement, string elementName, WoWPoint? defaultHuntingGroundCenter = null)
        {
            var huntingGrounds = new HuntingGroundsType(parentElement
                                                    .Elements()
                                                    .DefaultIfEmpty(new XElement(elementName))
                                                    .FirstOrDefault(elem => (elem.Name == elementName)));

            if (!huntingGrounds.IsAttributeProblem)
            {
                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!huntingGrounds.Waypoints.Any() && defaultHuntingGroundCenter.HasValue)
                    { huntingGrounds.AppendWaypoint(defaultHuntingGroundCenter.Value, "hunting ground center", Navigator.PathPrecision); }

                if (!huntingGrounds.Waypoints.Any())
                {
                    QuestBehaviorBase.LogError("Neither the X/Y/Z attributes nor the <{0}> sub-element has been specified.", elementName);
                    huntingGrounds.IsAttributeProblem = true;
                }
            }

            return huntingGrounds;
        }