Class EntitySpawner

java.lang.Object
com.csse3200.game.entities.EntitySpawner

public class EntitySpawner extends Object
Handles periodic spawning of one entity
  • Constructor Details

    • EntitySpawner

      public EntitySpawner(int maxSpawnCount, UnaryOperator<Entity> spawner, int growthRate, int initialSpawnCount, int spawnHour, int randomRange, int daysBetweenSpawns)
      Constructor for EntitySpawner
      Parameters:
      maxSpawnCount - maximum number of entities that can be spawned in one cycle
      spawner - method that creates the entity
      growthRate - linear growth rate of number of entities spawned each spawn cycle
      initialSpawnCount - the initial number of entities to be spawned
      spawnHour - the hour that the entities will be spawned or the hour after which a randomGoal will be determined.
      randomRange - max number of hours that the entity may spawn after spawnHour
      daysBetweenSpawns - minimum number of times spawnHour must occur between spawns
  • Method Details

    • setGameArea

      public void setGameArea(GameArea gameArea)
      Set GameArea
      Parameters:
      gameArea - GameArea to spawn entities
    • startSpawner

      public void startSpawner()
      Begin periodic spawning
    • hourUpdate

      public void hourUpdate()
      Handles each hour trigger - responsible for calling spawnNPC() at correct time
    • spawnEntities

      public void spawnEntities()
      Spawns entities onto the GameArea