isCollision static method

bool isCollision(
  1. Shape a,
  2. Shape b
)

Implementation

static bool isCollision(Shape a, Shape b) {
  if (a is RectangleShape) {
    if (b is RectangleShape) {
      return rectToRect(a, b);
    } else if (b is CircleShape) {
      return rectToCircle(a, b);
    } else if (b is PolygonShape) {
      return rectToPolygon(a, b);
    } else {
      return false;
    }
  } else if (a is CircleShape) {
    if (b is RectangleShape) {
      return rectToCircle(b, a);
    } else if (b is CircleShape) {
      return circleToCircle(a, b);
    } else if (b is PolygonShape) {
      return circleToPolygon(a, b);
    } else {
      return false;
    }
  } else {
    if (b is RectangleShape && a is PolygonShape) {
      return rectToPolygon(b, a);
    } else if (b is CircleShape && a is PolygonShape) {
      return circleToPolygon(b, a);
    } else if (b is PolygonShape && a is PolygonShape) {
      return polygonToPolygon(a, b);
    } else {
      return false;
    }
  }
}