Ejemplo n.º 1
0
    private void CreateRooms()
    {
        var roomsList = ProceduralGenerationAlgorithms.BinarySpacePartitioning(new BoundsInt((Vector3Int)startPos, new Vector3Int(dungeonWidth, dungeonHeight, 0)),
                                                                               minRoomWidth, minRoomHeight);                                                                                    // divide the dungeon into multiple rooms
        HashSet <Vector2Int> floor = new HashSet <Vector2Int>();

        if (randomWalkRooms)
        {
            floor = CreateRoomsRandomly(roomsList);                                                                         // create rooms with randomwalk using the divided rooms provided
        }
        else
        {
            floor = CreateSimpleRooms(roomsList);                                                                                                                                       // create simple rooms using the divided rooms provided
        }

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

        foreach (var room in roomsList)
        {
            roomCenters.Add((Vector2Int)Vector3Int.RoundToInt(room.center));                                                                                    // get the center of each room and add it to roomCenters
        }

        HashSet <Vector2Int> corridors = ConnectRooms(roomCenters);

        floor.UnionWith(corridors);

        tilemapVisualizer.PaintFloorTile(floor);
        WallGenerator.CreateWall(floor, tilemapVisualizer);
    }
Ejemplo n.º 2
0
    protected override void RunProcedualGeneration()
    {
        HashSet <Vector2Int> floorPositions = RunRandomWalk(randomWalkParameters, startPos);

        tilemapVisualizer.Clear();
        tilemapVisualizer.PaintFloorTile(floorPositions);
        WallGenerator.CreateWall(floorPositions, tilemapVisualizer);
    }
    private void CorridorFirstGeneration()
    {
        HashSet <Vector2Int> floorPositions         = new HashSet <Vector2Int>();
        HashSet <Vector2Int> potentialRoomPositions = new HashSet <Vector2Int>();

        CreateCorridoor(floorPositions, potentialRoomPositions);

        HashSet <Vector2Int> roomPositions = CreateRooms(potentialRoomPositions);
        List <Vector2Int>    deadEnds      = FindAllDeadEnd(floorPositions);

        CreateRoomAtDeadEnd(deadEnds, roomPositions);
        floorPositions.UnionWith(roomPositions);                        // save both corridor and room floor

        tilemapVisualizer.PaintFloorTile(floorPositions);
        WallGenerator.CreateWall(floorPositions, tilemapVisualizer);
    }