示例#1
0
        public override bool Intersects(AHitBox hb)
        {
            if (hb.GetHitBoxType() == HitBoxType.RECTANGLE)
            {
                RectHitBox tmp = (RectHitBox)hb;
                if (tmp._rect.Intersects(_rect))
                {
                    return true;
                }
            }
            else if (hb.GetHitBoxType() == HitBoxType.CIRCLE)
            {
                CircleHitBox tmp = (CircleHitBox)hb;

                Vector2[] points = new Vector2[4] {
                    new Vector2(X, Y),
                    new Vector2(X + Width, Y),
                    new Vector2(X + Width, Y + Height),
                    new Vector2(X, Y + Height)
                };

                foreach (Vector2 pt in points)
                {
                    if (DistanceABNoSqrt(tmp.X, tmp.Y, pt.X, pt.Y) <= tmp.Radius * tmp.Radius)
                        return true;
                }

            }
            return false;
        }
示例#2
0
 public override bool Intersects(AHitBox hb)
 {
     if (hb.GetHitBoxType() == HitBoxType.RECTANGLE)
     {
         RectHitBox tmp = (RectHitBox)hb;
         return tmp.Intersects(this);
     }
     else if (hb.GetHitBoxType() == HitBoxType.CIRCLE)
     {
         CircleHitBox tmp = (CircleHitBox)hb;
         return (DistanceABNoSqrt(X, Y, tmp.X, tmp.Y) <= (Radius + tmp.Radius) * (Radius + tmp.Radius));
     }
     return false;
 }