Ejemplo n.º 1
0
        public GameBoard(string GameMode)
        {
            Instance = this;
            InitializeComponent();
            UstawTlo();
            InitializeVariables();
            //DrawGameBoardStart();
            DrawGameBoard2();
            //Test1
            Rysuj();

            keyEventHandler = new KeyEventHandler(Sterowanie2);
            Application.Current.MainWindow.KeyDown += keyEventHandler;


            actualGameMode = GameMode;

            if (GameMode == "   Ultra  ")
            {
                TrybGry.Text = "Pozostały czas: ";
            }
            if (GameMode == " LandSlide ")
            {
                TrybGry.Text = "Osuwisko za: ";
            }

            tetris         = new Tetrimo();
            następnyTetris = new Tetrimo();
            tetris.Stwórz();
            RysujNastepny(następnyTetris.getKształt());

            TimerStart();

            bazaWynikow = MainMenu.bazaWynikow;
            //bazaWynikow.InicjalizujBazeWynikow();

            // Uruchom();
        }
Ejemplo n.º 2
0
        private void Callback(object sender, EventArgs e)
        {
            Debug.WriteLine("tick");

            dropTime = (int)dropTimer.ElapsedMilliseconds;
            Debug.WriteLine(dropTime.ToString());

            if (dropTime > dropRate)
            {
                dropTime = 0;
                dropTimer.Restart();
                tetris.Opadaj();
            }

            if (czyOpadł)
            {
                if (tetris.CzyWystaje())
                {
                    czyGameOver = true;
                }

                else
                {
                    if (actualGameMode == "  Haunted  " && !isHaunted)
                    {
                        czyPokazywać = true;
                        isHaunted    = true;
                        timer.Restart();
                    }
                    Random rnd = new Random();

                    tetris         = następnyTetris;
                    następnyTetris = new Tetrimo();

                    aktualnyKolor = nastepnyKolor;
                    nastepnyKolor = rnd.Next(1, 7);

                    RysujNastepny(następnyTetris.getKształt());

                    if (!tetris.Stwórz())
                    {
                        czyGameOver = true;
                    }

                    czyOpadł = false;
                }

                if (czyGameOver == true)
                {
                    mainTimer.Stop();
                    czyZapauzowane = true;
                    GameOverPopUp dlg = new GameOverPopUp();
                    dlg.Owner = App.Current.MainWindow;

                    dlg.ShowDialog();
                    if (dlg.DialogResult == true) //wybrano przejscie do podsumowania
                    {
                        Podsumowanie();
                    }
                    else //wybrano opcje restartu
                    {
                        Restart();
                    }
                }
            }
            if (czyZapauzowane)
            {
                //Interface.PausePopUp();
            }
            switch (actualGameMode)
            {
            case "  Maraton ":

                if (poziom == 15)
                {
                    czyGameOver = true;
                }
                break;

            case "  Endless ":

                break;

            case "   Ultra  ":
                if (poziom < 5)
                {
                    poziom = 5;
                }
                playTime = (int)timer.ElapsedMilliseconds / 1000;
                //Console.SetCursorPosition(5, 4);
                // Console.Write("Pozotały czas: ");
                // Console.SetCursorPosition(21, 4);
                float czas = 180 - playTime;
                Czas.Text = czas.ToString();
                //  Console.Write("" + czas + " ");
                if (playTime > 180)
                {
                    czyGameOver = true;
                }

                break;

            case " LandSlide ":
                playTime = (int)timer.ElapsedMilliseconds / 1000;

                //Console.SetCursorPosition(5, 4);
                //Console.Write("Następny osuw za: ");
                //Console.SetCursorPosition(23, 4);

                float czas1 = 16 - playTime;
                Czas.Text = czas1.ToString();

                if (playTime > 15)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        Tetrimo.Landslide();
                    }
                    timer.Restart();
                }
                break;

            case "  Haunted  ":
                if (isHaunted)
                {
                    playTime = (int)timer.ElapsedMilliseconds;
                    if (playTime > 800)
                    {
                        isHaunted    = false;
                        czyPokazywać = false;
                    }
                }
                break;
            }
            WyczyscLinie();
        }