Class LevelGameArea

java.lang.Object
com.csse3200.game.areas.GameArea
com.csse3200.game.areas.LevelGameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, AreaAPI, EnemySpawner
Direct Known Subclasses:
SlotMachineArea

public class LevelGameArea extends GameArea implements AreaAPI, EnemySpawner
Creates a level in the game, creates the map, a tiled grid for the playing area and a player unit inventory allowing the player to add units to the grid.
  • Constructor Details

    • LevelGameArea

      public LevelGameArea(String levelKey)
      Initialise this LevelGameArea for a specific level.
      Parameters:
      levelKey - the level key to load
  • Method Details

    • setScaling

      public void setScaling()
      Uses stage height and width to set variables relating to tile, grid and character sizing and placement.
    • create

      public void create()
      Creates the game area by calling helper methods as required.
      Specified by:
      create in class GameArea
    • getGrid

      public LevelGameGrid getGrid()
      Getter for grid
      Specified by:
      getGrid in interface AreaAPI
      Returns:
      grid
    • setGrid

      public void setGrid(LevelGameGrid newGrid)
    • spawnRobot

      public void spawnRobot(int col, int row, RobotFactory.RobotType robotType)
      Description copied from interface: EnemySpawner
      Spawn a robot at the specified grid location.
      Specified by:
      spawnRobot in interface EnemySpawner
      Parameters:
      col - grid column
      row - grid row
      robotType - robot type identifier
    • spawnRobotOnDefence

      public void spawnRobotOnDefence(RobotFactory.RobotType robotType)
      Spawns a robot directly on top of an existing defence (placed unit) on the grid. If no defence exists, does nothing and logs a warning.
    • spawnProjectile

      public void spawnProjectile(com.badlogic.gdx.math.Vector2 spawnPos)
    • getSelectedUnit

      public Entity getSelectedUnit()
      Getter for selected_unit
      Specified by:
      getSelectedUnit in interface AreaAPI
      Returns:
      selected_unit
    • setSelectedUnit

      public void setSelectedUnit(Entity unit)
      Setter for selected_unit
      Specified by:
      setSelectedUnit in interface AreaAPI
      Parameters:
      unit - Entity in the inventory
    • spawnUnit

      public void spawnUnit(int position)
      Adds a unit to the grid
      Specified by:
      spawnUnit in interface AreaAPI
      Parameters:
      position - the grid tile for spawning
    • removeUnit

      public void removeUnit(int position)
      Remove a unit form a tile
      Specified by:
      removeUnit in interface AreaAPI
      Parameters:
      position - of the tile
    • getTileSize

      public float getTileSize()
      Getter for tile size in world units
      Specified by:
      getTileSize in interface AreaAPI
      Returns:
      tileSize the size of the tiles
    • stageToWorld

      public com.badlogic.gdx.math.GridPoint2 stageToWorld(com.badlogic.gdx.math.GridPoint2 pos)
      Converts stage (mouse/screen) coordinates into world (entity placement) coordinates
      Specified by:
      stageToWorld in interface AreaAPI
      Parameters:
      pos - a and y coordinates in the stage
      Returns:
      GridPoint 2 containing x and y coordinates in the world
    • worldToStage

      public com.badlogic.gdx.math.GridPoint2 worldToStage(com.badlogic.gdx.math.GridPoint2 pos)
      Converts world (entity placement) coordinates into stage (mouse/screen) coordinates
      Specified by:
      worldToStage in interface AreaAPI
      Parameters:
      pos - a and y coordinates in the world
      Returns:
      GridPoint 2 containing x and y coordinates in the stage
    • resize

      public void resize()
      Method to reset game entity size/position on window resize.
    • checkGameOver

      public void checkGameOver()
      Checks the game over condition when a robot reaches the end of the grid
    • beginDrag

      public void beginDrag(com.badlogic.gdx.graphics.Texture texture)
      Begins a drag operation with the given texture.
      Specified by:
      beginDrag in interface AreaAPI
      Parameters:
      texture - the texture to display while dragging
    • cancelDrag

      public void cancelDrag()
      Cancels an ongoing drag operation.
      Specified by:
      cancelDrag in interface AreaAPI
    • setIsCharacterSelected

      public void setIsCharacterSelected(boolean status)
      Sets whether a character is currently selected.
      Specified by:
      setIsCharacterSelected in interface AreaAPI
      Parameters:
      status - true to indicate a character is selected, false otherwise
    • isCharacterSelected

      public boolean isCharacterSelected()
      Checks if a character is currently selected.
      Specified by:
      isCharacterSelected in interface AreaAPI
      Returns:
      true if a character is selected, false otherwise
    • getWorldWidth

      public float getWorldWidth()