本文整理汇总了C#中Room.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Room.Equals方法的具体用法?C# Room.Equals怎么用?C# Room.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRandomTask
public Task GetRandomTask(int duration, Room room)
{
IList<Task> list;
if (room.Equals(Room.AllRooms))
list = (from task in Tasks where (task.Duration.Equals(duration)) select task).ToList();
else
list =
(from task in Tasks where (task.Duration.Equals(duration)) && (task.Room.Equals(room)) select task).
ToList();
return list[(new Random()).Next(0, list.Count)];
}
示例2: roomIntersects
/* Check if parameter room intersects with any others in the list of rooms created so far */
private bool roomIntersects(Room room)
{
foreach (Room curRoom in rooms)
{
// If the current room is the parameter room, ignore it
if(room.Equals(curRoom)) continue;
/* //Debug code
Console.WriteLine("room's bottom edge->{0}",(room.x + room.w)-1);
Console.WriteLine("room's top edge->{0}", room.x);
Console.WriteLine("room's right edge->{0}", (room.y + room.h)-1);
Console.WriteLine("room's left edge->{0}", room.y);
Console.WriteLine("curRoom's top edge->{0}", curRoom.x);
Console.WriteLine("curRoom's bottom edge->{0}", (curRoom.x + curRoom.w)-1);
Console.WriteLine("curRoom's left edge->{0}", curRoom.y);
Console.WriteLine("curRoom's right edge->{0}", (curRoom.y + curRoom.h)-1);
* */
// Box collision checking
if(!((room.x + room.w)-1 < curRoom.x) && // room's right edge is left of curRoom's left
!(room.x > (curRoom.x + curRoom.w)-1) && // room's left edge is right of curRoom's right
!((room.y + room.h)-1 < curRoom.y) && // room's bottom edge is above curRoom's top
!(room.y > (curRoom.y + curRoom.h)-1 )) // room's top edge is below curRoom's bottom
{
return true;
}
}
return false;
}
示例3: findNearestRoom
/* In the list of created rooms, find and return the nearest room to the parameter room */
private Room findNearestRoom(Room room)
{
// Midpoint of parameter room
Point midPoint = new Point(room.x + (room.w / 2),
room.y + (room.h / 2));
Room nearestRoom = new Room();
int nearest_distance = 1000000;
// For each room
foreach (Room curRoom in rooms)
{
// If the current room is the parameter room, ignore it
if (curRoom.Equals(room)) continue;
// Current room's midpoint
Point cur_midPoint = new Point(curRoom.x + (curRoom.w / 2),
curRoom.y + (curRoom.h / 2));
// Calculate distance between parameter room and current room
int distance = (int)Math.Sqrt((midPoint.x - cur_midPoint.x)^2 + (midPoint.y - cur_midPoint.y)^2);
// Check if the current room qualifies as the new closest room
if(distance < nearest_distance)
{
nearest_distance = distance;
nearestRoom = curRoom;
}
}
if (nearestRoom.Equals(null))
{
Console.WriteLine("Attempted to return null nearest room");
System.Environment.Exit(1);
}
return nearestRoom;
}