Example #1
0
        private void GameEnd(object obj, EventArgs args)
        {
            double newScore  = this.model.Score;
            double highscore = logic.GetHighScore();

            tickTimer.Stop();
            GameOverViewModel vm = new GameOverViewModel()
            {
                NewScore = (int)(newScore > highscore ? newScore : highscore),
                Message  = newScore > highscore ? "New Highscore!" : "Nice, but the highscore is",
            };
            GameOverWindow gameOver = new GameOverWindow(vm);

            if (gameOver.ShowDialog() == true)
            {
                this.GameEnded?.Invoke(this, EventArgs.Empty);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GameOverWindow"/> class.
 /// </summary>
 /// <param name="vm">Requires a ViewModel which will be set as DataContext for this window.
 /// The ViewModel's properties will be read one time.</param>
 public GameOverWindow(GameOverViewModel vm)
     : this()
 {
     this.DataContext = vm;
 }