コード例 #1
0
        //After the game finishes, check if the player got a high score
        //Перевірка в кінці гри, чи попав гравець у таблицю рекордів
        void CheckScore()
        {
            HighScoresList hs = new HighScoresList(highScores);

            foreach (Player p in highScores.playersList)
            {
                if (player.Score > p.Score)
                {
                    EnterName dialog = new EnterName();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        string name = dialog.NameTextBox.Text;
                        Player plr  = new Player();
                        plr.Name  = name;
                        plr.Score = player.Score;

                        highScores.playersList.Remove(highScores.playersList.Min());
                        highScores.playersList.Add(plr);
                        highScores.playersList.Sort();
                        highScores.playersList.Reverse();
                        highScores.SerializeToXML();

                        hs.FillListView(highScores.playersList);
                        hs.ShowDialog();
                    }
                    break;
                }
            }
        }
コード例 #2
0
        private void highScoresToolStripMenu_Click(object sender, EventArgs e)
        {
            HighScoresList hs = new HighScoresList(highScores);

            hs.ShowDialog();
        }