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:
CaveGameArea
,CutsceneArea
,ForestGameArea
,LevelOneGameArea
,LevelTwoGameArea
,SprintOneGameArea
,TemplateGameArea
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CombatStatsComponent
protected InventoryComponent
protected Entity
protected TerrainComponent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Create the game area, including terrain, static entities (trees), dynamic entities (player)protected void
createMinimap
(com.badlogic.gdx.graphics.Texture minimapTexture) Creates and adds the minimap display to the given game area.void
createWithPlayer
(Entity oldPlayer) Create the game area using components from a different player entity.void
dispose()
Dispose of all internal entities in the areaGet copies all of the player components we want to transfer in between resets/levels.protected abstract void
Loads assetsprotected abstract void
Loads all entities in a given areaprotected abstract void
Loads prerequisites for each area.protected void
reset()
Resets the game areavoid
saveComponents
(CombatStatsComponent combatStats, InventoryComponent inventory) Save a copy of all of the components we want to store for resets/level switches.protected void
spawnEntity
(Entity entity) Spawn entity at its current positionprotected void
spawnEntityAt
(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY) Spawn entity on a given tile.protected abstract Entity
Spawns playerprotected abstract Entity
spawnPlayer
(List<Component> componentList) Spawns player with previous componentsvoid
-
Field Details
-
terrain
-
areaEntities
-
player
-
combatStats
-
inventory
-
-
Constructor Details
-
GameArea
protected GameArea()
-
-
Method Details
-
getEvents
-
trigger
-
create
public void create()Create the game area, including terrain, static entities (trees), dynamic entities (player) -
createWithPlayer
Create the game area using components from a different player entity.- Parameters:
oldPlayer
-
-
reset
protected void reset()Resets the game area -
loadPrerequisites
protected abstract void loadPrerequisites()Loads prerequisites for each area. Music, sounds, terrain etc -
loadEntities
protected abstract void loadEntities()Loads all entities in a given area -
spawnPlayer
Spawns player- Returns:
- player entity
-
spawnPlayer
Spawns player with previous components- Parameters:
componentList
-- Returns:
- Player entity with old components
-
loadAssets
protected abstract void loadAssets()Loads assets -
getComponents
Get copies all of the player components we want to transfer in between resets/levels.- Returns:
- The list of all player components.
-
saveComponents
Save a copy of all of the components we want to store for resets/level switches.- Parameters:
combatStats
- - CombatStatsComponent.inventory
- - InventoryComponent.
-
dispose
public void dispose()Dispose of all internal entities in the area- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
getPlayer
-
spawnEntity
Spawn entity at its current position- Parameters:
entity
- Entity (not yet registered)
-
spawnEntityAt
protected void spawnEntityAt(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY) Spawn entity on a given tile. Requires the terrain to be set first.- Parameters:
entity
- Entity (not yet registered)tilePos
- tile position to spawn atcenterX
- true to center entity X on the tile, false to align the bottom left cornercenterY
- true to center entity Y on the tile, false to align the bottom left corner
-
createMinimap
protected void createMinimap(com.badlogic.gdx.graphics.Texture minimapTexture) Creates and adds the minimap display to the given game area.- Parameters:
minimapTexture
- the texture to use as minimap background
-