Class LevelComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.levels.LevelComponent

public class LevelComponent extends Component
  • 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
      Overrides:
      create in class Component
    • 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
      Overrides:
      update in class Component
    • 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

      public void setGameArea(ForestGameArea newGameArea)
      Sets and stores the current GameArea/map in a private attribute
      Parameters:
      newGameArea - the new game area that needs to be stored
    • setCustomerSpawnController

      public void setCustomerSpawnController(Entity var)
      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

      public ForestGameArea getGameArea()
      Get the current GameArea/Map
      Returns:
      the current ForestGameArea
    • getCustomerSpawnController

      public Entity getCustomerSpawnController()
      Get the Entity that handles all the customer spawning events
      Returns:
      the Entity with all customer spawning events
    • getSpawnStartTime

      public Long 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