private List <Vector2f> Astar(Field2D field_0, bool flag_1) { for (; pathes.Count > 0;) { AStarFinder.ScoredPath spath_2 = (AStarFinder.ScoredPath)CollectionUtils.RemoveAt(pathes, 0); Vector2f current = spath_2.path[spath_2.path.Count - 1]; if (current.Equals(goal)) { return(spath_2.path); } List <Vector2f> list = field_0.Neighbors(current, flag_1); int size = list.Count; for (int i = 0; i < size; i++) { Vector2f next = list[i]; if (CollectionUtils.Contains(next, visitedCache)) { continue; } CollectionUtils.Add(visitedCache, next); if (!field_0.IsHit(next) && !flying) { continue; } List <Vector2f> path_3 = new List <Vector2f>(spath_2.path); CollectionUtils.Add(path_3, next); float score = spath_2.score + findHeuristic .GetScore(goal.x, goal.y, next.x, next.y); Insert(score, path_3); } } return(null); }
private List<Vector2f> Astar(Field2D field_0, bool flag_1) { for (; pathes.Count > 0; ) { AStarFinder.ScoredPath spath_2 = (AStarFinder.ScoredPath)CollectionUtils.RemoveAt(pathes, 0); Vector2f current = spath_2.path[spath_2.path.Count - 1]; if (current.Equals(goal)) { return spath_2.path; } List<Vector2f> list = field_0.Neighbors(current, flag_1); int size = list.Count; for (int i = 0; i < size; i++) { Vector2f next = list[i]; if (CollectionUtils.Contains(next, visitedCache)) { continue; } CollectionUtils.Add(visitedCache, next); if (!field_0.IsHit(next) && !flying) { continue; } List<Vector2f> path_3 = new List<Vector2f>(spath_2.path); CollectionUtils.Add(path_3, next); float score = spath_2.score + findHeuristic .GetScore(goal.x, goal.y, next.x, next.y); Insert(score, path_3); } } return null; }
public bool IsHit(int px, int py) { return(field.IsHit(px, py)); }