Class GameArea

java.lang.Object
com.deco2800.game.areas.GameArea
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
ForestGameArea

public abstract class GameArea
extends java.lang.Object
implements 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 Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.List<Entity> areaEntities  
    protected TerrainComponent terrain  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected GameArea()  
  • Method Summary

    Modifier and Type Method Description
    abstract void create()
    Create the game area in the world.
    void dispose()
    Dispose of all internal entities in the area
    protected void spawnEntity​(Entity entity)
    Spawn entity at its current position
    protected void spawnEntityAt​(Entity entity, GridPoint2 tilePos, boolean centerX, boolean centerY)
    Spawn entity on a given tile.
    void spawnEntityAt​(Entity entity, Vector2 entityPos, boolean centerX, boolean centerY)
    Spawn entity on a given tile.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • 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 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, 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
    • spawnEntityAt

      public void spawnEntityAt​(Entity entity, Vector2 entityPos, boolean centerX, boolean centerY)
      Spawn entity on a given tile. Requires the terrain to be set first.
      Parameters:
      entity - Entity (not yet registered)
      entityPos - world 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