Ejemplo n.º 1
0
        private void GameOver()
        {
            player.Stop();
            //I check if the timer is enabled because I don't want the program to run the code twice which can happen if the timer interval is small enough

            if (Timer.Enabled)
            {
                Timer.Enabled = false;

                HighScores highScores;
                LoadHighScores(out highScores);

                //I test for 10 because it means that it is not a new highscore
                if (highScores.CheckForNewHighScore(Shapes.score) == 10)
                {
                    GameOver gameOver = new GameOver();
                    Hide();
                    gameOver.Show();
                }
                else if (highScores.CheckForNewHighScore(Shapes.score) <= 4)
                {
                    NewHighScore newHighScore = new NewHighScore();
                    Hide();
                    newHighScore.Show();
                }
                else
                {
                    MessageBox.Show("CheckForNewHighScore error");
                }
            }
        }
Ejemplo n.º 2
0
        private void GameOver()
        {
            player.Stop();
            if (Timer.Enabled)
            {
                Timer.Enabled = false;

                HighScores highScores;
                LoadHighScores(out highScores);

                //Jag testar för 10 för det betyder att scoret inte är större än något highscore
                if (highScores.CheckForNewHighScore(Shapes.score) == 10)
                {
                    GameOver gameOver = new GameOver();
                    Hide();
                    gameOver.Show();
                }
                else if (highScores.CheckForNewHighScore(Shapes.score) <= 4)
                {
                    NewHighScore newHighScore = new NewHighScore();
                    Hide();
                    newHighScore.Show();
                }
                else
                {
                    MessageBox.Show("CheckForNewHighScore error");
                }
            }
        }
Ejemplo n.º 3
0
 private void StartAnimation()
 {
     smallBoard.Isvalymas();
     GeneruotiDetales();
     d            = BusimaDetale;
     BusimaDetale = RandomDetale();
     foreach (var koord in d.LangeliuKoord)
     {
         myBoard.NuspalvintLangeli(Convert.ToInt32(koord.X), Convert.ToInt32(koord.Y), d.Spalva);
     }
     foreach (var koord in BusimaDetale.LangeliuKoord)
     {
         smallBoard.NuspalvintLangeliSmall(Convert.ToInt32(koord.X), Convert.ToInt32(koord.Y), BusimaDetale.Spalva);
     }
     if (!d.ArLieciaDetalesApacia(myBoard.UzimtiLangeliai)) // tikrinam, ar tik atsiradus detalei ji nera ant kitos detales
     {
         t          = new DispatcherTimer();
         t.Tick    += t_Tick;
         t.Interval = new TimeSpan(0, 0, 0, 0, 250);
         t.Start();
     }
     else
     {
         t.Stop();
         arGameOver = true;
         GameOver GameOver = new GameOver(Menu, Taskai, this);
         GameOver.Show();
     }
 }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            HighScores highScores;
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("HighScores.hs", FileMode.Open, FileAccess.Read);

            highScores = (HighScores)formatter.Deserialize(stream);
            stream.Dispose();
            Stream saveStream = new FileStream("HighScores.hs", FileMode.OpenOrCreate, FileAccess.ReadWrite);

            highScores.ChangeHighScore(highScores.CheckForNewHighScore(Shapes.score), tbxName.Text, Shapes.score);
            formatter.Serialize(saveStream, highScores);
            saveStream.Dispose();

            GameOver gameOver = new GameOver();

            Hide();
            gameOver.Show();
        }