Esempio n. 1
0
 //Ending game process
 //Процедура завершення гри
 private void GameOver()
 {
     gameStarted = false;
     gamePaused  = false;
     DropTimer.Stop();
     DropTimer.Enabled = false;
     //Using delegates because of thread concurrency error (StackOverflow)
     //Через помилку "Конфлікт потоків", використовуємо делегатів (StackOverflow)
     HelpText.Invoke((MethodInvoker)(() =>
     {
         HelpText.Text = "GAME OVER";
     }));
     //Clear the game screen
     //очистка ігрового вікна
     MakeGlass();
     //Clear 'next figure' screen
     //очистка вікна наступної фігури
     MakeNextGlass();
     HelpText.Invoke((MethodInvoker)(() =>
     {
         ShowHighScores();
     }));
     score = 0;
     lines = 0;
     level = 0;
     DisplayInfoText();
     SpeedIndicator.Invoke((MethodInvoker)(() =>
     {
         SpeedIndicator.Text = "0";
     }));
     //Redraw game screen
     //оновлення вікна програми
     ReDraw();
 }
Esempio n. 2
0
 //Show game information: score, cleared lines, level
 //Delegates are used to avoid thread concurrency error (StackOverflow)
 //Показ тексту про стан гри: рахунок, очищено ліній, рівень
 //Використані делегати, т.к. інакше виникає помилка про конфлікт потоків (StackOverflow)
 private void DisplayInfoText()
 {
     ScoreIndicator.Invoke((MethodInvoker)(() =>
     {
         ScoreIndicator.Text = score.ToString();
     }));
     LinesIndicator.Invoke((MethodInvoker)(() =>
     {
         LinesIndicator.Text = lines.ToString();
     }));
     LevelIndicator.Invoke((MethodInvoker)(() =>
     {
         LevelIndicator.Text = level.ToString();
     }));
     SpeedIndicator.Invoke((MethodInvoker)(() =>
     {
         SpeedIndicator.Text = (startingSpeed - DropTimer.Interval).ToString();
     }));
     if (gameStarted)
     {
         HelpText.Invoke((MethodInvoker)(() =>
         {
             HelpText.Text = helpText;
         }));
     }
 }