Exemplo n.º 1
0
        public bool HasCollision(ICollidablePrimitive other)
        {
            #region Argument Check

            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            #endregion

            var otherCpp = other as ConvexPolygonPrimitive;
            if (otherCpp != null)
            {
                return(CollisionDetector.CheckPolygonToPolygonCollision(this, otherCpp));
            }

            var line = other as LinePrimitive;
            if (line != null)
            {
                return(CollisionDetector.CheckLineToPolygonCollision(line, this));
            }

            var circle = other as CirclePrimitive;
            if (circle != null)
            {
                return(CollisionDetector.CheckCircleToPolygonCollision(circle, this));
            }

            throw new NotSupportedException();
        }
Exemplo n.º 2
0
        public bool HasCollision(ICollidablePrimitive other)
        {
            #region Argument Check

            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            #endregion

            var otherLine = other as LinePrimitive;
            if (otherLine != null)
            {
                return(CollisionDetector.CheckLineToLineCollision(this, otherLine));
            }

            var circle = other as CirclePrimitive;
            if (circle != null)
            {
                return(CollisionDetector.CheckLineToCircleCollision(this, circle));
            }

            var polygon = other as ConvexPolygonPrimitive;
            if (polygon != null)
            {
                return(CollisionDetector.CheckLineToPolygonCollision(this, polygon));
            }

            throw new NotSupportedException();
        }
Exemplo n.º 3
0
        internal static bool CheckPrimitiveCollision(ICollidablePrimitive primitive, ICollidable other)
        {
            #region Argument Check

            if (primitive == null)
            {
                throw new ArgumentNullException("primitive");
            }

            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            #endregion

            var otherPrimitive = other as ICollidablePrimitive;
            if (otherPrimitive != null)
            {
                return(primitive.HasCollision(otherPrimitive));
            }

            var otherElement = other as ICollidableElement;
            if (otherElement != null)
            {
                return(CheckElementCollision(otherElement, primitive));
            }

            throw new NotSupportedException();
        }