public Side CollidingSide(PhysicalObject other) { float distanceTop = Math.Abs(Y - other.Bottom); float distanceBottom = Math.Abs(Bottom - other.Y); float distanceLeft = Math.Abs(other.Right - X); float distanceRight = Math.Abs(other.Size.Left - Size.Right); float min = Math.Min(Math.Min(distanceTop, distanceBottom), Math.Min(distanceLeft, distanceRight)); if (min == distanceRight) return Side.Right; if (min == distanceLeft) return Side.Left; if (min == distanceTop) return Side.Up; if (min == distanceBottom) return Side.Down; throw new InvalidEnumArgumentException("Side"); }
public virtual bool IsColliding(PhysicalObject other) { return Size.Intersects(other.Size); }