// Execute button functions private void HandPointerPressReleaseEvent(object sender, HandPointerEventArgs e) { if (capturedHandPointer == e.HandPointer) { if (e.HandPointer.GetIsOver(buttonLoad)) { // Delete game GameRepository gameRepository = new GameRepository(); gameRepository.DeleteGame(playerID); // Load a new game GameMode gameMode = new GameMode(kinectSensorChooser, playerID); Close(); gameMode.ShowDialog(); VisualStateManager.GoToState(buttonLoad, "MouseOver", true); } else if (e.HandPointer.GetIsOver(buttonBack)) { Close(); VisualStateManager.GoToState(buttonBack, "MouseOver", true); } else { VisualStateManager.GoToState(buttonLoad, "Normal", true); VisualStateManager.GoToState(buttonBack, "Normal", true); } e.HandPointer.Capture(null); e.Handled = true; } }
// 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(); }
private void playGame(object sender, RoutedEventArgs e) { // Delete game GameRepository gameRepository = new GameRepository(); gameRepository.DeleteGame(playerID); // Load a new game GameMode gameMode = new GameMode(kinectSensorChooser, playerID); Close(); gameMode.ShowDialog(); }