Package com.deco2800.game.areas
Class RandomPointGenerator
java.lang.Object
com.deco2800.game.areas.RandomPointGenerator
Class used to spawn a random point within a certain range of the city center
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.badlogic.gdx.math.GridPoint2
getCityCenter
(AtlantisTerrainFactory terrainFactory) Get the centre of the city as a GridPoint2static com.badlogic.gdx.math.GridPoint2
getRandomPointInIsland
(AtlantisTerrainFactory terrainFactory, int range) Gets a position to deploy entities on the island, the range value is to choose a point such that the entity being placed fits in only island tiles and doesn't end up being spawned at the edges.static com.badlogic.gdx.math.GridPoint2
getRandomPointInRange
(AtlantisTerrainFactory terrainFactory, double scale) Finds a random point within a certain range of the city centre, based on the scale used.static com.badlogic.gdx.math.GridPoint2
getRandomPointInSea
(AtlantisTerrainFactory terrainFactory, int range) Gets a position to deploy entities in the sea, the range value is to choose a point such that the entity being placed fits in only sea tiles and doesn't end up being spawned at the edges.static com.badlogic.gdx.math.GridPoint2
getRescaledBottomRightCorner
(AtlantisTerrainFactory terrainFactory, double scale) Gets the bottom-right corner of the city map after re-scalingstatic int
getRescaledHeight
(AtlantisTerrainFactory terrainFactory, double scale) Gets the re-scaled height of the city mapstatic com.badlogic.gdx.math.GridPoint2
getRescaledTopLeftCorner
(AtlantisTerrainFactory terrainFactory, double scale) Gets the top-left corner of the city map after re-scalingstatic int
getRescaledWidth
(AtlantisTerrainFactory terrainFactory, double scale) Gets the re-scaled width of the city map
-
Constructor Details
-
RandomPointGenerator
public RandomPointGenerator()
-
-
Method Details
-
getCityCenter
Get the centre of the city as a GridPoint2- Parameters:
terrainFactory
- the factory for the Atlantis map- Returns:
- the grid point representing the city center
-
getRescaledWidth
public static int getRescaledWidth(AtlantisTerrainFactory terrainFactory, double scale) throws IllegalArgumentException Gets the re-scaled width of the city map- Parameters:
scale
- the scaling factor for the city map (between 0 and 1)terrainFactory
- the factory for the Atlantis map- Returns:
- the re-scaled width
- Throws:
IllegalArgumentException
-
getRescaledHeight
public static int getRescaledHeight(AtlantisTerrainFactory terrainFactory, double scale) throws IllegalArgumentException Gets the re-scaled height of the city map- Parameters:
scale
- the scaling factor for the city map (between 0 and 1)terrainFactory
- the factory for the Atlantis map- Returns:
- the re-scaled height
- Throws:
IllegalArgumentException
-
getRescaledTopLeftCorner
public static com.badlogic.gdx.math.GridPoint2 getRescaledTopLeftCorner(AtlantisTerrainFactory terrainFactory, double scale) throws IllegalArgumentException Gets the top-left corner of the city map after re-scaling- Parameters:
scale
- the scaling factor for the city map (between 0 and 1)terrainFactory
- the factory for the Atlantis map- Returns:
- the re-scaled top-left corner
- Throws:
IllegalArgumentException
-
getRescaledBottomRightCorner
public static com.badlogic.gdx.math.GridPoint2 getRescaledBottomRightCorner(AtlantisTerrainFactory terrainFactory, double scale) throws IllegalArgumentException Gets the bottom-right corner of the city map after re-scaling- Parameters:
scale
- the scaling factor for the city map (between 0 and 1)terrainFactory
- the factory for the Atlantis map- Returns:
- the re-scaled bottom-right corner
- Throws:
IllegalArgumentException
-
getRandomPointInRange
public static com.badlogic.gdx.math.GridPoint2 getRandomPointInRange(AtlantisTerrainFactory terrainFactory, double scale) throws IllegalArgumentException Finds a random point within a certain range of the city centre, based on the scale used. If scale = 0.0, then the city center is returned. If scale = 1.0, then the entire city map is used.- Parameters:
scale
- the scaling factor for the city map (between 0 and 1)terrainFactory
- the factory for the Atlantis map- Returns:
- a random point in the range
- Throws:
IllegalArgumentException
-
getRandomPointInSea
public static com.badlogic.gdx.math.GridPoint2 getRandomPointInSea(AtlantisTerrainFactory terrainFactory, int range) Gets a position to deploy entities in the sea, the range value is to choose a point such that the entity being placed fits in only sea tiles and doesn't end up being spawned at the edges.- Parameters:
terrainFactory
- the factory for the Atlantis maprange
- points within this range must be ocean tiles.- Returns:
-
getRandomPointInIsland
public static com.badlogic.gdx.math.GridPoint2 getRandomPointInIsland(AtlantisTerrainFactory terrainFactory, int range) Gets a position to deploy entities on the island, the range value is to choose a point such that the entity being placed fits in only island tiles and doesn't end up being spawned at the edges.- Parameters:
terrainFactory
- the factory for the Atlantis maprange
- points within this range must be island tiles.- Returns:
-