예제 #1
0
        /// <summary>
        /// Return boolean that indicates,
        /// if position of Ship is Equal to position of the current Missile of invader
        /// </summary>
        /// <param name="d1"></param>
        /// <param name="d2"></param>
        /// <returns></returns>
        private bool CollisionHitBox(DisplayableObject d1, DisplayableObject d2)
        {
            if (d1 != null && d2 != null)
            {
                return(d1.X == d2.X & d1.Y == d2.Y);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Check collision between a DisplayableObject and a set of Displayable object
        /// </summary>
        /// <param name="d1"></param>
        /// <param name="dSet"></param>
        /// <returns></returns>
        private DisplayableObject CollisionObjectsHitBox(DisplayableObject d1, DisplayableObject[] dSet)
        {
            foreach (DisplayableObject d2 in dSet)
            {
                if (CollisionHitBox(d1, d2))
                {
                    return(d2);
                }
            }

            return(null);
        }