本文整理汇总了C#中Room.SetupRoom方法的典型用法代码示例。如果您正苦于以下问题:C# Room.SetupRoom方法的具体用法?C# Room.SetupRoom怎么用?C# Room.SetupRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room.SetupRoom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRoomsAndCorridors
void CreateRoomsAndCorridors()
{
while (needRoomsAndCorridorsCreation == true)
{
// Create the rooms array with a random size.
rooms = new Room[numRooms.Random];
//Non IntRange representation of how many rooms there are
int numbRooms = rooms.Length;
// There should be one less corridor than there is rooms.
corridors = new Corridor[rooms.Length - 1];
// There will be a specified number of appending corridor
aCorridors = new Corridor[rooms.Length - 2];
//Make dead end corridor array
deadEndCorridorsArray = new Corridor[corridors.Length];
// Create the first room and corridor.
rooms [0] = new Room ();
corridors [0] = new Corridor ();
// Setup the first room, there is no previous corridor so we do not use one.
rooms [0].SetupRoom (roomWidth, roomHeight, columns, rows);
// Setup the first corridor using the first room.
corridors [0].SetupCorridor (rooms [0], corridorLength, roomWidth, roomHeight, columns, rows, true);
// Set up second room. Check for overlap is not necessary
rooms [1] = new Room ();
rooms [1].SetupRoom (roomWidth, roomHeight, columns, rows, corridors [0]);
// Set up the rest of the rooms and corridors, checking for overlaps
for (int i = 2; i < rooms.Length; i++) {
bool goodRoomPlacement = false;
bool goodCorridorPlacement = false;
bool goodAppCorridorPlacement = false;
bool goodDeadEndCorridorPlacement = false;
//bool goodCorridorNotOverlapRoomPlacement = false;
bool goodRoomNotOverlapCorridorPlacement = false;
//bool roomOverlapsCorridor = false;
//bool roomOverlapsAppCorridor = false;
//bool roomOverlapsDeadEndCorridor = false;
bool makeDeadEndCorridor = true;
//If generation has tried different corridor/room placements exceeding the number of rooms there are
if (triedCounter >= numbRooms * 2) {
//Then reload the level
//reloadLevelNeeded = true;
//SceneManager.LoadScene (3);
break;
}
// If room overlaps with any other rooms, create entirely new corridor leaving from the last created room
while (!goodRoomPlacement && !goodCorridorPlacement && !goodDeadEndCorridorPlacement && !goodAppCorridorPlacement && !goodRoomNotOverlapCorridorPlacement) {
bool appendCorridor = false;
// Create test corridor and room
Corridor corridorToBePlaced = new Corridor ();
Corridor corridorToAppend = new Corridor ();
if (numAppend < rooms.Length - 1)
appendCorridor = true;
//If a room in the array is null then there was an error with generation. Restart the scene
if (rooms [i - 1] == null) {
//reloadLevelNeeded = true;
//SceneManager.LoadScene (3);
break;
}
//Set tried counter to 0 and enter into while loop with placementNeeded as true
triedCounter = 0;
placementNeeded = true;
//Stays in this loop until a good placement or the amount of tries has been exceeded
while (placementNeeded == true) {
triedCounter++;
if (triedCounter >= numbRooms * 2)
break;
//Create the corridor
//Make the corridor
corridorToBePlaced.SetupCorridor (rooms [i - 1], corridorLength, roomWidth, roomHeight, columns, rows, false);
//Stay in this loop until the corridor is longer than the minimum length or until tries are exhausted
while (corridorToBePlaced.corridorLength < minCorridorLength) {
triedCounter++;
corridorToBePlaced.SetupCorridor (rooms [i - 1], corridorLength, roomWidth, roomHeight, columns, rows, false);
if (triedCounter >= numbRooms * 2)
break;
}
if (triedCounter >= numbRooms * 2)
break;
if (corridorToBePlaced.corridorLength < minCorridorLength) {
//Do nothing
} else {
//Check to see if it overlaps any rooms/corridors
//.........这里部分代码省略.........