Package model.levels

Class LevelManagerModel

java.lang.Object
model.levels.LevelManagerModel

public class LevelManagerModel extends Object
Manages the Level in the game.

This singleton class is responsible for loading, managing, and transitioning between levels. It keeps track of the current level, handles level transitions, and provides access to level data.

  • Method Details

    • getInstance

      public static LevelManagerModel getInstance()
      Returns the singleton instance of the LevelManagerModel.

      If the instance is null, it initializes the LevelManagerModel instance.

      Returns:
      the singleton instance of the LevelManagerModel
    • loadNextLevel

      public void loadNextLevel()
      Loads the next level and sets the game state to level transition.

      If the current level is the last level, sets allLevelsCompleted to true.

    • newPlayReset

      public void newPlayReset()
      Resets the game to the first level and resets all levels.
    • getCurrentLevel

      public Level getCurrentLevel()
      Returns:
      the current level
    • getLevelTileData

      public int[][] getLevelTileData()
      Returns the level tiles tpe data of the current level.
      Returns:
      a 2D array representing the tiles in map
    • getWindDirectionData

      public Constants.Direction[][] getWindDirectionData()
      Returns the wind direction data of the current level.
      Returns:
      a 2D array representing the wind direction data
    • getLevelWithIndex

      public Level getLevelWithIndex(int levelIndex)
      Returns the level associated to the specified index.
      Parameters:
      levelIndex - the index of the level to get
      Returns:
      the level associated to the specified index
    • increaseLevelIndex

      public void increaseLevelIndex()
      Increases the level index by one.
    • areAllLevelsCompleted

      public boolean areAllLevelsCompleted()
      Checks if all levels are completed.
      Returns:
      true if all levels are completed, false otherwise
    • getLevels

      public ArrayList<Level> getLevels()
      Returns the list of all levels.
      Returns:
      an ArrayList of all levels
    • getLevelIndex

      public int getLevelIndex()
      Returns the current level index.
      Returns:
      the current level index