// this is where we add the rooms to the 2d array that will be used to represent the dungeon
 public void AddRoomsToDungeonArray(SubDungeon subDungeon)
 {
     // dont continue further if the subdungeon doesnt exist
     if (subDungeon == null)
     {
         return;
     }
     // if the node has no children
     if (subDungeon.IsLeaf())
     {
         // iterate through the room and add it to the dungeon array
         for (int i = (int)subDungeon.room.x; i < subDungeon.room.xMax; i++)
         {
             for (int j = (int)subDungeon.room.y; j < subDungeon.room.yMax; j++)
             {
                 dungeon[i, j] = 0;
             }
         }
     }
     // if its not a leaf then move further down the tree to its children
     else
     {
         AddRoomsToDungeonArray(subDungeon.left);
         AddRoomsToDungeonArray(subDungeon.right);
     }
 }
 // this is where we create the binary space partition tree
 public void GenerateBinarySpacePartition(SubDungeon subDungeon)
 {
     // checks to see if the node has no children
     if (subDungeon.IsLeaf())
     {
         // if the sub-dungeon is too big, then split it
         if ((subDungeon.rect.width > maxRoomSize) || (subDungeon.rect.height > maxRoomSize) || (Random.Range(0.0f, 1.0f) > 0.25))
         {
             // if we split, then recursively continue spliting the sub dungeons
             if (subDungeon.Split(minRoomSize, maxRoomSize))
             {
                 GenerateBinarySpacePartition(subDungeon.left);
                 GenerateBinarySpacePartition(subDungeon.right);
             }
         }
     }
 }