当前位置: 首页>>代码示例>>C#>>正文


C# Room.SetupRoom方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:technicalvgda,项目名称:Adagio,代码行数:101,代码来源:BoardCreator.cs


注:本文中的Room.SetupRoom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。