Class MapGenerator

java.lang.Object
tech.underoaks.coldcase.MapGenerator

public final class MapGenerator extends Object
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 Details

    • MapGenerator

      public MapGenerator()
  • Method Details

    • serializeContentToMap

      public static Map serializeContentToMap(Path path, boolean isDetective)
      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 Map Object.
    • serializeMapToJson

      public static String serializeMapToJson(Map map)
      Serializes a Map object 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 - The Map to serialize.
      Returns:
      The resulting JSON-String
    • deserializeMap

      public static Map deserializeMap(String jsonMap)
      Deserializes a Map object from JSON format.
      Parameters:
      jsonMap - The JSON string to deserialize.
      Returns:
      The deserialized Map object.