Ejemplo n.º 1
0
        public bool CollidesWith(ICollisionShape otherShape)
        {
            if (otherShape is CollisionSet)
            {
                return(otherShape.CollidesWith(this));
            }
            var circleShape = otherShape as CollisionCircle;

            if (circleShape != null)
            {
                return(CollidesWith(circleShape.circle));
            }
            var rectShape = otherShape as CollisionRect;

            if (rectShape != null)
            {
                return(CollidesWith(rectShape.rectangle));
            }
            var pointShape = otherShape as CollisionPoint;

            if (pointShape != null)
            {
                return(circle.Contains(pointShape.Position));
            }
            return(false);
        }
Ejemplo n.º 2
0
 public bool CollidesWith(ICollisionShape otherShape)
 {
     if (otherShape is CollisionPoint)
     {
         var otherPoint = otherShape as CollisionPoint;
         return(Vector2.Distance(Position, otherPoint.Position) < MIN_COLLISION_DIST);
     }
     return(otherShape.CollidesWith(this));
 }
Ejemplo n.º 3
0
 public bool CollidesWith(ICollisionShape otherShape)
 {
     if (otherShape is CollisionRect)
     {
         var otherRect = otherShape as CollisionRect;
         return(CollidesWith(((CollisionRect)otherShape).rectangle));
     }
     if (otherShape is CollisionPoint)
     {
         return(rectangle.Contains(((CollisionPoint)otherShape).Position));
     }
     return(otherShape.CollidesWith(this));
 }