Class LevelComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.levels.LevelComponent
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Initialises the component to add necessary listeners to the LevelService and initialise an array with customer namesvoid
Update that a customer joined the linevoid
Update that a customer left the linevoid
Add one to the total number of customers spawnedint
Get the current number of customers in the lineGet the Entity that handles all the customer spawning eventsGet the current GameArea/Mapint
Get the number of customers required to spawn in the levelboolean
Is the game spawning customers?int
Get the total number of customers that have been spawned in the level currentlyGet the time that the most recent customer spawnedvoid
Initialise the map of acceptable customers in each level key = game level i.e.void
Initialise the customer name array which is dependent on which customers are acceptable in each level.void
initSpawning
(int spawnCap) Ensures that all private attributes are set to default and then enables spawningvoid
Set the number of customers that have spawned to 0void
Gets the Entity responsible for storing and handling all customer spawn eventsvoid
setGameArea
(ForestGameArea newGameArea) Sets and stores the current GameArea/map in a private attributevoid
setLevelSpawnCap
(int cap) Stores the new levels spawn capacity in the levelSpawnCap attributevoid
Make the private attribute spawnStartTime store the time when the most recently spawned customer was actually spawnedvoid
Inverses the boolean value of nowSpawning attributevoid
update()
Checks if the level should be spawning.Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
LevelComponent
public LevelComponent()
-
-
Method Details
-
initialiseAcceptableCustomers
public void initialiseAcceptableCustomers()Initialise the map of acceptable customers in each level key = game level i.e. LEVEL_1, value = array list of customers -
initialiseCustomerNameArr
public void initialiseCustomerNameArr()Initialise the customer name array which is dependent on which customers are acceptable in each level. -
create
public void create()Initialises the component to add necessary listeners to the LevelService and initialise an array with customer names -
update
public void update()Checks if the level should be spawning. If it is, then it calculates the seconds since the last customer spawned, and if it has been more than three seconds and the spawn capacity of the level has not been reached yet, then spawn another customer -
initSpawning
public void initSpawning(int spawnCap) Ensures that all private attributes are set to default and then enables spawning- Parameters:
spawnCap
- the number of customers that need to be spawned in the current level
-
setGameArea
Sets and stores the current GameArea/map in a private attribute- Parameters:
newGameArea
- the new game area that needs to be stored
-
setCustomerSpawnController
Gets the Entity responsible for storing and handling all customer spawn events- Parameters:
var
- the Entity with all spawning events
-
setSpawnStartTime
public void setSpawnStartTime()Make the private attribute spawnStartTime store the time when the most recently spawned customer was actually spawned -
toggleNowSpawning
public void toggleNowSpawning()Inverses the boolean value of nowSpawning attribute -
setLevelSpawnCap
public void setLevelSpawnCap(int cap) Stores the new levels spawn capacity in the levelSpawnCap attribute- Parameters:
cap
- the number of customers that must be spawned
-
getCurrentCustomersLinedUp
public int getCurrentCustomersLinedUp()Get the current number of customers in the line- Returns:
- the current number of customers in the line
-
getNumbCustomersSpawned
public int getNumbCustomersSpawned()Get the total number of customers that have been spawned in the level currently- Returns:
- the number of customers that have spawned
-
getNowSpawning
public boolean getNowSpawning()Is the game spawning customers?- Returns:
- whether the game is spawning customers
-
getLevelSpawnCap
public int getLevelSpawnCap()Get the number of customers required to spawn in the level- Returns:
- the number of customers that must spawn in the level
-
getGameArea
Get the current GameArea/Map- Returns:
- the current ForestGameArea
-
getCustomerSpawnController
Get the Entity that handles all the customer spawning events- Returns:
- the Entity with all customer spawning events
-
getSpawnStartTime
Get the time that the most recent customer spawned- Returns:
- when the latest customer spawned
-
customerJoinedLineUp
public void customerJoinedLineUp()Update that a customer joined the line -
customerLeftLineUp
public void customerLeftLineUp()Update that a customer left the line -
customerSpawned
public void customerSpawned()Add one to the total number of customers spawned -
resetCustomerSpawn
public void resetCustomerSpawn()Set the number of customers that have spawned to 0
-