IEnumerator generateMapDelay()
    {
        while (!GameManager.instance.transition.textureHidden)
        {
            yield return(null);
        }
        GameManager.instance.transition.BeginShow();
        GameManager.instance.player.canMove = false;
        while (!GameManager.instance.transition.textureShown)
        {
            yield return(null);
        }
        GameManager.instance.transition.BeginHide();
        GameManager.instance.player.canMove = true;

        isInDungeon = true;
        playerLocation.GetComponent <PlayerController>().lerping = false;
        buttonReference.SetActive(false);
        for (int x = 0; x < map.GetUpperBound(0); x++)     //Loop through the width of the map
        {
            for (int y = 0; y < map.GetUpperBound(1); y++) //Loop through the height of the map
            {
                // fill map with 0's so it's all dirt
                map[x, y] = (int)tileType.wall;
            }
        }
        tilemap.ClearAllTiles();

        List <rect> roomList = new List <rect>();
        int         numRooms = 0;

        for (int i = 0; i < nRooms; i++)
        {
            int w = Random.Range(minRoomSize, maxRoomSize);
            int h = Random.Range(minRoomSize, maxRoomSize);

            int x = Random.Range(1, scaledXSize - w - 1);
            int y = Random.Range(1, scaledYSize - h - 1);

            rect newRoom = new rect(x, y, h, w);

            if (numRooms != 0)
            {
                for (int j = 0; j < roomList.Count; j++)
                {
                    if (newRoom.intersect(roomList[j]))
                    {
                        break;
                    }
                }
            }

            map = createRoom(newRoom, map);
            Vector2Int newCenter = newRoom.center();
            if (numRooms == 0)
            {
                playerLocation.position = new Vector3(newCenter.x + 1 + gridOffset, newCenter.y + 1 + gridOffset, 0);
            }
            else
            {
                Vector2Int lastCenter = roomList[numRooms - 1].center();

                if (Random.Range(0, 2) > 1)
                {
                    createHTunnel(lastCenter.x, newCenter.x, lastCenter.y, map);
                    createVTunnel(lastCenter.y, newCenter.y, newCenter.x, map);
                }
                else
                {
                    createVTunnel(lastCenter.y, newCenter.y, lastCenter.x, map);
                    createHTunnel(lastCenter.x, newCenter.x, newCenter.y, map);
                }
            }
            map = spawnChest(newCenter, map);
            roomList.Add(newRoom);
            numRooms++;
        }
        Vector2Int stairPos = roomList[numRooms - 1].center();

        map[stairPos.x, stairPos.y] = (int)tileType.stairs;
        setTileMap(map);
        if (floorText)
        {
            floorText.text = string.Format("Floor {0}", currentFloorNumber + 1);
        }

        if (currentFloorNumber > highestFloorAchieved)
        {
            highestFloorAchieved   = currentFloorNumber;
            reachedNewHighestFloor = true;
        }
        else
        {
            reachedNewHighestFloor = true;
        }
    }