Class GameArea

java.lang.Object
com.csse3200.game.areas.GameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
CombatArea, ForestGameArea, MazeGameArea

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

    • create

      public abstract void create()
      Create the game area in the world.
    • dispose

      public void dispose()
      Dispose of all internal entities in the area
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • 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
    • getPlayer

      public abstract Entity getPlayer()
    • getEnemies

      public abstract List<Entity> getEnemies()
    • getBosses

      public abstract List<Entity> getBosses()
    • getFriendlyNPCs

      public abstract List<Entity> getFriendlyNPCs()
    • getMinigameNPCs

      public abstract List<Entity> getMinigameNPCs()
    • unloadAssets

      public abstract void unloadAssets()
    • pauseMusic

      public abstract void pauseMusic()
    • playMusic

      public abstract void playMusic()
    • unlockArea

      public void unlockArea(String area)
    • spawnEntityAtVector

      public void spawnEntityAtVector(Entity entity, com.badlogic.gdx.math.Vector2 worldPos)
      Spawns an entity at a specified world position.

      This method sets the position of the given entity to the specified coordinates in the world and then registers the entity into the game world. The entity should not be registered prior to calling this method.

      Parameters:
      entity - The entity to be spawned (not yet registered).
      worldPos - The world position where the entity should be placed.
    • spawnConvertedNPCs

      public void spawnConvertedNPCs(Entity defeatedEnemy)
    • spawnEntityCenteredAt

      protected void spawnEntityCenteredAt(Entity entity, com.badlogic.gdx.math.Vector2 worldPos)
      Spawns an entity centered at a specified world position.

      This method sets the position of the given entity to the specified coordinates in the world and then registers the entity into the game world. The entity should not be registered prior to calling this method.

      Parameters:
      entity - Entity (not yet registered)
      worldPos - The world position where the entity should be placed.