Esempio n. 1
0
        public static Shot WyliczWartoscPrzestrzeliny(PointF shotPoint, TargetDetails targetDet)
        {
            double wartosc = 0;
            Shot   sh      = new Shot();
            double pix     = Pix(targetDet.BlackR);



            Point  shotCenter = Point.Round(shotPoint);
            var    diffX      = shotCenter.X - targetDet.BlackCenter.X;
            var    diffY      = shotCenter.Y - targetDet.BlackCenter.Y;
            double odlegl     = Math.Sqrt(Math.Pow(diffX, 2) + Math.Pow(diffY, 2));

            sh.Length = odlegl * pix;

            double dziesietna  = (restRingWidth / pix) / 2; //dziesietna dla pierscieni 9 --
            double dziesietna1 = dziesietna / 10;

            double dziesietna10  = ((tenRingWidth + innerTen) / pix) / 2;// dziesietna dla 10
            double dziesietna11  = dziesietna10 / 10;
            double czteryiPolmmR = FourNHalfR(pix);
            double dl            = odlegl - czteryiPolmmR;

            //  Point strzalObliczonyOdSrodka = new Point(center.X + diffX, center.Y + diffY);

            Point strzalObliczonyOdSrodkaPix;

            if (targetDet.CameraFlipped)
            {
                strzalObliczonyOdSrodkaPix = new Point(-Convert.ToInt32(diffX * pix), -Convert.ToInt32(diffY * pix));
            }
            else
            {
                strzalObliczonyOdSrodkaPix = new Point(Convert.ToInt32(diffX * pix), Convert.ToInt32(diffY * pix));
            }

            sh.PointFromCenter = strzalObliczonyOdSrodkaPix;

            //sprawdzenie wartości strzału
            if (dl <= TenR(pix))
            {
                wartosc = CountdziesietneDycha(10, odlegl, czteryiPolmmR, TenR(pix), dziesietna11, InnerTenR(pix));
            }
            else if (dl <= NineR(pix))
            {
                wartosc = Countdziesietne(9, odlegl, czteryiPolmmR, NineR(pix), dziesietna1);
            }
            else if (dl <= EightR(pix))
            {
                wartosc = Countdziesietne(8, odlegl, czteryiPolmmR, EightR(pix), dziesietna1);
            }
            else if (dl <= SevenR(pix))
            {
                wartosc = Countdziesietne(7, odlegl, czteryiPolmmR, SevenR(pix), dziesietna1);
            }
            else if (dl <= SixR(pix))
            {
                wartosc = Countdziesietne(6, odlegl, czteryiPolmmR, SixR(pix), dziesietna1);
            }
            else if (dl <= FiveR(pix))
            {
                wartosc = Countdziesietne(5, odlegl, czteryiPolmmR, FiveR(pix), dziesietna1);
            }
            else if (dl <= FourR(pix))
            {
                wartosc = Countdziesietne(4, odlegl, czteryiPolmmR, FourR(pix), dziesietna1);
            }
            else if (dl <= ThreeR(pix))
            {
                wartosc = Countdziesietne(3, odlegl, czteryiPolmmR, ThreeR(pix), dziesietna1);
            }
            else if (dl <= TwoR(pix))
            {
                wartosc = Countdziesietne(2, odlegl, czteryiPolmmR, TwoR(pix), dziesietna1);
            }
            else if (dl <= OneR(pix))
            {
                wartosc = Countdziesietne(1, odlegl, czteryiPolmmR, OneR(pix), dziesietna1);
            }


            sh.Value = wartosc;
            sh.Time  = DateTime.Now.Ticks;
            return(sh);
        }
Esempio n. 2
0
 internal void Update(Shot newShot)
 {
     Value           = newShot.Value;
     Length          = newShot.Length;
     PointFromCenter = newShot.PointFromCenter;
 }