Beispiel #1
0
        public static void CheckScore()
        {
            bool newHighScore = false;

            if (players.Count < 1)
            {
                HighScore highScore = new HighScore();
                highScore.Show();
                newHighScore = true;
            }

            foreach (Player p in players)
            {
                if (ThisScore >= p.Score)
                {
                    HighScore highScore = new HighScore();
                    highScore.Show();
                    newHighScore = true;

                    break;
                }
            }

            if (!newHighScore)
            {
                GameOverForm gameOver = new GameOverForm();
                gameOver.Show();
            }
        }
Beispiel #2
0
        private void submitBtn_Click(object sender, EventArgs e)
        {
            string name = nameText.Text; //get name input

            //write new score to file
            using (StreamWriter writer = File.AppendText(Global.highScoreFile))
            {
                writer.WriteLine($"{name}:{Global.ThisScore}");
            }

            //add player to players list
            Global.AddNewPlayer(new Player(name, Global.ThisScore));

            //create game over object and show form
            GameOverForm gameOver = new GameOverForm();

            gameOver.Show();
            this.Close();
        }