Exemplo 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));
        }
Exemplo n.º 2
0
        public override bool CollidesWithShape(Shape other, out CollisionResult result)
        {
            if (other is Polygon)
            {
                return(ShapeCollisions.PolygonToPolygon(this, other as Polygon, out result));
            }

            if (other is Circle)
            {
                if (ShapeCollisions.CircleToPolygon(other as Circle, this, out result))
                {
                    result.InvertResult();
                    return(true);
                }
                return(false);
            }

            throw new NotImplementedException(string.Format("overlaps of Polygon to {0} are not supported", other));
        }
Exemplo n.º 3
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));
        }