Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/AxisAlignedRectangle.cs
/// <summary>
/// Returns whether this instance collides against the argument Capsule2D.
/// </summary>
/// <param name="capsule">The Capsule2D to test collision against.</param>
/// <returns>Whether collision has occurred.</returns>
Returns whether this instance collides against the argument Capsule2D.
Returns whether this instance collides against the argument Capsule2D .
public bool CollideAgainst(Capsule2D capsule)
		{
            UpdateDependencies(TimeManager.CurrentTime);
            capsule.UpdateDependencies(TimeManager.CurrentTime);
            Circle circle = Capsule2D.CollisionCircle;
            circle.Position = capsule.Endpoint1Position;
            circle.Radius = capsule.EndpointRadius;
            bool collision = circle.CollideAgainst(this);
            if (collision)
            {
                return true;
            }
            circle.Position = capsule.Endpoint2Position;
            collision = circle.CollideAgainst(this);
            if (collision)
            {
                return true;
            }
            Polygon polygon = Capsule2D.CollisionPolygon;
            float right = capsule.Scale - capsule.EndpointRadius;
            float top = capsule.EndpointRadius;
            polygon.SetPoint(0, -right, top);
            polygon.SetPoint(1, right, top);
            polygon.SetPoint(2, right, -top);
            polygon.SetPoint(3, -right, -top);
            polygon.SetPoint(4, -right, top);
            polygon.Position = capsule.Position;
            polygon.RotationMatrix = capsule.RotationMatrix;
            polygon.UpdateDependencies(TimeManager.CurrentTime);
            return this.CollideAgainst(polygon);
		}
public bool CollideAgainst ( Capsule2D capsule ) { UpdateDependencies ( TimeManager . CurrentTime ) ; capsule . UpdateDependencies ( TimeManager . CurrentTime ) ; Circle circle = Capsule2D . CollisionCircle ; circle . Position = capsule . Endpoint1Position ; circle . Radius = capsule . EndpointRadius ; bool collision = circle . CollideAgainst ( this ) ; if ( collision ) { return true ; } circle . Position = capsule . Endpoint2Position ; collision = circle . CollideAgainst ( this ) ; if ( collision ) { return true ; } Polygon polygon = Capsule2D . CollisionPolygon ; float right = capsule . Scale - capsule . EndpointRadius ; float top = capsule . EndpointRadius ; polygon . SetPoint ( 0 , - right , top ) ; polygon . SetPoint ( 1 , right , top ) ; polygon . SetPoint ( 2 , right , - top ) ; polygon . SetPoint ( 3 , - right , - top ) ; polygon . SetPoint ( 4 , - right , top ) ; polygon . Position = capsule . Position ; polygon . RotationMatrix = capsule . RotationMatrix ; polygon . UpdateDependencies ( TimeManager . CurrentTime ) ; return this . CollideAgainst ( polygon ) ; }
Returns whether this instance collides against the argument Capsule2D.
Returns whether this instance collides against the argument Capsule2D .
Whether collision has occurred.
Whether collision has occurred .
capsule
Capsule2D
The Capsule2D to test collision against.
The Capsule2D to test collision against .