示例#1
0
 /// <summary>
 /// Check for a collision between a RectCollider and a RayCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RectCollider self, RayCollider other)
 {
     Vector2[] corners = self.Corners;
     Vector2 p1, p2;
     for (int i = 0; i < 4; i++)
     {
         p1 = corners[i];
         p2 = corners[(i + 1) % 4];
         if (GeometryUtils.RayToSegmentPOI(
             other.x1, other.y1, other.x2, other.y2,
             p1.X, p1.Y, p2.X, p2.Y).HasValue)
             return true;
     }
     return false;
 }
示例#2
0
        /// <summary>
        /// Check for a collision between a RectCollider and a RayCollider.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="other"></param>
        public static bool Collision(RectCollider self, RayCollider other)
        {
            Vector2[] corners = self.Corners;
            Vector2   p1, p2;

            for (int i = 0; i < 4; i++)
            {
                p1 = corners[i];
                p2 = corners[(i + 1) % 4];
                if (GeometryUtils.RayToSegmentPOI(
                        other.x1, other.y1, other.x2, other.y2,
                        p1.X, p1.Y, p2.X, p2.Y).HasValue)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
 /// <summary>
 /// Check for a collision between a LineSegmentCollider and a RayCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(LineSegmentCollider self, RayCollider other)
 {
     return(Collision(other, self));
 }
示例#4
0
 /// <summary>
 /// Check for a collision between a RayCollider and a CircleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, CircleCollider other)
 {
     return(Collision(other, self));
 }
示例#5
0
 /// <summary>
 /// Check for a collision between a RayCollider and a RayCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, RayCollider other)
 {
     return(GeometryUtils.AreRaysIntersecting(
                self.x1, self.y1, self.x2, self.y2,
                other.x1, other.y1, other.x2, other.y2));
 }
示例#6
0
 /// <summary>
 /// Check for a collision between a RayCollider and a LineSegmentCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, LineSegmentCollider other)
 {
     return(GeometryUtils.RayToSegmentPOI(
                self.x1, self.y1, self.x2, self.y1,
                other.x1, other.y1, other.x2, other.y2).HasValue);
 }
示例#7
0
 /// <summary>
 /// Check for a collision between a RayCollider and a ParticleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, ParticleCollider other)
 {
     return(GeometryUtils.IsPointOnRay(other.x, other.y, self.x1, self.y1, self.x2, self.y2));
 }
示例#8
0
 public static bool Collision(CircleCollider self, RayCollider other)
 {
     return(GeometryUtils.CircleToRayPOI(
                self.x, self.y, self.radius, other.x1, other.y1, other.x2, other.y2).Length > 0);
 }
示例#9
0
 /// <summary>
 /// Check for a collision between a ParticleCollider and a RayCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(ParticleCollider self, RayCollider other)
 {
     return Collision(other, self);
 }
示例#10
0
 public static bool Collision(CircleCollider self, RayCollider other)
 {
     return GeometryUtils.CircleToRayPOI(
         self.x, self.y, self.radius, other.x1, other.y1, other.x2, other.y2).Length > 0;
 }
示例#11
0
 /// <summary>
 /// Check for a collision between a RayCollider and a RectCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, RectCollider other)
 {
     return Collision(other, self);
 }
示例#12
0
 /// <summary>
 /// Check for a collision between a RayCollider and a RayCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, RayCollider other)
 {
     return GeometryUtils.AreRaysIntersecting(
         self.x1, self.y1, self.x2, self.y2,
         other.x1, other.y1, other.x2, other.y2);
 }
示例#13
0
 /// <summary>
 /// Check for a collision between a RayCollider and a LineSegmentCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, LineSegmentCollider other)
 {
     return GeometryUtils.RayToSegmentPOI(
         self.x1, self.y1, self.x2, self.y1,
         other.x1, other.y1, other.x2, other.y2).HasValue;
 }
示例#14
0
 /// <summary>
 /// Check for a collision between a RayCollider and a ParticleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, ParticleCollider other)
 {
     return GeometryUtils.IsPointOnRay(other.x, other.y, self.x1, self.y1, self.x2, self.y2);
 }