private bool EndGame(bool showConfirmation) { if (showConfirmation && (_appContext.IsGameInPlay || _appContext.IsGameInPlay)) { var result = MessageDialog.Show( _isExiting ? "Confirm Exit" : "Confirm Quit", "Are you sure you want to " + (_isExiting ? "exit?" : "quit?"), MessageDialogButtons.YesNo); if (result != MessageDialogResult.Yes) { return(false); } } var gameController = Interlocked.CompareExchange(ref _gameController, null, null); if (gameController == null) { return(true); } gameController.Terminate(); // when current game is terminated, go back to main menu music _appContext.ThemeMusicLibrary.Clear(); _musicPlayer.SwitchMusic("DefaultMusic"); GameLog.Client.General.Info("Game was exited"); return(true); }
private void OnLoaded(object @object, RoutedEventArgs routedEventArgs) { Loaded -= OnLoaded; ClientSettings.Current.Saved += (s, e) => CheckFullScreenSettings(); ClientSettings.Current.Loaded += (s, e) => CheckFullScreenSettings(); _eventAggregator.GetEvent <ViewActivatingEvent>().Subscribe(OnViewActivating, ThreadOption.PublisherThread); _audioEngine.Volume = (float)ClientSettings.Current.MasterVolume; _musicPlayer.Volume = (float)ClientSettings.Current.MusicVolume; _soundPlayer.Volume = (float)ClientSettings.Current.FXVolume; ClientSettings.Current.MasterVolumeChanged += (s, e) => _audioEngine.Volume = (float)e.NewValue; ClientSettings.Current.MusicVolumeChanged += (s, e) => _musicPlayer.Volume = (float)e.NewValue; ClientSettings.Current.FXVolumeChanged += (s, e) => _soundPlayer.Volume = (float)e.NewValue; _audioEngine.Start(); _musicPlayer.PlayMode = PlaybackMode.Sequential | PlaybackMode.Fade; _musicPlayer.SwitchMusic("DefaultMusic"); _musicPlayer.Play(); }