public final class MapManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MapManager.Point
Simple and general class that consists of two final integer values.
|
Modifier and Type | Method and Description |
---|---|
static MapManager.Point |
coordinatesToPoint(Coordinates coords)
Conversion from coordinates to configuration file numbering.
|
static void |
createMap(java.lang.String[][] mapGrid)
Creates the map by allocating the tiles depending on the character wrote
in the .txt file.
|
static int |
getColumns()
Returns the columns of the map matrix.
|
static MapManager |
getInstance()
Returns the singleton of the class if it has been allocated yet,
otherwise calls the constructor of the class which allocates the
singleton and returns it.
|
static int |
getRows()
Returns the rows of the map matrix.
|
java.util.List<MapManager.Point> |
getSpawnPoints()
Return all spawn points of the map with the same numbering used in configuration file.
|
static java.lang.String[][] |
loadMap(java.lang.String mapPath)
Method to load a map from its absolute path.
|
static Coordinates |
pointToCoordinates(MapManager.Point point)
Conversion from coordinates to configuration file numbering.
|
void |
searchSpecialTiles()
Iterates the matrix mapping the map in search of tiles to be grouped such
as
Roads.TrafficLight and Roads.Zebra . |
void |
startSimulation()
Starts the simulation if it hasn't been started yet, otherwise it does
anything, so it can't mess the current simulation.
|
public static MapManager getInstance()
public static java.lang.String[][] loadMap(java.lang.String mapPath)
mapPath
- Path of the map to be loadedpublic java.util.List<MapManager.Point> getSpawnPoints()
public static MapManager.Point coordinatesToPoint(Coordinates coords)
coords
- coordinates to be convertedpublic static Coordinates pointToCoordinates(MapManager.Point point)
point
- values to be convertedpublic static int getRows()
public static int getColumns()
public static void createMap(java.lang.String[][] mapGrid)
Coordinates
class for
the X and Y values.mapGrid
- the String matrix taken from the .txt filepublic void startSimulation()
Timer.schedule
method on the thread charged of handling the
traffic light, allocating a new TimerTask
object and calling the
routine every second.Thread.start
method on
the thread charged of handling the zebra crossings.MapManager.started
field to true.Notes:
public void searchSpecialTiles()
Roads.TrafficLight
and Roads.Zebra
.