public override List <WayNode> GetSurround(Map map, WayNode center) { var result = new List <WayNode>(); var centerPos = center.Current; var lPos = centerPos + new int2(-1, 0); var rPos = centerPos + new int2(1, 0); var uPos = centerPos + new int2(0, 1); var dPos = centerPos + new int2(0, -1); if (map.Avaliable(lPos) && map.FindWayData[lPos].Walkable) { if (!WayNodes.ContainsKey(lPos)) { WayNodes[lPos] = new AStarWayNode(lPos, new int2(-1, -1)); } result.Add(this[lPos]); } if (map.Avaliable(rPos) && map.FindWayData[rPos].Walkable) { if (!WayNodes.ContainsKey(rPos)) { WayNodes[rPos] = new AStarWayNode(rPos, new int2(-1, -1)); } result.Add(this[rPos]); } if (map.Avaliable(uPos) && map.FindWayData[uPos].Walkable) { if (!WayNodes.ContainsKey(uPos)) { WayNodes[uPos] = new AStarWayNode(uPos, new int2(-1, -1)); } result.Add(this[uPos]); } if (map.Avaliable(dPos) && map.FindWayData[dPos].Walkable) { if (!WayNodes.ContainsKey(dPos)) { WayNodes[dPos] = new AStarWayNode(dPos, new int2(-1, -1)); } result.Add(this[dPos]); } return(result); }
public List <long> GetWayNodesFromTo(long from, long to) { int fromIndex = WayNodes.IndexOf(from); int toIndex = WayNodes.IndexOf(to); if (fromIndex < toIndex) { return(WayNodes.GetRange(fromIndex, toIndex - fromIndex + 1)); } if (fromIndex > toIndex) { List <long> result = WayNodes.GetRange(toIndex, fromIndex - toIndex + 1); result.Reverse(); return(result); } UnityEngine.Debug.Log("GetWayNodesFromTo returned null"); return(null); }
public bool ContainsNode(long id) { return(WayNodes.Contains(id)); }
public bool ContainsNode(OSMNode node) { return(WayNodes.Contains(node.Id)); }