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


C# Room.Equals方法代码示例

本文整理汇总了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)];
        } 
开发者ID:tebriel,项目名称:UfYH.Net,代码行数:12,代码来源:RandomListModel.cs

示例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;
    }
开发者ID:FreeReign,项目名称:Dungeon-Generator,代码行数:30,代码来源:DungeonGenerator.cs

示例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;
 }
开发者ID:FreeReign,项目名称:Dungeon-Generator,代码行数:32,代码来源:DungeonGenerator.cs


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