Exemple #1
0
        public PositionsInfo()
        {
            ownBasePos       = null;
            enemyBasePos     = null;
            visitedNavPoints = new List <string>();
            chosenNavPoint   = null;
            ourFlagInfo      = new Dictionary <string, string>();
            enemyFlagInfo    = new Dictionary <string, string>();

            pathHome        = new Dictionary <int, Vector3>();
            pathToEnemyBase = new Dictionary <int, Vector3>();

            TooCloseForPath = 0L;
        }
Exemple #2
0
 public float DistanceFrom(NavPoint target)
 {
     return Location.DistanceFrom(target.Location);
 }
Exemple #3
0
 public float Distance2DFrom(NavPoint target, Vector3.Orientation orientation)
 {
     return Location.Distance2DFrom(target.Location, orientation);
 }
Exemple #4
0
        /// <summary>
        /// lists of nav points arrive as dicts with an "ID" key and keys "0", "1", .... "n" these need converting to lists
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static NavPoint ConvertToNavPoint(Dictionary<string, string> dictRawNP)
        {
            NavPoint location = new NavPoint();

            // now get a list of just keys, and sort it to use in extracting the key:value pairs
            Dictionary<string, string>.KeyCollection keyList = dictRawNP.Keys;

            // debug
            if (dictRawNP.ContainsKey("Reachable"))
            {
                //Console.Out.WriteLine(dictRawNP.ToString());
                //Console.Out.WriteLine("-------");
            }

            IOrderedEnumerable<string> sortedList =
                keyList.OrderBy(key => key.Length).ThenBy(key => key);

            foreach (string key in sortedList)
            {
                string locString = dictRawNP[key];
                switch (key)
                {
                    case "Id":
                        location.Id = locString.Trim();
                        break;
                    case "Location":
                        location.Location = Vector3.ConvertToVector3(locString);
                        break;
                    case "Visible":
                        location.Visible = bool.Parse(locString.Trim());
                        break;
                    case "Reachable":
                        location.Reachable = bool.Parse(locString.Trim());
                        break;
                    case "Item":
                        location.Item = locString.Trim();
                        break;
                    case "ItemClass":
                        location.ItemClass = locString.Trim();
                        break;
                    case "Flag":
                        location.Type = locString.Trim();
                        break;
                    case "Rotation":
                        location.Rotation = Vector3.ConvertToVector3(locString);
                        break;
                    default:
                        break;

                }
            }

            return location;
        }
Exemple #5
0
        ///
        /// SENSES
        /// 
        private bool atTargetLocation(NavPoint target, int distanceTolerance)
        {
            if (!GetBot().info.ContainsKey("Location"))
                return false;
            Vector3 location = Vector3.ConvertToVector3(GetBot().info["Location"]);

            if (target == null)
                return false;
            else
            {
                // this distance may need adjusting in future (we may also wish to consider the Z axis)
                if (location.DistanceFrom(target.Location) < distanceTolerance)
                    return true;
                else
                    return false;
            }
        }
Exemple #6
0
        internal NavPoint[] GetReachableNavPoints(NavPoint[] navPoints, int distanceTolerance, Vector3 target)
        {
            List<NavPoint> result = new List<NavPoint>();

            foreach (NavPoint currentNP in navPoints)
                if (currentNP.Reachable && currentNP.Distance2DFrom(target, Vector3.Orientation.XY) > distanceTolerance)
                    result.Add(currentNP);

            return result.ToArray();
        }
Exemple #7
0
        /// <summary>
        /// lists of nav points arrive as dicts with an "ID" key and keys "0", "1", .... "n" these need converting to lists
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static NavPoint ConvertToNavPoint(Dictionary <string, string> dictRawNP)
        {
            NavPoint location = new NavPoint();

            // now get a list of just keys, and sort it to use in extracting the key:value pairs
            Dictionary <string, string> .KeyCollection keyList = dictRawNP.Keys;

            // debug
            if (dictRawNP.ContainsKey("Reachable"))
            {
                //Console.Out.WriteLine(dictRawNP.ToString());
                //Console.Out.WriteLine("-------");
            }

            IOrderedEnumerable <string> sortedList =
                keyList.OrderBy(key => key.Length).ThenBy(key => key);

            foreach (string key in sortedList)
            {
                string locString = dictRawNP[key];
                switch (key)
                {
                case "Id":
                    location.Id = locString.Trim();
                    break;

                case "Location":
                    location.Location = Vector3.ConvertToVector3(locString);
                    break;

                case "Visible":
                    location.Visible = bool.Parse(locString.Trim());
                    break;

                case "Reachable":
                    location.Reachable = bool.Parse(locString.Trim());
                    break;

                case "Item":
                    location.Item = locString.Trim();
                    break;

                case "ItemClass":
                    location.ItemClass = locString.Trim();
                    break;

                case "Flag":
                    location.Type = locString.Trim();
                    break;

                case "Rotation":
                    location.Rotation = Vector3.ConvertToVector3(locString);
                    break;

                default:
                    break;
                }
            }

            return(location);
        }
Exemple #8
0
 public float DistanceFrom(NavPoint target)
 {
     return(Location.DistanceFrom(target.Location));
 }
Exemple #9
0
 public float Distance2DFrom(NavPoint target, Vector3.Orientation orientation)
 {
     return(Location.Distance2DFrom(target.Location, orientation));
 }