コード例 #1
0
        //	Display final score after game end
        private void Tick_GameEnd(object source, EventArgs e)
        {
            //	Stop the one time timer
            if (!timerGameEnd.IsEnabled)
            {
                return;
            }

            timerGameEnd.Stop();

            //	Update the score
            ScoreRepository scoreRepository = new ScoreRepository();

            scoreRepository.AddScore(currentScore, playerID, gameMode);

            //	Delete previous saved game
            GameRepository gameRepository = new GameRepository();

            if (gameRepository.GetGame(playerID).Count > 0)
            {
                gameRepository.DeleteGame(playerID);
            }

            //	Display the score
            countdown.Text     = "FINAL SCORE:\n" + currentScore;
            countdown.FontSize = 200;
            countdown.Width    = screenWidth;
            Canvas.SetLeft(countdown, 0);
            Canvas.SetTop(countdown, screenHeight / 2 - countdown.ActualHeight / 2);

            //	Auto back after 5 seconds
            timerGameBack.Tick    += new EventHandler(Tick_GameBack);
            timerGameBack.Interval = TimeSpan.FromMilliseconds(3000);
            timerGameBack.Start();
        }