Пример #1
0
        public static bool IsTouching(this IQuboidPlace root, IQuboidPlace otherPlace, Direction direction)
        {
            switch (direction)
            {
            case Direction.Left:
                return(root.Left == otherPlace.Right && !(root.Down >= otherPlace.Up || root.Up <= otherPlace.Down || root.Front <= otherPlace.Back || root.Back >= otherPlace.Front));

            case Direction.Right:
                return(otherPlace.IsTouching(root, Direction.Left));;

            case Direction.Back:
                return(root.Back == otherPlace.Front && !(root.Down >= otherPlace.Up || root.Up <= otherPlace.Down || root.Right <= otherPlace.Left || root.Left >= otherPlace.Right));

            case Direction.Front:
                return(otherPlace.IsTouching(root, Direction.Back));

            case Direction.Down:
                return(root.Down == otherPlace.Up && !(root.Left >= otherPlace.Right || root.Right <= otherPlace.Left || root.Front <= otherPlace.Back || root.Back >= otherPlace.Front));

            case Direction.Up:
                return(otherPlace.IsTouching(root, Direction.Down));

            default:
                break;
            }
            return(false);
        }
Пример #2
0
 public static bool Contains(this IQuboidPlace qplace, IQuboidLogic package, int rotation)
 {
     if (qplace.Length >= package.GetLength(rotation) &&
         qplace.Width >= package.GetWidth(rotation) &&
         qplace.Height >= package.GetHeight(rotation))
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
        public static bool Intersect2D(this IQuboidPlace quboidPlace, IQuboidPlace otherQuboidPlace)
        {
            if (
                (quboidPlace.Back >= otherQuboidPlace.Front) || (quboidPlace.Front <= otherQuboidPlace.Back) ||
                (quboidPlace.Left >= otherQuboidPlace.Right) || (quboidPlace.Right <= otherQuboidPlace.Left)
                )
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
 public QuboidPlace(IQuboidPlace model)
 {
     if (model != null)
     {
         Left   = model.Left;
         Back   = model.Back;
         Down   = model.Down;
         Width  = model.Width;
         Length = model.Length;
         Height = model.Height;
     }
 }