Package com.csse3200.game.areas
Class GameArea
java.lang.Object
com.csse3200.game.areas.GameArea
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
- Direct Known Subclasses:
ElevatorGameArea
,FlyingBossRoom
,ForestGameArea
,MainHall
,MovingBossRoom
,OfficeGameArea
,Reception
,ResearchGameArea
,SecurityGameArea
,ServerGameArea
,ShippingGameArea
,StaticBossRoom
,StorageGameArea
,TunnelGameArea
Represents an area in the game, such as a level, indoor area, etc. An area has a terrain and
other entities to spawn on that terrain.
Support for enabling/disabling game areas could be added by making this a Component instead.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record
Camera bounds helper. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected float
protected CameraComponent
protected static boolean
Prevents re-entrant room transitions across areasprotected static int
protected TerrainComponent
protected TerrainFactory
protected EnemyWaves
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
GameArea
(TerrainFactory terrainFactory, CameraComponent cameraComponent) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addSolidWallBottom
(GameArea.Bounds b, float wallWidth) protected void
addSolidWallLeft
(GameArea.Bounds b, float wallWidth) Solid walls on edges.protected void
addSolidWallRight
(GameArea.Bounds b, float wallWidth) protected void
addSolidWallTop
(GameArea.Bounds b, float wallWidth) protected void
addVerticalDoorLeft
(GameArea.Bounds b, float wallWidth, Runnable onEnter) Add a vertical door on the left edge, splitting the wall into two segments.protected void
addVerticalDoorRight
(GameArea.Bounds b, float wallWidth, Runnable onEnter) Add a vertical door on the right edge.protected boolean
Attempt to start a room transition.protected void
clearAndLoad
(Supplier<GameArea> nextAreaSupplier) Helper to clear current entities and transition to a new area.abstract void
create()
Create the game area in the world.void
dispose()
Dispose of all internal entities in the areaprotected void
Mark the end of a room transition.protected void
Ensure the common player atlas is available.protected void
ensureTextures
(String[] texturePaths) Convenience to load textures if not already loaded.float
Returns the base difficulty scale of the current room.protected GameArea.Bounds
getCameraBounds
(CameraComponent cameraComponent) getEnemySpawnPosition
(int roomNumber) Gets all the current entitiesabstract Entity
allows manipulation of player character by loading functionint
Returns the room number corresponding to the current floor.protected com.badlogic.gdx.math.Vector2
getRoomSpawnPosition
(String roomName) protected <T extends GameArea>
voidvoid
removeEntity
(Entity entity) Remove an entityprotected void
setupTerrainWithOverlay
(TerrainFactory factory, TerrainFactory.TerrainType type, com.badlogic.gdx.graphics.Color overlayColor) Create terrain of a given type and add an optional color overlay.void
spawnDeepspin
(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds DeepSpin enemies onto the map.void
spawnEnemies
(int roomNumber, int total, float scaleFactor, Entity player) Spawns the enemies based on the room number given.void
spawnEntity
(Entity entity) Spawn entity at its current positionprotected void
spawnEntityAt
(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY) void
spawnEntityInRoom
(String roomName, Entity entity) Spawn an entity inside the specified room.protected void
void
spawnGhostGPT
(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds GhostGPT enemies onto the map.spawnGhostGPTProjectile
(com.badlogic.gdx.math.Vector2 directionToFire, WeaponsStatsComponent source) Spawns the projectile used by the Ghost GPT Enemyvoid
spawnGrokDroid
(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds GrokDroid enemies onto the map.void
protected void
spawnObjectDoors
(com.badlogic.gdx.math.GridPoint2 leftDoorPos, com.badlogic.gdx.math.GridPoint2 rightDoorPos) Spawns decorative object doors (non-functional) at given positions.void
spawnTurret
(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds Turret enemies onto the map.void
spawnVroomba
(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds Vroomba enemies onto the map.void
startWaves
(Entity player) Start enemy waves from terminal command by typing "waves".toString()
protected void
unloadAssets
(String[] assetPaths) Unload a set of assets if loaded.
-
Field Details
-
terrain
-
areaEntities
-
terrainFactory
-
cameraComponent
-
baseScaling
protected float baseScaling -
isTransitioning
protected static boolean isTransitioningPrevents re-entrant room transitions across areas -
wavesManager
-
roomNumber
protected static int roomNumber
-
-
Constructor Details
-
GameArea
-
-
Method Details
-
create
public abstract void create()Create the game area in the world. -
dispose
public void dispose()Dispose of all internal entities in the area- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
beginTransition
protected boolean beginTransition()Attempt to start a room transition. Returns false if one is already in progress. -
endTransition
protected void endTransition()Mark the end of a room transition. -
spawnEntity
Spawn entity at its current position- Parameters:
entity
- Entity (not yet registered)
-
spawnFloor
protected void spawnFloor() -
startWaves
Start enemy waves from terminal command by typing "waves". -
getRoomNumber
public int getRoomNumber()Returns the room number corresponding to the current floor.- Returns:
- Room number as an int if the floor name is in the format "Floor2" with 2 being any number, otherwise returns 1.
-
getBaseDifficultyScale
public float getBaseDifficultyScale()Returns the base difficulty scale of the current room.- Returns:
- Scaling factor as a float.
-
spawnEntityAt
protected void spawnEntityAt(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY) -
spawnEnemies
Spawns the enemies based on the room number given.- Parameters:
roomNumber
- The number of the current floor/room.total
- The total number of enemies to be spawned.scaleFactor
- The scaling factor of the difficulty of the enemies to be spawned.player
- The playerEntity
that is to be target by the enemies.
-
spawnGhostGPT
public void spawnGhostGPT(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds GhostGPT enemies onto the map.- Parameters:
total
- The total number of GhostGPT to be spawned.scaleFactor
- The scale of increase in difficulty of the GhostGPT
-
spawnDeepspin
public void spawnDeepspin(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds DeepSpin enemies onto the map.- Parameters:
total
- The total number of DeepSpins to be spawned.scaleFactor
- The scale of increase in difficulty of the DeepSpin
-
spawnGrokDroid
public void spawnGrokDroid(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds GrokDroid enemies onto the map.- Parameters:
total
- The total number of GrokDroid to be spawned.scaleFactor
- The scale of increase in difficulty of the GrokDroid
-
spawnVroomba
public void spawnVroomba(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds Vroomba enemies onto the map.- Parameters:
total
- The total number of Vroomba to be spawned.scaleFactor
- The scale of increase in difficulty of the Vroomba
-
spawnTurret
public void spawnTurret(int total, float scaleFactor, Entity player, Map<String, ArrayList<com.badlogic.gdx.math.Vector2>> positions) Adds Turret enemies onto the map.- Parameters:
total
- The total number of Turret to be spawned.scaleFactor
- The scale of increase in difficulty of the GhostGPT
-
spawnGhostGPTProjectile
public Entity spawnGhostGPTProjectile(com.badlogic.gdx.math.Vector2 directionToFire, WeaponsStatsComponent source) Spawns the projectile used by the Ghost GPT Enemy- Parameters:
directionToFire
- The direction in which the projectile is to be fired.source
- The damage and other statistics that the projectile will use.- Returns:
- The spawned projectile
Entity
-
getEnemySpawnPosition
-
removeEntity
Remove an entity- Parameters:
entity
- to be removed
-
getEntities
Gets all the current entities- Returns:
- the entities on the map
-
spawnEntityInRoom
Spawn an entity inside the specified room. Requires the terrain to be set first.- Parameters:
entity
- entity to spawn (not yet registered)
-
getRoomSpawnPosition
-
ensureTextures
Convenience to load textures if not already loaded. -
ensurePlayerAtlas
protected void ensurePlayerAtlas()Ensure the common player atlas is available. -
unloadAssets
Unload a set of assets if loaded. -
setupTerrainWithOverlay
protected void setupTerrainWithOverlay(TerrainFactory factory, TerrainFactory.TerrainType type, com.badlogic.gdx.graphics.Color overlayColor) Create terrain of a given type and add an optional color overlay. -
getCameraBounds
-
addSolidWallLeft
Solid walls on edges. -
addSolidWallRight
-
addSolidWallTop
-
addSolidWallBottom
-
addVerticalDoorLeft
Add a vertical door on the left edge, splitting the wall into two segments. -
addVerticalDoorRight
Add a vertical door on the right edge. -
loadArea
-
clearAndLoad
Helper to clear current entities and transition to a new area. -
spawnObjectDoors
protected void spawnObjectDoors(com.badlogic.gdx.math.GridPoint2 leftDoorPos, com.badlogic.gdx.math.GridPoint2 rightDoorPos) Spawns decorative object doors (non-functional) at given positions.- Parameters:
leftDoorPos
- grid position for the left/bottom decorative doorrightDoorPos
- grid position for the right/top decorative door
-
spawnItem
-
toString
-
getPlayer
allows manipulation of player character by loading function- Returns:
- player entity
-