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:
BaseLevelGameArea,CutsceneArea,TemplateGameArea
Represents an area in the game, such as a level, indoor area, etc. An area has a grid and
other entities to spawn on that grid.
Support for enabling/disabling game areas could be added by making this a Component instead.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CombatStatsComponentprotected ArrayList<com.badlogic.gdx.math.Vector2> protected GridComponentprotected InventoryComponentprotected booleanprotected Entityprotected com.badlogic.gdx.math.GridPoint2 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Create the game area, including grid, static entities (trees), dynamic entities (player)protected voidcreateMinimap(com.badlogic.gdx.graphics.Texture minimapTexture) Creates and adds the minimap display to the given game area.voidcreateWithPlayer(Entity oldPlayer) Create the game area using components from a different player entity.voiddispose()Dispose of all internal entities in the areaGet copies all the player components we want to transfer in between resets/levels.List<com.badlogic.gdx.math.Vector2> Returns the list of death locations.com.badlogic.gdx.math.GridPoint2protected abstract voidLoads assetsprotected abstract voidLoads all entities in a given areaprotected abstract voidLoads prerequisites for each area.voidrecordDeathLocation(com.badlogic.gdx.math.Vector2 location) Records the death location of the player (does NOT copy the location).voidreset()Resets the game areavoidsaveComponents(CombatStatsComponent combatStats, InventoryComponent inventory) Save a copy of all the components we want to store for resets/level switches.protected voidsetDeathMarkerTexture(com.badlogic.gdx.graphics.Texture texture) Sets the texture to use for the death marker.protected voidspawnDeathMarker(com.badlogic.gdx.math.Vector2 location) Spawns a death marker at the given location.voidSpawns a death marker at the death location.protected voidspawnEntity(Entity entity) Spawn entity at its current positionprotected voidspawnEntityAt(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY) Spawn entity on a given tile.protected abstract EntitySpawns playerprotected abstract EntityspawnPlayer(List<Component> componentList) Spawns player with previous componentsvoid
-
Field Details
-
grid
-
tileBounds
protected com.badlogic.gdx.math.GridPoint2 tileBounds -
areaEntities
-
deathLocations
-
player
-
isResetting
protected boolean isResetting -
combatStats
-
inventory
-
-
Constructor Details
-
GameArea
protected GameArea()
-
-
Method Details
-
getEvents
-
getMapBounds
public com.badlogic.gdx.math.GridPoint2 getMapBounds() -
trigger
-
setDeathMarkerTexture
protected void setDeathMarkerTexture(com.badlogic.gdx.graphics.Texture texture) Sets the texture to use for the death marker.- Parameters:
texture- the texture to use for the death marker.
-
recordDeathLocation
public void recordDeathLocation(com.badlogic.gdx.math.Vector2 location) Records the death location of the player (does NOT copy the location).- Parameters:
location- the location of the player's death.
-
getDeathLocations
Returns the list of death locations.- Returns:
- the list of death locations.
-
spawnDeathMarker
protected void spawnDeathMarker(com.badlogic.gdx.math.Vector2 location) Spawns a death marker at the given location.- Parameters:
location- the location to spawn the death marker at.
-
spawnDeathMarkers
public void spawnDeathMarkers()Spawns a death marker at the death location. -
create
public void create()Create the game area, including grid, static entities (trees), dynamic entities (player) -
createWithPlayer
Create the game area using components from a different player entity.- Parameters:
oldPlayer- the older player entity
-
reset
public void reset()Resets the game area -
loadPrerequisites
protected abstract void loadPrerequisites()Loads prerequisites for each area. Music, sounds, grid 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- the list of components with witch to create the player- Returns:
- Player entity with old components
-
loadAssets
protected abstract void loadAssets()Loads assets -
getComponents
Get copies all the player components we want to transfer in between resets/levels.- Returns:
- The list of all player components.
-
saveComponents
Save a copy of all 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:
disposein 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 grid 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
-