private bool createRoom(ObjectDirection wall)
    {
        int      roomWidth  = Random.Range(roomSize.minimum, roomSize.maximum + 1);
        int      roomHeight = Random.Range(roomSize.minimum, roomSize.maximum + 1);
        Vector2i roomOffset = new Vector2i(Random.Range(0, roomWidth), Random.Range(0, roomHeight));
        Vector2i roomOrigin = new Vector2i(0, 0);

        //Debug.Log("Chose the wall at " + wall.x + ","+wall.y);

        switch (wall.getDirection())
        {
        case Direction.UP:
            roomOrigin.x = wall.x - roomWidth + 1 + roomOffset.x;
            roomOrigin.y = wall.y + 1;
            break;

        case Direction.RIGHT:
            roomOrigin.x = wall.x + 1;
            roomOrigin.y = wall.y - roomOffset.y;
            break;

        case Direction.LEFT:
            roomOrigin.x = wall.x - roomWidth;
            roomOrigin.y = wall.y - roomOffset.y;
            break;

        case Direction.DOWN:
            roomOrigin.x = wall.x - roomOffset.x;
            roomOrigin.y = wall.y - roomHeight;
            break;

        default:
            Debug.LogError("Unknown Direction found: " + wall.getDirection().ToString());
            break;
        }
        // Check if the rectangle is available (filled with walls)
        if (!checkRect(roomOrigin.x - spaceBetweenRooms, roomOrigin.y - spaceBetweenRooms, roomWidth + spaceBetweenRooms * 2, roomHeight + spaceBetweenRooms * 2, "Wall"))
        {
            return(false);
        }

        //Debug.Log("room Origin: " + roomOrigin.ToString());
        // If so, create a room
        fillRect(roomOrigin.x, roomOrigin.y, roomWidth, roomHeight, floorTiles);
        // Create the entrace
        fillRect(wall.x, wall.y, 1, 1, floorTiles);

        roomsCount++;
        return(true);
    }
    /// <summary>
    /// Check if the corridor is feasible
    /// </summary>
    /// <param name="wall"></param>
    /// <param name="length"></param>
    /// <returns></returns>
    protected bool checkCorridor(ObjectDirection wall, int length)
    {
        Count xRange = new Count(1, 1);
        Count yRange = new Count(1, 1);

        switch (wall.getDirection())
        {
        case Direction.UP:
        case Direction.DOWN:
            xRange = new Count(wall.x - spaceBetweenCorridors, wall.x + spaceBetweenCorridors);
            yRange = new Count(wall.y, wall.y);
            break;

        case Direction.LEFT:
        case Direction.RIGHT:
            xRange = new Count(wall.x, wall.x);
            yRange = new Count(wall.y - spaceBetweenCorridors, wall.y + spaceBetweenCorridors);
            break;
        }
        for (int startingX = xRange.minimum; startingX <= xRange.maximum; startingX++)
        {
            for (int startingY = yRange.minimum; startingY <= yRange.maximum; startingY++)
            {
                int x = startingX;
                int y = startingY;
                for (int i = 0; i < length + spaceBetweenCorridors; i++)
                {
                    GameObject obj = levelMap.getTile(x, y);
                    if (obj == null || !obj.CompareTag("Wall"))
                    {
                        return(false);
                    }

                    x += wall.direction.x;
                    y += wall.direction.y;
                }
            }
        }
        return(true);
    }
    /// <summary>
    /// Check if the corridor is feasible
    /// </summary>
    /// <param name="wall"></param>
    /// <param name="length"></param>
    /// <returns></returns>
    protected bool checkCorridor(ObjectDirection wall, int length)
    {
        Count xRange = new Count(1, 1);
        Count yRange = new Count(1, 1);
        switch (wall.getDirection())
        {
            case Direction.UP:
            case Direction.DOWN:
                xRange = new Count(wall.x - spaceBetweenCorridors, wall.x + spaceBetweenCorridors);
                yRange = new Count(wall.y, wall.y);
                break;
            case Direction.LEFT:
            case Direction.RIGHT:
                xRange = new Count(wall.x, wall.x);
                yRange = new Count(wall.y - spaceBetweenCorridors, wall.y + spaceBetweenCorridors);
                break;
        }
        for (int startingX = xRange.minimum; startingX <= xRange.maximum; startingX++)
        {
            for (int startingY = yRange.minimum; startingY <= yRange.maximum; startingY++)
            {
                int x = startingX;
                int y = startingY;
                for (int i = 0; i < length+spaceBetweenCorridors; i++)
                {
                    GameObject obj = levelMap.getTile(x, y);
                    if (obj == null || !obj.CompareTag("Wall"))
                    {
                        return false;
                    }

                    x += wall.direction.x;
                    y += wall.direction.y;
                }
            }
        }
        return true;
    }
    private bool createRoom(ObjectDirection wall)
    {
        int roomWidth = Random.Range(roomSize.minimum, roomSize.maximum+1);
        int roomHeight = Random.Range(roomSize.minimum, roomSize.maximum+1);
        Vector2i roomOffset = new Vector2i(Random.Range(0, roomWidth), Random.Range(0, roomHeight));
        Vector2i roomOrigin = new Vector2i(0, 0);

        //Debug.Log("Chose the wall at " + wall.x + ","+wall.y);

        switch(wall.getDirection())
        {
            case Direction.UP:
                roomOrigin.x = wall.x - roomWidth + 1 + roomOffset.x;
                roomOrigin.y = wall.y + 1;
                break;
            case Direction.RIGHT:
                roomOrigin.x = wall.x + 1;
                roomOrigin.y = wall.y - roomOffset.y;
                break;
            case Direction.LEFT:
                roomOrigin.x = wall.x - roomWidth;
                roomOrigin.y = wall.y - roomOffset.y;
                break;
            case Direction.DOWN:
                roomOrigin.x = wall.x - roomOffset.x;
                roomOrigin.y = wall.y - roomHeight;
                break;
            default:
                Debug.LogError("Unknown Direction found: " + wall.getDirection().ToString());
                break;

        }
        // Check if the rectangle is available (filled with walls)
        if (!checkRect(roomOrigin.x-spaceBetweenRooms, roomOrigin.y-spaceBetweenRooms, roomWidth+ spaceBetweenRooms*2, roomHeight+ spaceBetweenRooms*2, "Wall"))
            return false;

        //Debug.Log("room Origin: " + roomOrigin.ToString());
        // If so, create a room
        fillRect(roomOrigin.x, roomOrigin.y, roomWidth, roomHeight, floorTiles);
        // Create the entrace
        fillRect(wall.x, wall.y, 1, 1, floorTiles);

        roomsCount++;
        return true;
    }