コード例 #1
0
 void PopulateRooms(GameHandler gameHandler, int difficultyLevel)
 {
     // Go through all the rooms...
     for (int i = 0; i < rooms.Length; i++)
     {
         // ... and Populate each Room with Enemies
         PopulatedRoom room = rooms [i];
         room.PopulateRoomWithEnemies(gameHandler, difficultyLevel);
     }
 }
コード例 #2
0
    void CreateRoomsAndCorridors()
    {
        // Create the rooms array with a random size.
        rooms = new PopulatedRoom[numRooms.Random];

        // There should be one less corridor than there is rooms.
        corridors = new Corridor[rooms.Length - 1];

        // Create the first room and corridor.
        rooms[0]     = new PopulatedRoom();
        corridors[0] = new Corridor();

        // Setup the first room, there is no previous corridor so we do not use one.
        rooms[0].SetupFirstRoom(roomWidth, roomHeight, columns, rows);

        // Setup the first corridor using the first room.
        corridors[0].SetupCorridor(rooms[0], corridorLength, roomWidth, roomHeight, columns, rows, true);

        for (int i = 1; i < rooms.Length; i++)
        {
            // Create a room.
            rooms[i] = new PopulatedRoom();

            // Setup the room based on the previous corridor.
            rooms[i].SetupRoom(roomWidth, roomHeight, columns, rows, corridors[i - 1]);

            // If we haven't reached the end of the corridors array...
            if (i < corridors.Length)
            {
                // ... create a corridor.
                corridors[i] = new Corridor();

                // Setup the corridor based on the room that was just created.
                corridors[i].SetupCorridor(rooms[i], corridorLength, roomWidth, roomHeight, columns, rows, false);
            }



            if (i == 1)
            {
                Vector3    playerPos = new Vector3(rooms[i].xPos, rooms[i].yPos, 0);
                GameObject player    = GameHandler.instance.player;
                player.transform.position = playerPos;
            }
        }
    }
コード例 #3
0
    void SetPopulatedTilesValues()
    {
        // Go through all the rooms...
        for (int n = 0; n < rooms.Length; n++)
        {
            PopulatedRoom currentRoom = rooms[n];

            // ... and for each room go through it's width.
            for (int i = 0; i < currentRoom.roomWidth; i++)
            {
                int xCoord = currentRoom.xPos + i;

                // For each horizontal tile, go up vertically through the room's height.
                for (int j = 0; j < currentRoom.roomHeight; j++)
                {
                    int yCoord = currentRoom.yPos + j;

                    // The coordinates in the jagged array are based on the room's position and it's width and height.
                    populatedTiles[xCoord][yCoord] = currentRoom.populatedTiles[i][j];
                }
            }
        }
    }