Ejemplo n.º 1
0
 /// <summary>
 /// Swaps the content of the window.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 private void SwitchWindowContent(IMainWindowContentViewModel viewModel)
 {
     this.CurrentView  = viewModel;
     this.WindowWidth  = viewModel.WindowWidth;
     this.WindowHeight = viewModel.WindowHeight;
     viewModel.WindowContentSwitchRequested += this.WindowContentSwitchRequested;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Switches the content of the window.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        protected void SwitchWindowContent(IMainWindowContentViewModel viewModel)
        {
            if (viewModel.PreviousViewModel == null)
            {
                viewModel.PreviousViewModel = this;
            }

            this.OnWindowContentSwitchRequested(new WindowContentSwitchRequestedEventArgs(viewModel));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Opens the game.
        /// </summary>
        private async void OpenGame()
        {
            IMainWindowContentViewModel nextWindow = null;

            foreach (var window in this.WindowSelectionViewModel.SelectedWindows)
            {
                var mapWindow = this.SelectedMap.Windows.FirstOrDefault(w => w.Id == window.Id);
                if (mapWindow != null)
                {
                    mapWindow.IsOwnWindow = window.IsChecked;
                }
            }

            if (this.gameType == GameConfiguration.GameType.MultiPlayerGame)
            {
                var loadingScreenViewModel = new LoadingScreenViewModel(Resources.WaitingForOpponent, GameConfiguration.GameType.MultiPlayerGame, true);
                GameConsoleContext.Current.GameConsoleCallback.GameStarted += loadingScreenViewModel.StartGame;
                try
                {
                    loadingScreenViewModel.CurrentGameId = await GameConsoleContext.Current.GameConsoleServiceClient.OpenGameAsync(this.SelectedMap.Id, this.WindowSelectionViewModel.SelectedWindows.Select(x => x.Id), Settings.Default.PlayerName);
                }
                catch (ServerUnavailableException ex)
                {
                    this.HandleServerException(ex);
                }

                nextWindow = loadingScreenViewModel;
            }
            else
            {
                var game = new Game();
                if (this.gameType == GameConfiguration.GameType.SinglePlayerTraining)
                {
                    game.Init(Guid.NewGuid(), this.SelectedMap, null, true, true, GameConfiguration.GameType.SinglePlayerTraining);
                }
                else
                {
                    game.Init(Guid.NewGuid(), this.SelectedMap, "José (Computer)", true, true, GameConfiguration.GameType.SinglePlayerGame);
                }

                var gameStateViewModel = new GameStateViewModel(game);
                nextWindow = gameStateViewModel;

                GameManager.Current.StartGame(game, gameStateViewModel);
            }

            this.SwitchWindowContent(nextWindow);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowContentSwitchRequestedEventArgs"/> class.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 public WindowContentSwitchRequestedEventArgs(IMainWindowContentViewModel viewModel)
 {
     this.ViewModel = viewModel;
 }