Пример #1
0
        // Enters the players name and score to the leaderboard
        private void EnterButton_Click(object sender, EventArgs e)
        {
            // Gets user input name
            string name = nameTextBox.Text;

            // No whitespace in name
            name = name.Replace(" ", "");

            // If player does not enter a name, they are Unknown
            if (name == "")
            {
                name = "Unknown";
            }

            // Names limited to 10 characters
            if (name.Length > 10)
            {
                name = name.Substring(0, 10);
            }

            // Create the new High Score and add it to the leaderboard
            newhs = new HighScore(name, score);
            HighScores hs = new HighScores();

            hs.AddNewHs(newhs);

            // Write the scores to the file and update the splash screen
            hs.Write();
            splash.UpdateHS();
            Close();
        }