コード例 #1
0
        public bool TryGetTouchedSide(IntRectangle other, out Side touchedSide)
        {
            if (Left < other.Right && Right > other.Left && Front < other.Back && Back > other.Front)
            {
                if (Top == other.Bottom)
                {
                    touchedSide = Side.Top;
                    return(true);
                }
                if (Bottom == other.Top)
                {
                    touchedSide = Side.Bottom;
                    return(true);
                }
            }

            if (Top < other.Bottom && Bottom > other.Top && Front < other.Back && Back > other.Front)
            {
                if (Left == other.Right)
                {
                    touchedSide = Side.Left;
                    return(true);
                }
                if (Right == other.Left)
                {
                    touchedSide = Side.Right;
                    return(true);
                }
            }

            if (Left < other.Right && Right > other.Left && Top < other.Bottom && Bottom > other.Top)
            {
                if (Front == other.Back)
                {
                    touchedSide = Side.Front;
                    return(true);
                }
                if (Back == other.Front)
                {
                    touchedSide = Side.Back;
                    return(true);
                }
            }

            touchedSide = Side.Left;
            return(false);
        }
コード例 #2
0
 public static IntRectangle FromCenterAndSite(IntVector center, IntVector size)
 {
     return(IntRectangle.FromPositionAndSize(center - size / 2, size));
 }
コード例 #3
0
 public bool Intersects(IntRectangle other)
 {
     return(other.Right > Left && other.Left < Right && other.Bottom > Top && other.Top < Bottom && other.Back > Front && other.Front < Back);
 }