Пример #1
0
 public int KolizjaBudynek(Statek s)
 {
     for (int j = 0; j < b.Count; j++)
     {
         if (s.h <= b[j].h)
         {
             for (int a = 0; a < s.tr.Count; a++)
             {
                 if (s.tr[a].x == b[j].x && s.tr[a].y == b[j].y)
                 {
                     s.stanLotu = "Koliz";
                     return(0);
                 }
             }
         }
     }
     return(0);
 }
Пример #2
0
 public int NiebezpieczneZblizenieBudynek(Statek s)
 {
     for (int j = 0; j < b.Count; j++)
     {
         if (s.h <= b[j].h)
         {
             for (int a = 0; a < s.tr.Count; a++)
             {
                 if (s.tr[a].x - b[j].x <2 && s.tr[a].x - b[j].x> -2 && s.tr[a].y - b[j].y <2 && s.tr[a].y - b[j].y> -2)
                 {
                     s.stanLotu = "Zbliz";
                     return(0);
                 }
             }
         }
     }
     return(0);
 }
Пример #3
0
        public void ustalTrajektorie(int x_cel, int y_cel, int direct)
        {
            tr = new List <Trasa>();
            tr.Add(new Trasa(x, y, h, d, v));
            double bok = v * v * 0.00000670162031; // dlugosc boku osmiokata

            if (x_cel != x || y_cel != y)          // znajdz trase do podanego celu
            {
                Statek[] s = new Statek[4];        // tworzy trzon tr s[0], bok okregu s[1], prosta s[2], prostopadla s[3]

                int      git    = 0;
                double[] dl_bok = new double[8];
                for (int jj = 0; jj < 8; jj++)             // dlugosci odpowiednich bokow
                {
                    if (d % 4 == 0)
                    {
                        dl_bok[jj] = Math.Round(bok * 2);                     // poziom
                    }
                    else if (d % 4 == 2)
                    {
                        dl_bok[jj] = Math.Round(bok * 1);                     // pion
                    }
                    else if (d % 2 == 1)
                    {
                        dl_bok[jj] = Math.Round(bok * 0.71);                  // skos
                    }
                }
                int xd = -1, x1, y1;

                s[0]   = new Statek(x, y, h, d, v);
                s[0].d = d;
                s[0].tr.Add(new Trasa(x, y, h, d, v));    // trzon trajektorii s[0]

                int ile = 0;
                while (ile < 8 && git < 1)
                {
                    int dd = s[0].d;    // ostatni kierunek na trzonie s[0]

                    s[1] = new Statek(x, y, h, d, v);
                    s[1].tr.Add(new Trasa(x, y, h, dd, v));             // bok okregu s[1]

                    for (int ii = 0; ii < dl_bok[d] - 1; ii++)          // dodaje do trajektorii bok
                    {
                        plusTrajektorie(ref s[1].tr, s[1].d);
                    }

                    x1 = s[1].tr[s[1].tr.Count - 1].x;                  // ostatni x s[1]
                    y1 = s[1].tr[s[1].tr.Count - 1].y;                  // ostatni y s[1]

                    s[2] = new Statek(x1, y1, h, d, v);
                    s[2].tr.Add(new Trasa(x1, y1, h, dd, v));                                                  // tworzy prosta s[2]
                    int i2 = 0, i3 = 0;
                    while (s[2].tr[i2].x < 96 && s[2].tr[i2].y < 32 && s[2].tr[i2].x > 0 && s[2].tr[i2].y > 0) // tworzy trajektorie s3
                    {
                        plusTrajektorie(ref s[2].tr, s[2].tr[i2].d);                                           // buduje prosta s[2]
                        i2   = s[2].tr.Count - 1;
                        i3   = 0;
                        s[3] = new Statek(s[2].tr[i2].x, s[2].tr[i2].y, h, d, v);
                        s[3].tr.Add(new Trasa(s[2].x, s[2].y, h, dd, v));     // tworzy prosta s[3]
                        while (s[3].tr[i3].x < 96 && s[3].tr[i3].y < 32 && s[3].tr[i3].x > 0 && s[3].tr[i3].y > 0)
                        {
                            plusTrajektorie(ref s[3].tr, s[3].tr[i3].d);     // buduje prosta s[3]
                            i3 = s[3].tr.Count - 1;
                            if (s[3].tr[i3].x == x_cel && s[3].tr[i3].y == y_cel)
                            {
                                git = 1;
                            }
                            if (git == 1)
                            {
                                break;
                            }
                        }
                        if (git == 1)
                        {
                            break;
                        }
                    }
                    if (git == 0)
                    {
                        s[0].d = (s[1].d + xd + 8) % 8;
                    }
                    s[0].tr.AddRange(s[1].tr);
                }

                if (git == 1)
                {
                    tr.AddRange(s[0].tr);             // dodanie tajektorii s[0] do trajektorii samolotu
                }
            }

            int i = tr.Count - 1;

            while (tr[i].x < 96 && tr[i].y < 32 && tr[i].x > 0 && tr[i].y > 0) // kontynuluj lot prosto
            {
                plusTrajektorie(ref tr, tr[i].d);                              // dodaje nastepna kratke
                i = tr.Count - 1;
            }
        }
Пример #4
0
        public void ustalTrajektorie(int x_cel, int y_cel, int direct, int skala)
        {
            tr = new List <Trasa>();
            //plusTrajektorie(ref tr, d);
            double bok = v * v * 0.00000670162031 * skala; // dlugosc boku osmiokata

            if (x_cel != x || y_cel != y)                  // znajdz trase do podanego celu
            {
                Statek[] s      = new Statek[5];           // tworzy trzon tr s[0], bok okregu s[1], prosta s[2], prostopadla s[3]
                Baza     b      = new Baza();
                int      git    = 0;
                double[] dl_bok = new double[8];
                for (int jj = 0; jj < 8; jj++)             // dlugosci odpowiednich bokow
                {
                    if (jj % 4 == 0)
                    {
                        dl_bok[jj] = Math.Round(bok * 2);                      // poziom
                    }
                    else if (jj % 4 == 2)
                    {
                        dl_bok[jj] = Math.Round(bok * 1);                      // pion
                    }
                    else if (jj % 2 == 1)
                    {
                        dl_bok[jj] = Math.Round(bok * 0.71);                   // skos
                    }
                }
                int xd = -1, x1, y1, x0, y0;

                s[0]   = new Statek(x, y, h, d, v);
                s[0].d = d;
                s[0].tr.Add(new Trasa(x, y, h, d, v));        // trzon trajektorii s[0]

                s[4]   = new Statek(x, y, h, (d + 4) % 8, v); // prosta linia - trasa za samolotem s[4]
                s[4].d = (d + 4) % 8;
                s[4].tr.Add(new Trasa(x, y, h, (d + 4) % 8, v));

                int i4 = 0;
                while (s[4].tr[i4].x <120 && s[4].tr[i4].y <44 && s[4].tr[i4].x> -24 && s[4].tr[i4].y> -12) // wyznacz linie za samolotem
                {
                    plusTrajektorie(ref s[4].tr, s[4].tr[i4].d);                                            // dodaje nastepna kratke
                    i4 = s[4].tr.Count - 1;
                }

                int ile = 0;
                while (ile < 8 && git < 1) // szuka mozliwosci poki co w lewo
                {
                    int dd = s[0].d;       // ostatni kierunek na trzonie s[0]
                    x0 = s[0].tr[s[0].tr.Count - 1].x;
                    y0 = s[0].tr[s[0].tr.Count - 1].y;

                    s[1] = new Statek(x0, y0, h, dd, v);
                    s[1].tr.Add(new Trasa(x0, y0, h, dd, v));           // bok okregu s[1]

                    for (int ii = 0; ii < dl_bok[dd] - 1; ii++)         // dodaje do trajektorii bok
                    {
                        plusTrajektorie(ref s[1].tr, s[1].d);
                    }

                    x1 = s[1].tr[s[1].tr.Count - 1].x;                  // ostatni x s[1]
                    y1 = s[1].tr[s[1].tr.Count - 1].y;                  // ostatni y s[1]

                    s[2] = new Statek(x1, y1, h, dd, v);
                    s[2].tr.Add(new Trasa(x1, y1, h, dd, v));                                                  // tworzy prosta s[2]
                    int i2 = 0, i3 = 0;
                    while (s[2].tr[i2].x < 96 && s[2].tr[i2].y < 32 && s[2].tr[i2].x > 0 && s[2].tr[i2].y > 0) // tworzy trajektorie s[2]
                    {
                        plusTrajektorie(ref s[2].tr, s[2].tr[i2].d);                                           // buduje prosta s[2]
                        i2   = s[2].tr.Count - 1;
                        i3   = 0;
                        s[3] = new Statek(s[2].tr[i2].x, s[2].tr[i2].y, h, d, v);
                        s[3].tr.Add(new Trasa(s[2].tr[i2].x, s[2].tr[i2].y, h, (8 + dd + xd) % 8, v));             // tworzy prosta s[3]
                        while (s[3].tr[i3].x < 96 && s[3].tr[i3].y < 32 && s[3].tr[i3].x > 0 && s[3].tr[i3].y > 0) //tworzy tr s[3]
                        {
                            plusTrajektorie(ref s[3].tr, s[3].tr[i3].d);                                           // buduje prosta s[3]
                            i3 = s[3].tr.Count - 1;
                            if (s[3].tr[i3].x == x_cel && s[3].tr[i3].y == y_cel)
                            {
                                git = 1;
                                s[2].tr.RemoveAt(s[2].tr.Count - 1);
                                s[2].tr.AddRange(s[3].tr);
                                s[1].tr.AddRange(s[2].tr);
                            }
                            if (git == 1)
                            {
                                break;
                            }
                        }
                        if (git == 1)
                        {
                            break;
                        }
                    }
                    if (git == 0)
                    {
                        s[0].d = (s[1].d + xd + 8) % 8;
                    }
                    s[1].tr.RemoveAt(0);
                    s[0].tr.AddRange(s[1].tr);
                    ile++;
                }

                if (git == 1)
                {
                    tr.AddRange(s[0].tr);             // dodanie tajektorii s[0] do trajektorii samolotu
                }
                else
                {
                    tr.Add(new Trasa(x, y, h, d, v));
                }
            }
            else
            {
                tr.Add(new Trasa(x, y, h, d, v));
            }
            int i = tr.Count - 1;

            while (tr[i].x <120 && tr[i].y <44 && tr[i].x> -24 && tr[i].y> -12) // kontynuluj lot prosto
            {
                plusTrajektorie(ref tr, tr[i].d);                               // dodaje nastepna kratke
                i = tr.Count - 1;
            }
        }