Beispiel #1
0
        //Circle
        public static bool CircleToCircle(CircleCollider circle1, CircleCollider circle2)
        {
            var dx    = circle2.Position.X - circle1.Position.X;
            var dy    = circle2.Position.Y - circle2.Position.Y;
            var radii = circle1.Radius + circle2.Radius;

            return((dx * dx) + (dy * dy) < (radii * radii));
        }
Beispiel #2
0
 public override bool Collide(CircleCollider circle)
 {
     foreach (var c in colliders)
     {
         if (c.Collide(circle))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        //Line
        public static bool CircleToLine(CircleCollider circle, Vector2 lineStart, Vector2 lineEnd)
        {
            var direction = lineEnd - lineStart;

            direction.Normalize();
            var distance = Vector2.Dot(direction, circle.Position);

            if (distance >= circle.Radius)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public static bool CircleToPoint(CircleCollider circle, Vector2 point)
 {
     return(CircleToPoint(circle.Position.X, circle.Position.Y, circle.Radius, point.X, point.Y));
 }
Beispiel #5
0
 //Circle
 public static bool LineToCircle(float lineStartX, float lineStartY, float lineEndX, float lineEndY, CircleCollider circle)
 {
     return(CircleToLine(circle, new Vector2(lineStartX, lineStartY), new Vector2(lineEndX, lineEndY)));
 }
Beispiel #6
0
 public static bool RectToCircle(RectCollider rect, CircleCollider circle)
 {
     return(RectToCircle(rect.AbsolutePosition.X, rect.AbsolutePosition.Y, rect.Width, rect.Height, circle.AbsolutePosition.X, circle.AbsolutePosition.Y, circle.Radius));
 }
Beispiel #7
0
 public static bool RectToCircle(Rectangle rect, CircleCollider circle)
 {
     return(RectToCircle(rect.X, rect.Y, rect.Width, rect.Height, circle.Position.X, circle.Position.Y, circle.Radius));
 }
Beispiel #8
0
 //Rectangle
 public static bool CircleToRectangle(CircleCollider circle, RectCollider rect)
 {
     return(RectToCircle(rect, circle));
 }
Beispiel #9
0
 public override bool Collide(CircleCollider circle)
 {
     return(false);
 }