The 2D grid that will be used for the path finding
More...
|
Vector3 | GetTileWorldCoordinate (string coordinate) |
|
void | MoveDrone () |
| This is meant to be called from a button in the UI This method does: More...
|
|
PathReturn | GetShortestPath (string[] positions) |
|
PathReturn | GetShortestPath (string startPosition, string endPosition) |
| Find the shortest paths between start and end using Dijkstras algorithm All paths to start node are automatically cached so if it is asked again, there's no need to recalculate it More...
|
|
|
string | url = "https://mocki.io/v1/10404696-fd43-4481-a7ed-f9369073252f" |
|
ParsedData | parsed |
|
|
void | PushToHistory (string entry) |
|
void | Awake () |
| This is a default unity function, it is called when the object is instantiated into the scene
|
|
void | SetColor (string coords, Color color) |
| Set color of a tile based o it's coordinates
|
|
IEnumerator | DownloadAndParseGridData (string url) |
| Download and parse the API
|
|
void | GenerateGrid (ParsedData parsed) |
| Generate grid based on the parsed API
|
|
TileData | GetOrCreateTile (string key) |
| Return an already created tile or create a new one if a tile with the coordinates does not already exist More...
|
|
Vector3 | FromLetterNumberToVector (string letterAndNumber) |
| Transform letter and number coordinate system to a Vector to be used by Unity later
|
|
CachedPath | FindAllPathsFrom (string startPosition) |
| Find all paths to the start position using Dijkstras algorithm This is necessary because the API only have seconds instead of distance, which we can use as weight if we had distance information, we could use A* which is more effective
|
|
Dictionary< string, float > | GetNeighbors (string coordinates) |
| Get all neighbors of the tile More...
|
|
|
readonly Dictionary< string, CachedPath > | _cachedPaths = new() |
|
List< string > | _pathHistory = new() |
|
Tile | _tilePrefab |
|
Connector | _connectorPrefab |
|
Drone | _drone |
|
TMP_InputField | _startCoordinateInput |
|
TMP_InputField | _pickupCoordinateInput |
|
TMP_InputField | _dropOffCoordinateInput |
|
TextMeshProUGUI | _pathElement |
|
TextMeshProUGUI | _pathHistoryUi |
|
TextMeshProUGUI | _loading |
|
readonly HashSet< Tile > | _changedColorsTiles = new() |
|
readonly Dictionary< char, int > | _letterToInt |
| Dict used to convert from letters to numbers More...
|
|
Dictionary< string, TileData > | _allTilesData |
|
Dictionary< string, Tile > | _allTiles |
|
string | _lastPath |
|
The 2D grid that will be used for the path finding
◆ GetNeighbors()
Dictionary< string, float > DroneGame.Grid.GetNeighbors |
( |
string |
coordinates | ) |
|
|
private |
Get all neighbors of the tile
◆ GetOrCreateTile()
TileData DroneGame.Grid.GetOrCreateTile |
( |
string |
key | ) |
|
|
inlineprivate |
Return an already created tile or create a new one if a tile with the coordinates does not already exist
- Parameters
-
key | The coordinate in the format A2 |
- Returns
- A brand new or already existing Tile
◆ GetShortestPath()
PathReturn DroneGame.Grid.GetShortestPath |
( |
string |
startPosition, |
|
|
string |
endPosition |
|
) |
| |
|
inline |
Find the shortest paths between start and end using Dijkstras algorithm All paths to start node are automatically cached so if it is asked again, there's no need to recalculate it
- See also
- FindAllPathsFrom
◆ MoveDrone()
void DroneGame.Grid.MoveDrone |
( |
| ) |
|
|
inline |
This is meant to be called from a button in the UI This method does:
- Set some colors for a couple tiles
- Get inputs from the UI
- Call the pathfinding functions
- Start the drone Coroutine that makes it move
◆ _letterToInt
readonly Dictionary<char, int> DroneGame.Grid._letterToInt |
|
private |
Initial value:= new(){
{'A', 0},
{'B', 1},
{'C', 2},
{'D', 3},
{'E', 4},
{'F', 5},
{'G', 6},
{'H', 7}
}
Dict used to convert from letters to numbers
The documentation for this class was generated from the following file: