Package com.csse3200.game.areas.forest
Class ForestGameArea
java.lang.Object
com.csse3200.game.areas.GameArea
com.csse3200.game.areas.forest.ForestGameArea
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Forest area for the demo game with trees, a player, and some enemies.
-
Field Summary
FieldsFields inherited from class com.csse3200.game.areas.GameArea
areaEntities, terrain
-
Constructor Summary
ConstructorsConstructorDescriptionForestGameArea
(TerrainFactory terrainFactory, GdxGame game) Initialise this ForestGameArea to use the provided TerrainFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Create the game area, including terrain, static entities (trees), dynamic entities (player and NPCs), and uivoid
void
dispose()
Dispose of all internal entities in the areagets the playervoid
void
void
void
spawnConvertedNPCs
(Entity defeatedEnemy) Spawns defeated enemy NPCs are friendly NPCs in the same/similar locationvoid
spawnEntityNearPlayer
(Entity entity, int radius) Spawns an entity near the player within a specified radius, ensuring the entity is placed within the correct chunk boundaries and loaded areas of the game map.void
void
unlockArea
(String area) Unlock an area of the mapMethods inherited from class com.csse3200.game.areas.GameArea
spawnEntity, spawnEntityAt, spawnEntityAtVector, spawnEntityCenteredAt
-
Field Details
-
MAP_SIZE
public static final com.badlogic.gdx.math.GridPoint2 MAP_SIZE
-
-
Constructor Details
-
ForestGameArea
Initialise this ForestGameArea to use the provided TerrainFactory. Precondition: terrainFactory is not null- Parameters:
terrainFactory
- TerrainFactory used to create the terrain for the GameArea.game
- GdxGame needed for creating the player
-
-
Method Details
-
create
public void create()Create the game area, including terrain, static entities (trees), dynamic entities (player and NPCs), and ui -
unlockArea
Unlock an area of the map- Overrides:
unlockArea
in classGameArea
-
getPlayer
gets the player -
displayUI
public void displayUI() -
spawnEntityNearPlayer
Spawns an entity near the player within a specified radius, ensuring the entity is placed within the correct chunk boundaries and loaded areas of the game map. This function calculates a valid spawn position near the player's current location, considering the player's world position and current chunk. It ensures that the entity is spawned within the boundaries of the current chunk to avoid positioning the entity in an unloaded or inaccessible area.- Parameters:
entity
- The entity to be spawned near the player.radius
- The radius around the player's position within which the entity will be spawned. The spawn position is randomly selected within this radius but is constrained to be within the current chunk boundaries.
-
spawnConvertedNPCs
Spawns defeated enemy NPCs are friendly NPCs in the same/similar location- Overrides:
spawnConvertedNPCs
in classGameArea
- Parameters:
defeatedEnemy
- the entity that has been defeated in combat
-
playMusic
public void playMusic() -
pauseMusic
public void pauseMusic()- Specified by:
pauseMusic
in classGameArea
-
loadAssets
public void loadAssets() -
unloadAssets
public void unloadAssets()- Specified by:
unloadAssets
in classGameArea
-
dispose
public void dispose()Description copied from class:GameArea
Dispose of all internal entities in the area -
getEnemies
- Specified by:
getEnemies
in classGameArea
-
getBosses
-
getFriendlyNPCs
- Specified by:
getFriendlyNPCs
in classGameArea
-
getMinigameNPCs
- Specified by:
getMinigameNPCs
in classGameArea
-
getDynamicItems
-