Class TerrainFactory

java.lang.Object
com.csse3200.game.areas.terrain.TerrainFactory

public class TerrainFactory extends Object
Factory for creating game terrains.
  • Field Details

    • WORLD_TILE_SIZE

      public static final float WORLD_TILE_SIZE
      The tile size constant used for each tile in the TiledMap class
      See Also:
    • MAP_PATH

      protected static final String MAP_PATH
      The file path for the SpaceGameArea map file
      See Also:
    • charToTileImageMap

      protected static final Map<Character,String> charToTileImageMap
      HashMap used to map characters in map files to file paths containing their textures
  • Constructor Details

    • TerrainFactory

      public TerrainFactory(CameraComponent cameraComponent)
      Create a terrain factory with Orthogonal orientation.
      Parameters:
      cameraComponent - Camera to render terrains to. Must be orthographic.
    • TerrainFactory

      public TerrainFactory(CameraComponent cameraComponent, TerrainComponent.TerrainOrientation orientation)
      Create a terrain factory
      Parameters:
      cameraComponent - Camera to render terrains to. Must be orthographic.
      orientation - orientation to render terrain at.
  • Method Details

    • getMapTextures

      public static String[] getMapTextures()
    • isNumeric

      public static boolean isNumeric(String strNum)
      This function will be used to check if a string is numeric.
      Parameters:
      strNum - the string to be checked.
      Returns:
      false if the string is not numeric, else return true.
    • loadTextures

      public void loadTextures()
      Loads textures into the charToTextureMap based upon the images within the charToTileImageMap and resourceService.
    • getMapSize

      public com.badlogic.gdx.math.GridPoint2 getMapSize()
      Returns a copy of the MAP_SIZE variable.
      Returns:
      GridPoint2 instance representing Map Size.
    • createSpaceGameTerrain

      public TerrainComponent createSpaceGameTerrain(com.badlogic.gdx.maps.tiled.TiledMap tiledMap)
      Initiates the create terrain process for the SpaceGameArea.
      Parameters:
      tiledMap - the TiledMap instance of the game map.
      Returns:
      Terrain component which renders the terrain.
    • createTestTerrain

      public TerrainComponent createTestTerrain(com.badlogic.gdx.maps.tiled.TiledMap tiledMap, String testMapFilePath)
      Initiates the create terrain process for play testing different maps.
      Parameters:
      tiledMap - the TiledMap instance of the test game map.
      testMapFilePath - the file path of the test map file to be loaded.
      Returns:
      Terrain component which renders the terrain.
    • loadTiledMap

      public void loadTiledMap(com.badlogic.gdx.maps.tiled.TiledMap tiledMap, String mapFilePath)
      Finishes the create terrain process, loading the map into the TiledMap instance.
      Parameters:
      tiledMap - the TiledMap instance of the test game map.
      mapFilePath - the file path of the map file to be loaded.