class Level {
  int wallSize = 72;
  float levelArea;
  int leftBorder, rightBorder, topBorder, bottomBorder;
  
  Level(){
    leftBorder = wallSize;
    topBorder = wallSize;
    rightBorder = width - wallSize;
    bottomBorder = height - wallSize;
    levelArea = (rightBorder - leftBorder) * (bottomBorder - topBorder);
    maxDamageArea = levelArea / 2;
  }
  
  float getRandomX(int offset){
    return(random(leftBorder + offset,rightBorder - offset));
  }
  float getRandomY(int offset){
    return(random(topBorder + offset, bottomBorder - offset));
  }
  
  void update() {
    room.update();
  }
  
  void render(){
    room.render();
  }
  
  void nextRoom(){
    currentRoom++;
    loadRoom(currentRoom);
    player.x = width/2;
    player.y = level.bottomBorder;
    player.update();
  }
  
  void loadRoom(int r){
    clearRoom();  
    switch (r){
      case 0:
        room = new TutorialRoom();
        break;
      case 1:
        room = new BattleRoom();
        enemies.add(new Ghost(600,300));
        
        break;
      case 2:
        room = new MonologueRoom("I am so tired. I wish I knew what i was doing... I miss my mother, strange as that may be.");
        break;
      case 3:
        room = new BattleRoom();
        enemies.add(new Ghost(300,300));
        enemies.add(new Ghost(600,300));
        break;
      case 4:
        room = new BattleRoom();
        //enemies.add(new Ghost(600,300));
        enemies.add(new Skull(100,300));
        break;
      case 5:
        room = new MonologueRoom("They always called me 'The chosen of the Goddess'. I wish I knew why. I never felt special, even now... I am just scared.");
        break;
      case 6:
        room = new BattleRoom();
        enemies.add(new Ghost(600,300));
        enemies.add(new Skull(500,200));
        enemies.add(new Ghost(100,300));
        enemies.add(new Ghost(300,200));
        break;
      case 7:
        room = new BattleRoom();
        enemies.add(new Ghost(600,200));
        enemies.add(new BigGhost(500,200));
        enemies.add(new Ghost(300,200));
        break;
      case 8:
        room = new BattleRoom();
        enemies.add(new BigGhost(600,300));
        enemies.add(new Skull(500,200));
        enemies.add(new Ghost(100,300));
        break;
      case 9:
        room = new MonologueRoom("I’ve lived in the temple since I can remember. \"That doesn’t matter anymore, we live for Her, now.\" - they would say.");
        break;
      case 10:
        room = new BattleRoom();
        enemies.add(new Skull(600,300));
        enemies.add(new Skull(500,200));
        enemies.add(new Skull(100,300));
        break;
      case 11:
        room = new BattleRoom();
        enemies.add(new Ghost(600,300));
        enemies.add(new Skull(500,200));
        enemies.add(new Ghost(300,200));
        enemies.add(new Skull(200,300));
        enemies.add(new Ghost(100,300));
        break;
      case 12:
        room = new BattleRoom();
       // enemies.add(new Skull(600,300));
        enemies.add(new BigGhost(500,200));
        enemies.add(new Ghost(300,200));
        enemies.add(new BigGhost(200,300));
       // enemies.add(new Skull(100,300));
        break;
      case 13:
        room = new BattleRoom();
        enemies.add(new BigGhost(300,300));
        enemies.add(new Ghost(100,200));
        enemies.add(new Ghost(200,200));
        enemies.add(new Ghost(400,200));
        enemies.add(new Ghost(500,200));
        
        break;
      case 14:
        room = new MonologueRoom("All the gifts, 'Intuition', 'Ear', 'Heartwhisper'... All for what? Living in isolation, what were they good for?");
        break;
      case 15:
        room = new BattleRoom();
        enemies.add(new BigGhost(200,300));
        enemies.add(new Skull(200,200));
        enemies.add(new Skull(600,200));
        enemies.add(new Skull(120,500));
        break;
      case 16:
       // room = new MonologueRoom("Those ghosts, they don’t seem evil. They are restless, yes, but I don’t know why...");
        room = new BattleRoom();
        enemies.add(new BigGhost(200,300));
        enemies.add(new BigGhost(600,300));
        enemies.add(new BigGhost(300,400));
        break;
      case 17:
        room = new MonologueRoom("I didn’t even know how much I believed in the Goddess, not until she spoke to me in that dream. But soon, it won't matter.");
        break;
      case 18:
        room = new BattleRoom();
        enemies.add(new KingGhost(width/2, 250));
        enemies.add(new BigGhost(width/2 - 100, 200));
        enemies.add(new BigGhost(width/2 + 100, 200));
        enemies.add(new Ghost(width/2 + 200, 150));
        enemies.add(new Ghost(width/2 - 200, 150));
        break;
      case 19:
        room = new FinalRoom();
        break;
    }
  }
}