Пример #1
0
        /// <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>
        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));
        }
Пример #2
0
 public bool CollideAgainstBounce(Capsule2D capsule2D, float thisMass, float otherMass, float elasticity)
 {
     throw new NotImplementedException("This method is not implemented. Capsules are intended only for CollideAgainst - use Polygons for CollideAgainstMove and CollideAgainstBounce");
 }
Пример #3
0
 public bool CollideAgainst(Capsule2D capsule)
 {
     throw new NotImplementedException("This method hasn't been implemented yet.  Please complain on the FlatRedBall forums.");
 }