Class RoomManager

java.lang.Object
game.RoomManager

public class RoomManager extends Object
Singleton class that manages room creation, transitions, and difficulty scaling. Handles which room the player is in, spawning enemies, and tracking cleared rooms.
  • Field Details

    • BOSS_INTERVAL

      private static final int BOSS_INTERVAL
      Interval at which boss rooms appear
      See Also:
    • TREASURE_INTERVAL

      private static final int TREASURE_INTERVAL
      Interval at which treasure rooms appear
      See Also:
    • SHOP_INTERVAL

      private static final int SHOP_INTERVAL
      Interval at which store rooms appear
      See Also:
    • roomCleared

      private int roomCleared
      Number of rooms the player has cleared
    • currentRoom

      private Room currentRoom
      Currently active room
    • difficulty

      private double difficulty
      Difficulty scaling factor for enemy spawning
    • player

      private Player player
      The player instance
    • instance

      private static RoomManager instance
      Singleton instance
  • Constructor Details

    • RoomManager

      private RoomManager(Player player)
      Private constructor for singleton pattern.
      Parameters:
      player - the player instance to assign to rooms
  • Method Details

    • getInstance

      public static RoomManager getInstance(Player player)
      Retrieves the singleton instance of RoomManager and initializes it if necessary.
      Parameters:
      player - the player instance
      Returns:
      the RoomManager singleton instance
    • getInstance

      public static RoomManager getInstance()
      Retrieves the singleton instance for later calls, after it has been initialized.
      Returns:
      the RoomManager singleton instance
    • resetInstance

      public void resetInstance()
      Resets the singleton instance (for restarting the game).
    • createTopDoor

      public void createTopDoor(Room room)
      Adds a door at the top of the room.
      Parameters:
      room - the room to add the door to
    • createNextRoom

      public Room createNextRoom()
      Creates the next room based on the last digit of roomsCleared and intervals. Boss, treasure, shop, and combat rooms are spawned accordingly. Last digit = 0 -> BossRoom Last digit = 5 -> TreasureRoom Last digit = 7 -> StoreRoom Anything else -> CombatRoom
      Returns:
      the newly created room
    • enterNextRoom

      public void enterNextRoom()
      Transitions the player to the next room, creating a top door and resetting player position.
    • update

      public void update(double dt, Player player)
      Updates the current room and checks for door collisions.
      Parameters:
      dt - delta time in seconds
      player - the player instance
    • render

      public void render(javafx.scene.canvas.GraphicsContext gc, Player player)
      Renders the current room and the player.
      Parameters:
      gc - the GraphicsContext for drawing
      player - the player instance
    • getCurrentRoom

      public Room getCurrentRoom()
      Returns:
      the currently active room
    • getPlayer

      public Player getPlayer()
      Returns:
      the player instance
    • setPlayer

      public void setPlayer(Player player)
      Parameters:
      player - the player instance to set
    • increaseDifficulty

      public void increaseDifficulty()
      Increases the difficulty scaling factor for future rooms.
    • getScore

      public String getScore()
      Returns the player's score as a 3-digit string.
      Returns:
      score formatted as 3 digits (e.g., "007")