Class EnemyManagerModel

java.lang.Object
model.entities.EnemyManagerModel

public class EnemyManagerModel extends Object
Manages the enemies in the game, including their states, updates, and interactions with the player.
  • Method Details

    • getInstance

      public static EnemyManagerModel getInstance()
      Returns the singleton instance of the EnemyManagerModel.
      Returns:
      the singleton instance
    • update

      public void update()
      Updates the state of all enemies and relevant timers.
    • checkEnemyHit

      public void checkEnemyHit(PlayerModel playerModel, EnemyModel enemyModel)
      Checks if the player has hit an enemy and handles the interaction.
      Parameters:
      playerModel - the player model
      enemyModel - the enemy model
    • setAllHungry

      public void setAllHungry()
      Sets all active enemies to the hungry state.
    • loadEnemies

      public void loadEnemies()
      Loads the enemies for the current level.

      This method gets the list of enemies from the current level by the LevelManagerModel and saves them in the enemies list.

    • newLevelReset

      public void newLevelReset()
      Resets the state of the enemies for a new level.

      This method calls the newLevelReset method to clear the list of enemies and reset various flags and timers related to enemy states, such as whether all enemies have reached their spawn points, whether all enemies are dead, the chronometer for the time all enemies have been dead, the freeze state of enemies, and the invincibility mode of the player.

    • newPlayReset

      public void newPlayReset()
      Resets the state of the class to be ready for a new play.

      This method calls the newLevelReset method to clear the list of enemies and reset various flags and timers related to enemy states, such as whether all enemies have reached their spawn points, whether all enemies are dead, the chronometer for the time all enemies have been dead, the freeze state of enemies, and the invincibility mode of the player.

    • getActiveEnemiesCount

      public int getActiveEnemiesCount()
      Returns the count of active enemies.
      Returns:
      the count of active enemies
    • getEnemiesModels

      public ArrayList<EnemyModel> getEnemiesModels()
      Returns the list of enemy models.
      Returns:
      the list of enemy models
    • didAllEnemiesReachedSpawn

      public boolean didAllEnemiesReachedSpawn()
      returns if all enemies have reached their spawn points.
      Returns:
      true if all enemies have reached their spawn points, false otherwise
    • setChacknHeartfreeze

      public void setChacknHeartfreeze(int timer)
      This method sets the freeze and invincibility timers to the specified value, enabling the freeze state for enemies and the invincibility mode for the player.

      This method is used when the player picks up the Chack'n Heart power-up

      Parameters:
      timer - the timer value to set for both freeze and invincibility effects
    • getAllEnemiesDeadChronometer

      public int getAllEnemiesDeadChronometer()
      Returns the chronometer value for the time all enemies have been dead.
      Returns:
      the chronometer value
    • areAllEnemiesDead

      public boolean areAllEnemiesDead()
      returns if all enemies are dead.
      Returns:
      true if all enemies are dead, false otherwise