private void AddAdjacentRoomInDirection(TreeNode currentNode, IRoom room, RoomExits direction) { if (room.GetRoomExit(direction) != null) { if (currentNode.Parent != null && room.GetRoomExit(direction).availableExits[direction].Id != currentNode.Parent.ID) { var newNode = new TreeNode(room.GetRoomExit(direction).availableExits[direction]); if (!_unvisitedNodes.Contains(newNode)) { if (!currentNode.AdjacentNodes.ContainsKey(direction.ToString())) { currentNode.AdjacentNodes.Add(direction.ToString(), newNode); currentNode.AdjacentNodes[direction.ToString()].Parent = currentNode; AddNode(newNode); } } } } }
public IExit GetRoomExit(RoomExits direction = Interfaces.RoomExits.None) { GetRoomExits(); IExit result = null; if (direction != Interfaces.RoomExits.None) { result = RoomExits.Where(e => e.Direction.ToUpper() == direction.ToString().ToUpper()).SingleOrDefault(); } else { result = RoomExits.FirstOrDefault(); } return result; }