Пример #1
0
        public void pokaSamolot(ref Trasa pozycja)
        {
            int tmp = 3;

            string[] samolot = System.IO.File.ReadAllLines("samolot.txt");
            for (int i = 1; i < 22; i++)
            {
                insert(1, i, wierza[i - 1]);
            }
            if (pozycja.x < 116)    // przesuwanie sie w prawo
            {
                if (pozycja.x == 1)
                {
                    tmp = 0;
                }

                insert(pozycja.x, pozycja.y + 1, samolot[0 + tmp]);
                insert(pozycja.x + 1, pozycja.y + 2, samolot[1 + tmp]);
                insert(pozycja.x + 7, pozycja.y + 3, samolot[2 + tmp]);

                if (pozycja.y < 4)
                {
                    pozycja.y++;
                }
                pozycja.x += pozycja.v / 16;                                 // predkosc opadania (mniej-dluzej)
                if (pozycja.v > 35)
                {
                    pozycja.v = pozycja.v * 9 / 10;                        // hamowanie (mniej-szybsze)
                }
                insert(6, 3, "|    ||");
                insert(6, 4, "|    ||");
                insert(6, 5, "|    ||");
            }
            else if (pozycja.y < 22)   // przesuwanie w dol
            {
                pozycja.y++;
                pozycja.x++;

                if (pozycja.y < 7)
                {
                    pozycja.y--;
                    pozycja.x += 4;
                    insert(pozycja.x + 1, pozycja.y + 0, samolot[6]);
                    insert(pozycja.x + 0, pozycja.y + 1, samolot[7]);
                    insert(pozycja.x + 3, pozycja.y + 2, samolot[8]);
                    insert(pozycja.x + 0, pozycja.y + 3, samolot[9]);
                    insert(pozycja.x + 0, pozycja.y + 4, samolot[10]);
                    insert(pozycja.x + 6, pozycja.y + 5, samolot[11]);
                    pozycja.y++;
                }
                else
                {
                    insert(pozycja.x + 4, pozycja.y + 0, samolot[12]);
                    insert(pozycja.x + 6, pozycja.y + 1, samolot[13]);
                    insert(pozycja.x + 0, pozycja.y + 2, samolot[14]);
                    insert(pozycja.x + 1, pozycja.y + 3, samolot[15]);
                    insert(pozycja.x + 8, pozycja.y + 4, samolot[16]);
                    insert(pozycja.x + 9, pozycja.y + 5, samolot[17]);
                }
                for (int i = 22; i < 28; i++)
                {
                    insert(1, i, wierza[i - 1]);
                }
            }
            else
            {
                pozycja.v = 0;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(213, 52);
            Console.SetBufferSize(213, 52);
            Console.Title = "Kontrola Lotow";

            Radar radar         = new Radar();
            Baza  b             = new Baza(radar);
            Trasa losowySamolot = new Trasa(0, 0, 0, 0, 0);

            b.pokaInterfejs();
            int ms   = 0;
            int lot  = -1;
            int time = 100;

            int[] x = new int[1];
            x[0] = 0;
            for (; ;)
            {
                if (radar.run < 0)
                {
                    b.pokaInterfejs();
                }
                else
                {
                    radar.pokaRadar();                               // aktualizuje i wyswietla radar
                }
                b.pokaListeLotow(radar, x[0]);                       // wypisuje liste lotow do podgledu/edycji
                b.insert(200, 26, Convert.ToString(ms / 10 + " s")); // wypisuje czas trwania programu
                b.insert(212, 51, Convert.ToString("."));            // wypisuje nic na koncu okna
                b.pokaLot(radar, lot);

                if (Console.KeyAvailable)                           // pobiera wybrany przycisk
                {
                    char wybor = Console.ReadKey().KeyChar;
                    if (lot >= 0)
                    {
                        switch (wybor)
                        {
                        case '0': b.czyscKonsole(); lot = -1; break;

                        case '1': if (radar.s[lot].trajektoria < 1)
                            {
                                radar.s[lot].trajektoria++;
                            }
                            else
                            {
                                radar.s[lot].trajektoria--;
                            } break;

                        case '2': radar.s[lot].zmienTrajektorie(); break;
                        }
                    }                                          // zarzadzanie lotem
                    else if (wybor - 49 >= 0 && wybor - 49 < 10 && wybor - 49 <= radar.s.Count)
                    {
                        lot = wybor - 49;
                    }   // wypisuje info o danym locie
                    else if (wybor == 'q')
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                    }   // zabija aplikacje
                    else if (wybor == 'e')
                    {
                    }   // info o wlascicielach
                    else if (wybor == 'w')
                    {
                        losowySamolot = new Trasa(1, 2, 0, 0, 200);
                    }   // pusc samolot
                    else if (wybor == 'r')
                    {
                        radar.run *= -1;
                    }   // wlaczy/wylacz radar
                    else if (wybor == ']')
                    {
                        if (time > 15)
                        {
                            time -= 15;
                        }
                    }   // przyspiesz czas
                    else if (wybor == '[')
                    {
                        time += 15;
                    }   // przyspiesz czas
                }
                Thread.Sleep(time);
                ms++;
                if (losowySamolot.v != 0)
                {
                    b.pokaSamolot(ref losowySamolot);                       // ladujacy samolot
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(213, 52);
            Console.SetBufferSize(213, 52);
            Console.Title = "Kontrola Lotow";

            Radar radar         = new Radar();
            Baza  b             = new Baza(radar);
            Trasa losowySamolot = new Trasa(0, 0, 0, 0, 0);

            b.pokaInterfejs();
            int ms    = 0;
            int lot   = -1;
            int time  = 100;
            int gener = 0;

            for (; ;)
            {
                if (radar.run < 0)
                {
                    b.pokaInterfejs();
                }
                else
                {
                    radar.pokaRadar(ref lot);                           // aktualizuje i wyswietla radar
                    b.pokaListeLotow(radar, lot);                       // wypisuje liste lotow do podgledu/edycji
                    if (radar.skala > 1)
                    {
                        radar.naniesBudynki();                          // nanosi budynki na mape
                    }
                }
                radar.umieranie();
                if (gener == 1)
                {
                    radar.Losowanko();                                  // generuje samoloty na mapie przez losowanie
                }
                if (lot >= 0)
                {
                    b.pokaLot(radar, lot);                              // wyswietla informacje o locie
                }
                else
                {
                    b.pokaKonsole(radar.skala, gener);                  // czysci konsole
                }
                b.insert(200, 26, Convert.ToString(ms / 10 + " s"));    // wypisuje czas trwania programu
                b.insert(212, 51, Convert.ToString("."));               // wypisuje nic na koncu okna

                if (Console.KeyAvailable)                               // pobiera wybrany przycisk
                {
                    char wybor = Console.ReadKey().KeyChar;
                    if (lot >= 0)
                    {
                        switch (wybor)
                        {
                        case '0': b.czyscKonsole(); lot = -1; break;

                        case '1': if (radar.s[lot].trajektoria < 1)
                            {
                                radar.s[lot].trajektoria++;
                            }
                            else
                            {
                                radar.s[lot].trajektoria--;
                            } break;

                        case '2': radar.s[lot].zmienTrajektorie(radar.skala); break;
                        }                                        // zarzadzanie lotem
                    }
                    else if (wybor - 49 >= 0 && wybor - 49 < 10 && wybor - 49 <= radar.s.Count && radar.run > 0)
                    {
                        b.czyscKonsole();
                        lot = wybor - 49;
                        if (radar.s.Count < lot + 1)
                        {
                            lot = -1;
                        }
                    }   // wypisuje info o danym locie
                    else
                    {
                        switch (wybor)
                        {
                        case 'q': System.Diagnostics.Process.GetCurrentProcess().Kill(); break;         // zabija aplikacje

                        case 'e': b.pokaFax(); break;                                                   // info o wlascicielach

                        case 'w': losowySamolot = new Trasa(1, 2, 0, 0, 200); break;                    // pusc samolot

                        case 'r': radar.run *= -1; radar.pokaSkale(); break;                            // wlaczy/wylacz radar

                        case '.': if (time > 15)
                            {
                                time -= 15;
                            }
                            break;                                                                      // przyspiesz czas

                        case ',': time += 15; break;                                                    // spowolnij czas

                        case '/': time = 100; break;                                                    // ustaw domyslny czas

                        case 'm': radar.zmienMape(radar.run); break;                                    // zmienia mape

                        case 'g': if (gener == 0)
                            {
                                gener = 1;
                            }
                            else
                            {
                                gener = 0;
                            } break;                                                                    // generuje lot

                        case 'b': if (radar.skala > 1)
                            {
                                b.pokaListeBudynkow(radar);
                            }
                            break;                                                                      // generuje lot

                        case 's': b.zapis(radar); break;                                                // zapis do pliku

                        case 'k': radar.Kolizja(); break;                                               // kurs kolizyjny

                        case 'n': radar.NiebezpieczneZblizenia(); break;                                // niebezpieczne zblizenie

                        case 'x': radar.zderzonko(); break;

                        case 'c': radar.trajektorki(); break;
                        }
                    }
                }
                Thread.Sleep(time);
                ms++;
                if (losowySamolot.v != 0)
                {
                    b.pokaSamolot(ref losowySamolot);                       // ladujacy samolot
                }
            }
        }