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; }
public float DistanceFrom(NavPoint target) { return Location.DistanceFrom(target.Location); }
public float Distance2DFrom(NavPoint target, Vector3.Orientation orientation) { return Location.Distance2DFrom(target.Location, orientation); }
/// <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; }
/// /// 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; } }
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(); }
/// <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); }
public float DistanceFrom(NavPoint target) { return(Location.DistanceFrom(target.Location)); }
public float Distance2DFrom(NavPoint target, Vector3.Orientation orientation) { return(Location.Distance2DFrom(target.Location, orientation)); }