コード例 #1
0
 //'Highscores' menu
 //Меню "Кращі гравці"
 private void highToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!gameStarted)
     {
         if (tetroMenu.Checked)
         {
             HighScores hs = new HighScores("tetro");
             hs.Show();
         }
         else
         {
             HighScores hs = new HighScores("pento");
             hs.Show();
         }
     }
 }
コード例 #2
0
 //Show highscores
 //Показ найкращих гравців
 private void ShowHighScores()
 {
     if (tetroMenu.Checked)
     {
         HighScores hs = new HighScores("tetro");
         var        selectedPlayers = from p in hs.highScoresList
                                      where p.gameType == "Tetromino"
                                      select p;
         foreach (Player p in selectedPlayers)
         {
             //Check if the player has a high score
             //Перевірка, чи гравець попаде у список найкращих
             if (score > p.score)
             {
                 EnterName enter = new EnterName();
                 if (enter.ShowDialog() == DialogResult.OK)
                 {
                     string name   = enter.playerName.Text;
                     Player player = new Player();
                     player.name     = name;
                     player.score    = score;
                     player.lines    = lines;
                     player.level    = level;
                     player.gameType = "Tetromino";
                     //Add player to high scores
                     //Додавання гравця до списку найкращих
                     hs.Add(player);
                     //Show highscores
                     //Показ інформації про кращих гравців
                     hs.Show();
                 }
                 break;
             }
         }
     }
     else
     {
         HighScores hs = new HighScores("pento");
         var        selectedPlayers = from p in hs.highScoresList
                                      where p.gameType == "Pentomino"
                                      select p;
         foreach (Player p in selectedPlayers)
         {
             if (score > p.score)
             {
                 EnterName enter = new EnterName();
                 if (enter.ShowDialog() == DialogResult.OK)
                 {
                     string name   = enter.playerName.Text;
                     Player player = new Player();
                     player.name     = name;
                     player.score    = score;
                     player.lines    = lines;
                     player.level    = level;
                     player.gameType = "Pentomino";
                     hs.Add(player);
                     hs.Show();
                 }
                 break;
             }
         }
     }
 }