Class GameArea

java.lang.Object
com.csse3200.game.areas.GameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
BaseLevelGameArea, CutsceneArea, TemplateGameArea

public abstract class GameArea extends Object implements com.badlogic.gdx.utils.Disposable
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 Details

    • grid

      protected GridComponent grid
    • tileBounds

      protected com.badlogic.gdx.math.GridPoint2 tileBounds
    • areaEntities

      protected List<Entity> areaEntities
    • deathLocations

      protected ArrayList<com.badlogic.gdx.math.Vector2> deathLocations
    • player

      protected Entity player
    • isResetting

      protected boolean isResetting
    • combatStats

      protected CombatStatsComponent combatStats
    • inventory

      protected InventoryComponent inventory
  • Constructor Details

    • GameArea

      protected GameArea()
  • Method Details

    • getEvents

      public EventHandler getEvents()
    • getMapBounds

      public com.badlogic.gdx.math.GridPoint2 getMapBounds()
    • trigger

      public void trigger(String eventName)
    • 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

      public List<com.badlogic.gdx.math.Vector2> 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

      public void createWithPlayer(Entity oldPlayer)
      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

      protected abstract Entity spawnPlayer()
      Spawns player
      Returns:
      player entity
    • spawnPlayer

      protected abstract Entity spawnPlayer(List<Component> componentList)
      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

      public List<Component> getComponents()
      Get copies all the player components we want to transfer in between resets/levels.
      Returns:
      The list of all player components.
    • saveComponents

      public void saveComponents(CombatStatsComponent combatStats, InventoryComponent inventory)
      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:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • getPlayer

      public Entity getPlayer()
    • spawnEntity

      protected void spawnEntity(Entity entity)
      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 at
      centerX - true to center entity X on the tile, false to align the bottom left corner
      centerY - 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