protected override bool CollideRectangle(RectangleCollider other, out CollisionData data) { Vector2 depth = AABB.GetIntersectionDepth(Bounds, other.Bounds); if (depth != Vector2.Zero && (Math.Abs(depth.X) > 1 || Math.Abs(depth.Y) > 1)) { data = new CollisionData(depth); return true; } data = new CollisionData(Vector2.Zero); return false; }
public static bool Collide(Collider a, Collider b, out CollisionData data) { return a.Collide(b, out data); }
// ABSTRACT METHODS protected abstract bool CollideRectangle(RectangleCollider other, out CollisionData data);
protected abstract bool CollidePolygon(PolygonCollider other, out CollisionData data);
protected abstract bool CollideCircle(CircleCollider other, out CollisionData data);
public virtual bool Collide(Collider other, out CollisionData data) { switch (other.Type) { case ColliderTypes.Rectangle: return CollideRectangle(other as RectangleCollider, out data); case ColliderTypes.Circle: return CollideCircle(other as CircleCollider, out data); case ColliderTypes.Polygon: return CollidePolygon(other as PolygonCollider, out data); default: data = new CollisionData(Vector2.Zero); return false; } }
protected override bool CollideRectangle(RectangleCollider other, out CollisionData data) { // TODO: check collision data = new CollisionData(Vector2.Zero); return false; }
protected override bool CollidePolygon(PolygonCollider other, out CollisionData data) { // TODO: check collision data = new CollisionData(Vector2.Zero); return false; }