本文整理汇总了C#中Room.addDoor方法的典型用法代码示例。如果您正苦于以下问题:C# Room.addDoor方法的具体用法?C# Room.addDoor怎么用?C# Room.addDoor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room.addDoor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addNode
/// <summary>
/// Generate the level iteratively using breadth first generate
/// </summary>
/// <param name="map">Map of the entire level</param>
/// <param name="toBeGenerated">List (Queue) of rooms that are waiting to be added</param>
/// <param name="roomCount">Current number of rooms</param>
private int addNode(Dictionary<Vector2, Room> map, List<Room> toBeGenerated, int roomCount)
{
//While there are more rooms
while (toBeGenerated.Count > 0)
{
//Grab to top room and remove it from toBeGenerated
Room current = toBeGenerated[0];
toBeGenerated.RemoveAt(0);
//If the room is already in the map
Room inMap;
if (map.TryGetValue(current.position, out inMap))
{
//Give it any new doors
for (int e = 0; e < current.doors.Length; ++e)
{
if (current.doors[e] && !inMap.doors[e])
{
inMap.addDoor(e);
}
}
}//If the room isn't already in the map, we need to generate it
else
{
//Add it to the map
map.Add(current.position, current);
//How many doors this room has
int doorCount = 0;
//Buffs the chance of getting new rooms
float buff = 0;
//Buff the first room to make a spiderweb instead of a pole
if (roomCount == 1)
{
buff = 3.0f;
}
//Go through each door for the room
for (int e = 0; e < 4; ++e)
{
//If we are at the max room count, break
if (roomCount == curMaxSize)
{
break;
}
//If a door here does not already exist
if (!current.doors[e])
{
//Check to see if this room wants another door based on an algorithm
if (Random.Range(Mathf.Log(DifficultyTracker.difficultyTrack.getDifficulty() * DifficultyManager.dManager.floor) + buff, 10.0f + Mathf.Log(DifficultyTracker.difficultyTrack.getDifficulty() * DifficultyManager.dManager.floor) + (0.5f * doorCount)) > 5.0f)
{
Room temp;
//Make it harder to punch into existing rooms
if (!map.TryGetValue(dirToPos(current.position, e), out temp) || Random.Range(0.0f, 10.0f) > 2.0f)
{
//If the room in the given direction does exist, connect them
if (temp != null)
{
temp.addDoor(oppositeDirection(e));
current.addDoor(e);
}//If the room in the given direction doesn't exist
else if (roomCount < curMaxSize)
{
//Increment room count
++roomCount;
//Create the new room and connect them
Room newRoom = new Room();
newRoom.position = dirToPos(current.position, e);
newRoom.addDoor(oppositeDirection(e));
current.addDoor(e);
//Add the new room to the queue
toBeGenerated.Add(newRoom);
//If we are at the max room count, break
if (roomCount == curMaxSize)
{
break;
}
}
}
}
}
}
}
}
return roomCount;
}