Esempio n. 1
0
        private void frmYamb_Shown(object sender, EventArgs e)
        {
            try
            {

                Serializer serializer = new Serializer();
                Highscore highscore = serializer.DeSerializeObject("db.dat");
                Highscore.GetInstance().Highscores = highscore.Highscores;
                Highscore.GetInstance().HighscoreTables = highscore.HighscoreTables;
            }
            catch (Exception)
            {
                MessageBox.Show("The application has no access to db.dat file or the file is corrupted!\nReinstall the program to a location where they are no administrator rights necessary.\neg.: C:\\");
                this.Close();
            }

            frmWelcomeScreen welcome = new frmWelcomeScreen();
            DialogResult res = welcome.ShowDialog();
            if (res == DialogResult.OK)
            {
                game = new Game(welcome.Player);
                lbl_player.Text = welcome.Player;
            }
            else
            {
                this.Close();
            }
        }
Esempio n. 2
0
        public void GameFinished()
        {
            bool newHighscoreInput = Highscore.GetInstance()
                                         .AddHighscore(game.Player, YambTable.GetInstance().GetTotalPoints(), 0);
            if (newHighscoreInput)
            {
                frmHighscoreDisplay displayHS = new frmHighscoreDisplay(Highscore.GetInstance().insertedRank);
                displayHS.ShowDialog();
                try
                {
                    Serializer serializer = new Serializer();
                    serializer.SerializeObject("db.dat", Highscore.GetInstance());
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        "The application has no access to db.dat file or the file is corrupted!\nReinstall the program to a location where they are no administrator rights necessary.\neg.: C:\\");
                    this.Close();
                }
            }

            frmEndGame endGameForm = new frmEndGame();
            bool newGame = endGameForm.ShowPoints(YambTable.GetInstance().GetTotalPoints());

            if (newGame)
            {
                StartNewGame();
            }
            else
            {
                this.Close();
            }
        }