コード例 #1
0
    /// <summary>
    /// Check to see if a given room {roomCheck} is colliding with any existing rooms {roomSpawns}
    /// </summary>
    /// <param name="roomSpawns"></param>
    /// <param name="roomCheck"></param>
    /// <returns></returns>
    private bool CheckRoomIntersections(List <RoomSpawn> roomSpawns, RoomSpawn roomCheck)
    {
        List <Vector4> sizesCheck = roomCheck.roomSize;

        foreach (RoomSpawn room in roomSpawns)
        {
            List <Vector4> sizes = room.roomSize;
            foreach (Vector4 sizeCheck in sizesCheck)
            {
                foreach (Vector4 size in sizes)
                {
                    bool check = helper.AABBTest(new Vector2(sizeCheck.x + roomCheck.location.x, sizeCheck.y + roomCheck.location.y), new Vector2(sizeCheck.z, sizeCheck.w),
                                                 new Vector2(size.x + room.location.x, size.y + room.location.y), new Vector2(size.z, size.w));
                    if (check)
                    {
                        return(true);
                    }
                }
            }
        }

        return(false);
    }