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

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 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 Details

  • Constructor Details

    • GameArea

      protected GameArea()
  • Method Details

    • getEvents

      public EventHandler getEvents()
    • trigger

      public void trigger(String eventName, Entity player)
    • create

      public void create()
      Create the game area, including terrain, 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 -
    • 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

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

      protected abstract Entity spawnPlayer(List<Component> componentList)
      Spawns player with previous components
      Parameters:
      componentList -
      Returns:
      Player entity with old components
    • loadAssets

      protected abstract void loadAssets()
      Loads assets
    • getComponents

      public List<Component> getComponents()
      Get copies all of 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 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 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 terrain 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