Package com.csse3200.game.areas
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
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.
-
Field Summary
Fields inherited from class com.csse3200.game.areas.GameArea
areaEntities, waveManager
-
Constructor Summary
ConstructorsConstructorDescriptionLevelGameArea
(String levelKey) Initialise this LevelGameArea for a specific level. -
Method Summary
Modifier and TypeMethodDescriptionvoid
beginDrag
(com.badlogic.gdx.graphics.Texture texture) Begins a drag operation with the given texture.void
Cancels an ongoing drag operation.void
Checks the game over condition when a robot reaches the end of the gridvoid
create()
Creates the game area by calling helper methods as required.getGrid()
Getter for gridGetter for selected_unitfloat
Getter for tile size in world unitsfloat
boolean
Checks if a character is currently selected.void
removeUnit
(int position) Remove a unit form a tilevoid
resize()
Method to reset game entity size/position on window resize.void
setGrid
(LevelGameGrid newGrid) void
setIsCharacterSelected
(boolean status) Sets whether a character is currently selected.void
Uses stage height and width to set variables relating to tile, grid and character sizing and placement.void
setSelectedUnit
(Entity unit) Setter for selected_unitvoid
spawnProjectile
(com.badlogic.gdx.math.Vector2 spawnPos) void
spawnRobot
(int col, int row, RobotFactory.RobotType robotType) Spawn a robot at the specified grid location.void
spawnRobotOnDefence
(RobotFactory.RobotType robotType) Spawns a robot directly on top of an existing defence (placed unit) on the grid.void
spawnUnit
(int position) Adds a unit to the gridcom.badlogic.gdx.math.GridPoint2
stageToWorld
(com.badlogic.gdx.math.GridPoint2 pos) Converts stage (mouse/screen) coordinates into world (entity placement) coordinatescom.badlogic.gdx.math.GridPoint2
worldToStage
(com.badlogic.gdx.math.GridPoint2 pos) Converts world (entity placement) coordinates into stage (mouse/screen) coordinatesMethods inherited from class com.csse3200.game.areas.GameArea
despawnEntity, dispose, getEntities, requestDespawn, setWaveManager, spawnEntity, spawnRobotAtFloat, spawnRobotAtFloat, spawnRobotAtTile, spawnRobotAtTile
-
Constructor Details
-
LevelGameArea
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. -
getGrid
Getter for grid -
setGrid
-
spawnRobot
Description copied from interface:EnemySpawner
Spawn a robot at the specified grid location.- Specified by:
spawnRobot
in interfaceEnemySpawner
- Parameters:
col
- grid columnrow
- grid rowrobotType
- robot type identifier
-
spawnRobotOnDefence
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
Getter for selected_unit- Specified by:
getSelectedUnit
in interfaceAreaAPI
- Returns:
- selected_unit
-
setSelectedUnit
Setter for selected_unit- Specified by:
setSelectedUnit
in interfaceAreaAPI
- Parameters:
unit
- Entity in the inventory
-
spawnUnit
public void spawnUnit(int position) Adds a unit to the grid -
removeUnit
public void removeUnit(int position) Remove a unit form a tile- Specified by:
removeUnit
in interfaceAreaAPI
- Parameters:
position
- of the tile
-
getTileSize
public float getTileSize()Getter for tile size in world units- Specified by:
getTileSize
in interfaceAreaAPI
- 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 interfaceAreaAPI
- 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 interfaceAreaAPI
- 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. -
cancelDrag
public void cancelDrag()Cancels an ongoing drag operation.- Specified by:
cancelDrag
in interfaceAreaAPI
-
setIsCharacterSelected
public void setIsCharacterSelected(boolean status) Sets whether a character is currently selected.- Specified by:
setIsCharacterSelected
in interfaceAreaAPI
- 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 interfaceAreaAPI
- Returns:
- true if a character is selected, false otherwise
-
getWorldWidth
public float getWorldWidth()
-