示例#1
0
        // Display Score
        private void DisplayScore(object sender, EventArgs e)
        {
            // calculate the players score
            HighScore newHighScore = new HighScore() { QuestionsCorrect = _game.Score, TotalQuestions = _game.TotalQuestions, Date = DateTime.Now };

            // display the score grid
            HighScoreGridVisibility = Visibility.Visible;
            HighScoreText = String.Format(AppResources.HighScoreText, newHighScore.Percent);

            // load the high score table
            HighScoreTable hst = new HighScoreTable(_storageProvider);
            if (hst.IsNewHighScore(newHighScore) && !_scoreEntered)
            {
                HighScoreAnnounceText = AppResources.HighScoreAnnounceText;
                HighScoreNameVisibility = Visibility.Visible;
                HighScoreNameLabelVisibility = Visibility.Visible;
            }
        }
示例#2
0
        public void HighScoreContinueButtonPressed(object sender, EventArgs e)
        {
            // was this a high score?
            HighScore newHighScore = new HighScore() { QuestionsCorrect = _game.Score, TotalQuestions = _game.TotalQuestions, Date = DateTime.Now };
            HighScoreTable hst = new HighScoreTable(_storageProvider);
            if (hst.IsNewHighScore(newHighScore) && !_scoreEntered)
            {
                // enter in to the record books
                newHighScore.Name = HighScoreNameText;
                if (HighScoreNameText == "") newHighScore.Name = AppResources.AnonymousUser;
                hst.Add(newHighScore);
                _scoreEntered = true;

                // hack to allow us to reset the high score
                if (HighScoreNameText == AppResources.ResetPassword) hst.Reset();
            }

            // update the view model
            HighScoreGridVisibility = Visibility.Collapsed;

            // update the view model in case user hits back button from home screen
            HighScoreNameVisibility = Visibility.Collapsed;
            HighScoreNameLabelVisibility = Visibility.Collapsed;

            // signify that the game has well and truly ended
            this.GameEnded(this,new EventArgs());
        }