예제 #1
0
        /// <summary>
        /// Verify if the point is inside the squre area
        /// </summary>
        /// <param name="square"></param>
        /// <param name="point"></param>
        public static bool Inside(RectPosition square, Vector2 point)
        {
            if (square.position.X <= point.X && point.X < square.position.X + square.size.X)
            {
                if (square.position.Y <= point.Y && point.Y < square.position.Y + square.size.Y)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Verify if two square are in contact
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static bool Hit(RectPosition a, RectPosition b)
        {
            if (
                RectPosition.Inside(a, b.position.Xy) ||
                RectPosition.Inside(a, b.position.Xy + new Vector2(b.size.X, 0)) ||
                RectPosition.Inside(a, b.position.Xy + new Vector2(0, b.size.Y)) ||
                RectPosition.Inside(a, b.position.Xy + b.size))
            {
                return(true);
            }

            return(false);
        }