Beispiel #1
0
    private void CreateRooms()
    {
        var roomsList = ProceduralGenerationAlgorithms.BinarySpacePartitioning(new BoundsInt((Vector3Int)startPosition, new Vector3Int(dungeonWidth, dungeonHeight, 0)), minRoomWidth, minRoomHeight);

        HashSet <Vector2Int> floor = new HashSet <Vector2Int>();

        if (randomWalkRooms)
        {
            floor = CreateRoomsRandomly(roomsList);
        }
        else
        {
            floor = CreateSimpleRooms(roomsList);
        }


        List <Vector2Int> roomCenters = new List <Vector2Int>();

        foreach (var room in roomsList)
        {
            roomCenters.Add((Vector2Int)Vector3Int.RoundToInt(room.center));
        }

        HashSet <Vector2Int> corridors = ConnectRooms(roomCenters);

        floor.UnionWith(corridors);

        tilemapVisualizer.PaintFloorTiles(floor);
        WallGenerator.CreateWalls(floor, tilemapVisualizer);
    }
Beispiel #2
0
    protected override void RunProceduralGeneration()
    {
        HashSet <Vector2Int> floorPositions = RunRandomWalk(randomWalkParameters, startPosition);

        tilemapVisualizer.Clear();
        tilemapVisualizer.PaintFloorTiles(floorPositions);
        WallGenerator.CreateWalls(floorPositions, tilemapVisualizer);
    }
Beispiel #3
0
    private void CorridorFirstGeneration()
    {
        HashSet <Vector2Int> floorPositions         = new HashSet <Vector2Int>();
        HashSet <Vector2Int> potentialRoomPositions = new HashSet <Vector2Int>();

        CreateCorridors(floorPositions, potentialRoomPositions);

        HashSet <Vector2Int> roomPositions = CreateRooms(potentialRoomPositions);

        List <Vector2Int> deadEnds = FindAllDeadEnds(floorPositions);

        CreateRoomsAtDeadEnds(deadEnds, roomPositions);

        floorPositions.UnionWith(roomPositions);

        tileMapVisualiser.paintFloorTile(floorPositions);
        WallGenerator.CreateWalls(floorPositions, tileMapVisualiser);
    }