示例#1
0
    public static Room[,] PlaceSpecial(Room[,] dungeon)
    {
        int dir = Random.Range(0, 3); // Generate a random side to place the boss room at (0: Left, 1: Top, 2: Right)

        switch (dir)
        {
        case 0:     //Left Side
            RoomFunctions.SetSpecialRoomLeft(dungeon, 2);
            RoomFunctions.SetSpecialRoomTop(dungeon, 0);
            RoomFunctions.SetSpecialRoomRight(dungeon, 0);
            break;

        case 1:     //Top Side
            RoomFunctions.SetSpecialRoomLeft(dungeon, 0);
            RoomFunctions.SetSpecialRoomTop(dungeon, 2);
            RoomFunctions.SetSpecialRoomRight(dungeon, 0);
            break;

        case 2:     //Right Side
            RoomFunctions.SetSpecialRoomLeft(dungeon, 0);
            RoomFunctions.SetSpecialRoomTop(dungeon, 0);
            RoomFunctions.SetSpecialRoomRight(dungeon, 2);
            break;
        }

        return(dungeon);
    }
    void InitialiseDungeon()
    {
        int sizemultiplier = tileSize * roomSize;

        // Initialise dungeon layout
        dungeon = new Room[gridSize, gridSize];

        // Populate dungeon array
        for (int iZ = 0; iZ < dungeon.GetLength(1); iZ++)
        {
            for (int iX = 0; iX < dungeon.GetLength(0); iX++)
            {
                dungeon[iX, iZ] = new Room();
            }
        }

        // Start runnin' and populate array with basic dungeon
        if (runnersKnowDirection == true)    // runner knows it's previous direction
        {
            for (int i = 0; i < runners; i++)
            {
                dungeon = MapGenerate.RunnerNoBacktrack(dungeon, new Vector2(gridSize / 2, gridSize / 2), Random.Range(5, maxDistance + 1), MapGenerate.RandomDirVector());
            }
        }
        else
        {
            for (int i = 0; i < runners; i++) // runner doesnt know it's previous direction
            {
                dungeon = MapGenerate.RunnerBasic(dungeon, new Vector2(gridSize / 2, gridSize / 2), Random.Range(5, maxDistance + 1));
            }
        }

        // Add extra Rooms to array
        MapGenerate.PlaceStart(dungeon);
        MapGenerate.PlaceSpecial(dungeon);


        // Assign Room Assets
        RoomFunctions.AssignRoomTypes(dungeon, roomSet);

        // Place Placeholders
        if (!drawBasic)
        {
            roomsList = DungeonSpawner.DrawLayout(dungeon, this.transform.position, this.transform, drawEmptyRooms, emptyTile);
        }
        else
        {
            roomsList = DungeonSpawner.DrawBasic(dungeon, tile, this.transform.position, sizemultiplier, this.transform, drawEmptyRooms, emptyTile);
        }

        //Generating Start Room
        //Instantiate(tile, new Vector3(gridsizeX / 2, 0, gridsizeZ / 2), Quaternion.identity);
    }