Package tech.underoaks.coldcase
Class MapGenerator
java.lang.Object
tech.underoaks.coldcase.MapGenerator
Class for generating maps from text files.
It provides methods for serializing and deserializing maps to and from JSON.
The JSON format used is the one provided by the Json class provided by libGDX.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MapdeserializeMap(String jsonMap) Deserializes aMapobject from JSON format.static MapserializeContentToMap(Path path, boolean isDetective) Serializes the map from text files to JSON format.static StringserializeMapToJson(Map map) Serializes aMapobject to JSON format.
-
Constructor Details
-
MapGenerator
public MapGenerator()
-
-
Method Details
-
serializeContentToMap
Serializes the map from text files to JSON format.The map is read from the text files located at the given path.
- Parameters:
path- The path to the directory containing the map text files. The map files should be named "map.detective" and "map.ghost".isDetective- Whether the map is for the detective or the ghost. If true, the detective map is serialized. Otherwise, the ghost map is serialized.- Returns:
- A
MapObject.
-
serializeMapToJson
Serializes aMapobject to JSON format. This is planed to be used for saving the Map to a file. Note that this does not include the PlayerController or the GameController which are not part of the Map.- Parameters:
map- TheMapto serialize.- Returns:
- The resulting JSON-String
-
deserializeMap
Deserializes aMapobject from JSON format.- Parameters:
jsonMap- The JSON string to deserialize.- Returns:
- The deserialized
Mapobject.
-