Class ForestGameArea

java.lang.Object
com.csse3200.game.areas.GameArea
com.csse3200.game.areas.forest.ForestGameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class ForestGameArea extends GameArea
Forest area for the demo game with trees, a player, and some enemies.
  • Field Details

    • MAP_SIZE

      public static final com.badlogic.gdx.math.GridPoint2 MAP_SIZE
  • Constructor Details

    • ForestGameArea

      public ForestGameArea(TerrainFactory terrainFactory, GdxGame game)
      Initialise this ForestGameArea to use the provided TerrainFactory. Precondition: terrainFactory is not null
      Parameters:
      terrainFactory - TerrainFactory used to create the terrain for the GameArea.
      game - GdxGame needed for creating the player
  • Method Details

    • create

      public void create()
      Create the game area, including terrain, static entities (trees), dynamic entities (player and NPCs), and ui
      Specified by:
      create in class GameArea
    • unlockArea

      public void unlockArea(String area)
      Unlock an area of the map
      Overrides:
      unlockArea in class GameArea
    • getPlayer

      public Entity getPlayer()
      gets the player
      Specified by:
      getPlayer in class GameArea
      Returns:
      player entity
    • displayUI

      public void displayUI()
    • spawnEntityNearPlayer

      public void spawnEntityNearPlayer(Entity entity, int radius)
      Spawns an entity near the player within a specified radius, ensuring the entity is placed within the correct chunk boundaries and loaded areas of the game map. This function calculates a valid spawn position near the player's current location, considering the player's world position and current chunk. It ensures that the entity is spawned within the boundaries of the current chunk to avoid positioning the entity in an unloaded or inaccessible area.
      Parameters:
      entity - The entity to be spawned near the player.
      radius - The radius around the player's position within which the entity will be spawned. The spawn position is randomly selected within this radius but is constrained to be within the current chunk boundaries.
    • spawnConvertedNPCs

      public void spawnConvertedNPCs(Entity defeatedEnemy)
      Spawns defeated enemy NPCs are friendly NPCs in the same/similar location
      Overrides:
      spawnConvertedNPCs in class GameArea
      Parameters:
      defeatedEnemy - the entity that has been defeated in combat
    • playMusic

      public void playMusic()
      Specified by:
      playMusic in class GameArea
    • pauseMusic

      public void pauseMusic()
      Specified by:
      pauseMusic in class GameArea
    • loadAssets

      public void loadAssets()
    • unloadAssets

      public void unloadAssets()
      Specified by:
      unloadAssets in class GameArea
    • dispose

      public void dispose()
      Description copied from class: GameArea
      Dispose of all internal entities in the area
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class GameArea
    • getEnemies

      public List<Entity> getEnemies()
      Specified by:
      getEnemies in class GameArea
    • getBosses

      public List<Entity> getBosses()
      Specified by:
      getBosses in class GameArea
    • getFriendlyNPCs

      public List<Entity> getFriendlyNPCs()
      Specified by:
      getFriendlyNPCs in class GameArea
    • getMinigameNPCs

      public List<Entity> getMinigameNPCs()
      Specified by:
      getMinigameNPCs in class GameArea
    • getDynamicItems

      public Map<Integer,Entity> getDynamicItems()