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); }
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)); }
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)); }