Пример #1
0
        /// <summary>
        /// Constructs a list of nodes based on the geometry of the given body
        /// </summary>
        /// <param name="body"></param>
        /// <param name="distanceFromBody"></param>
        /// <param name="maxDistanceBetweenEachNode"></param>
        /// <returns></returns>
        public static List<Node> Construct(AbstractBody body, int distanceFromBody, int maxDistanceBetweenEachNode)
        {
            List<Node> result = new List<Node>();

            Type bodyType = body.GetType();

            if (bodyType.Equals(typeof(CircleBody)))
            {
                result = Construct((CircleBody)body, distanceFromBody, maxDistanceBetweenEachNode);
            }
            else
            {
                result = Construct((RectangleBody)body, distanceFromBody, maxDistanceBetweenEachNode);
            }

            return result;
        }
Пример #2
0
        /// <summary>
        /// Detect collision
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        public bool DetectCollision(AbstractBody body)
        {
            bool result = false;

            Type bodyType = body.GetType();

            if (bodyType.Equals(typeof(CircleBody)))
            {
                result = this.DetectCollision((CircleBody)body);
            }
            else if (bodyType.Equals(typeof(RectangleBody)))
            {
                result = this.DetectCollision((RectangleBody)body);
            }
            else if (bodyType.Equals(typeof(LineBody)))
            {
                result = this.DetectCollision((LineBody)body);
            }

            return result;
        }