internal List <Vector3Int> GetPathBetween(Vector3Int startPosition, Vector3Int endPosition) { var resultPath = GridSearch.AStarSearch(placementGrid, new Point(startPosition.x, startPosition.z), new Point(endPosition.x, endPosition.z)); List <Vector3Int> path = new List <Vector3Int>(); foreach (Point point in resultPath) { path.Add(new Vector3Int(point.X, 0, point.Y)); } return(path); }
internal List <Vector3Int> GetPathBetween(Vector3Int startPos, Vector3Int endPos) { var resultPath = GridSearch.AStarSearch(placementGrid, new Point(startPos.x, startPos.z), new Point(endPos.x, endPos.z)); // list of point toward the end pos List <Vector3Int> path = new List <Vector3Int>(); foreach (Point point in resultPath) { path.Add(new Vector3Int(point.X, 0, point.Y)); // add point to Vector3 list } return(path); }
private void GetNewPath(Point ghostPosition, Point playerPosition) { List <Point> path = null; switch (_AIState) { case GhostAIState.Random: path = GridSearch.BestFirstSearch(_grid, ghostPosition, _grid.GetRandomOpenPoint()).Path; break; case GhostAIState.TargetingWithLag: path = GridSearch.AStarSearch(_grid, ghostPosition, playerPosition).Path; break; case GhostAIState.Fleeing: var result = GridSearch.DijkstraGeneral(_grid, playerPosition); Point best = null; float largestDist = 0; foreach (Point k in result.DistanceMap.Keys) { if (result.DistanceMap[k] > largestDist) { best = k; largestDist = result.DistanceMap[k]; } } Dictionary <Point, float> costMap = InvertCostMap(result.DistanceMap, largestDist); path = GridSearch.AStarSearchWithCost(_grid, ghostPosition, best, costMap).Path; break; } _pathList = new Stack <Point>(path); }