Class GameArea

java.lang.Object
com.csse3200.game.areas.GameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
ElevatorGameArea, FlyingBossRoom, ForestGameArea, MainHall, MovingBossRoom, OfficeGameArea, Reception, ResearchGameArea, SecurityGameArea, ServerGameArea, ShippingGameArea, StaticBossRoom, StorageGameArea, TunnelGameArea

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

    • terrain

      protected TerrainComponent terrain
    • areaEntities

      protected List<Entity> areaEntities
    • terrainFactory

      protected TerrainFactory terrainFactory
    • cameraComponent

      protected CameraComponent cameraComponent
    • baseScaling

      protected float baseScaling
    • isTransitioning

      protected static boolean isTransitioning
      Prevents re-entrant room transitions across areas
    • wavesManager

      protected EnemyWaves wavesManager
    • roomNumber

      protected static int roomNumber
  • 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 com.badlogic.gdx.utils.Disposable
    • beginTransition

      protected boolean beginTransition()
      Attempt to start a room transition. Returns false if one is already in progress.
    • endTransition

      protected void endTransition()
      Mark the end of a room transition.
    • spawnEntity

      public void spawnEntity(Entity entity)
      Spawn entity at its current position
      Parameters:
      entity - Entity (not yet registered)
    • spawnFloor

      protected void spawnFloor()
    • startWaves

      public void startWaves(Entity player)
      Start enemy waves from terminal command by typing "waves".
    • getRoomNumber

      public int getRoomNumber()
      Returns the room number corresponding to the current floor.
      Returns:
      Room number as an int if the floor name is in the format "Floor2" with 2 being any number, otherwise returns 1.
    • getBaseDifficultyScale

      public float getBaseDifficultyScale()
      Returns the base difficulty scale of the current room.
      Returns:
      Scaling factor as a float.
    • spawnEntityAt

      protected void spawnEntityAt(Entity entity, com.badlogic.gdx.math.GridPoint2 tilePos, boolean centerX, boolean centerY)
    • spawnEnemies

      public void spawnEnemies(int roomNumber, int total, float scaleFactor, Entity player)
      Spawns the enemies based on the room number given.
      Parameters:
      roomNumber - The number of the current floor/room.
      total - The total number of enemies to be spawned.
      scaleFactor - The scaling factor of the difficulty of the enemies to be spawned.
      player - The player Entity that is to be target by the enemies.
    • spawnGhostGPT

      public void spawnGhostGPT(int total, float scaleFactor, Entity player, Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> positions)
      Adds GhostGPT enemies onto the map.
      Parameters:
      total - The total number of GhostGPT to be spawned.
      scaleFactor - The scale of increase in difficulty of the GhostGPT
    • spawnDeepspin

      public void spawnDeepspin(int total, float scaleFactor, Entity player, Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> positions)
      Adds DeepSpin enemies onto the map.
      Parameters:
      total - The total number of DeepSpins to be spawned.
      scaleFactor - The scale of increase in difficulty of the DeepSpin
    • spawnGrokDroid

      public void spawnGrokDroid(int total, float scaleFactor, Entity player, Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> positions)
      Adds GrokDroid enemies onto the map.
      Parameters:
      total - The total number of GrokDroid to be spawned.
      scaleFactor - The scale of increase in difficulty of the GrokDroid
    • spawnVroomba

      public void spawnVroomba(int total, float scaleFactor, Entity player, Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> positions)
      Adds Vroomba enemies onto the map.
      Parameters:
      total - The total number of Vroomba to be spawned.
      scaleFactor - The scale of increase in difficulty of the Vroomba
    • spawnTurret

      public void spawnTurret(int total, float scaleFactor, Entity player, Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> positions)
      Adds Turret enemies onto the map.
      Parameters:
      total - The total number of Turret to be spawned.
      scaleFactor - The scale of increase in difficulty of the GhostGPT
    • spawnGhostGPTProjectile

      public Entity spawnGhostGPTProjectile(com.badlogic.gdx.math.Vector2 directionToFire, WeaponsStatsComponent source)
      Spawns the projectile used by the Ghost GPT Enemy
      Parameters:
      directionToFire - The direction in which the projectile is to be fired.
      source - The damage and other statistics that the projectile will use.
      Returns:
      The spawned projectile Entity
    • getEnemySpawnPosition

      protected Map<String,ArrayList<com.badlogic.gdx.math.Vector2>> getEnemySpawnPosition(int roomNumber)
    • removeEntity

      public void removeEntity(Entity entity)
      Remove an entity
      Parameters:
      entity - to be removed
    • getEntities

      public List<Entity> getEntities()
      Gets all the current entities
      Returns:
      the entities on the map
    • spawnEntityInRoom

      public void spawnEntityInRoom(String roomName, Entity entity)
      Spawn an entity inside the specified room. Requires the terrain to be set first.
      Parameters:
      entity - entity to spawn (not yet registered)
    • getRoomSpawnPosition

      protected com.badlogic.gdx.math.Vector2 getRoomSpawnPosition(String roomName)
    • ensureTextures

      protected void ensureTextures(String[] texturePaths)
      Convenience to load textures if not already loaded.
    • ensurePlayerAtlas

      protected void ensurePlayerAtlas()
      Ensure the common player atlas is available.
    • unloadAssets

      protected void unloadAssets(String[] assetPaths)
      Unload a set of assets if loaded.
    • setupTerrainWithOverlay

      protected void setupTerrainWithOverlay(TerrainFactory factory, TerrainFactory.TerrainType type, com.badlogic.gdx.graphics.Color overlayColor)
      Create terrain of a given type and add an optional color overlay.
    • getCameraBounds

      protected GameArea.Bounds getCameraBounds(CameraComponent cameraComponent)
    • addSolidWallLeft

      protected void addSolidWallLeft(GameArea.Bounds b, float wallWidth)
      Solid walls on edges.
    • addSolidWallRight

      protected void addSolidWallRight(GameArea.Bounds b, float wallWidth)
    • addSolidWallTop

      protected void addSolidWallTop(GameArea.Bounds b, float wallWidth)
    • addSolidWallBottom

      protected void addSolidWallBottom(GameArea.Bounds b, float wallWidth)
    • addVerticalDoorLeft

      protected void addVerticalDoorLeft(GameArea.Bounds b, float wallWidth, Runnable onEnter)
      Add a vertical door on the left edge, splitting the wall into two segments.
    • addVerticalDoorRight

      protected void addVerticalDoorRight(GameArea.Bounds b, float wallWidth, Runnable onEnter)
      Add a vertical door on the right edge.
    • loadArea

      protected <T extends GameArea> void loadArea(Class<T> areaClass)
    • clearAndLoad

      protected void clearAndLoad(Supplier<GameArea> nextAreaSupplier)
      Helper to clear current entities and transition to a new area.
    • spawnObjectDoors

      protected void spawnObjectDoors(com.badlogic.gdx.math.GridPoint2 leftDoorPos, com.badlogic.gdx.math.GridPoint2 rightDoorPos)
      Spawns decorative object doors (non-functional) at given positions.
      Parameters:
      leftDoorPos - grid position for the left/bottom decorative door
      rightDoorPos - grid position for the right/top decorative door
    • spawnItem

      public void spawnItem(Entity item, com.badlogic.gdx.math.GridPoint2 position)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPlayer

      public abstract Entity getPlayer()
      allows manipulation of player character by loading function
      Returns:
      player entity