Ejemplo n.º 1
0
        public override bool CollidesWithShape(Shape other, out CollisionResult result)
        {
            if (other is Box && (other as Box).IsUnrotated)
            {
                return(ShapeCollisions.CircleToBox(this, other as Box, out result));
            }

            if (other is Circle)
            {
                return(ShapeCollisions.CircleToCircle(this, other as Circle, out result));
            }

            if (other is Polygon)
            {
                return(ShapeCollisions.CircleToPolygon(this, other as Polygon, out result));
            }

            throw new NotImplementedException(string.Format("Collisions of Circle to {0} are not supported", other));
        }
Ejemplo n.º 2
0
        public override bool Overlaps(Shape other)
        {
            CollisionResult result;

            // Box is only optimized for unrotated
            if (other is Box && (other as Box).IsUnrotated)
            {
                return(Collisions.RectToCircle(ref other.bounds, position, Radius));
            }

            if (other is Circle)
            {
                return(Collisions.CircleToCircle(position, Radius, other.position, (other as Circle).Radius));
            }

            if (other is Polygon)
            {
                return(ShapeCollisions.CircleToPolygon(this, other as Polygon, out result));
            }

            throw new NotImplementedException(string.Format("overlaps of Circle to {0} are not supported", other));
        }