private void ButtonNext_Click(object sender, RoutedEventArgs e)
        {
            OnlineGame.SetGameSettings(new GameConfig(PlayerRole.Server, "", _gameSpeed));

            if (OnlineGame.Connect.Server.IsClientConnected)
            {
                // OnlineGame.GoToGameWindow(_placement, _shipArrangement, Owner);
                if (_placement != PlacementState.Manualy)
                {
                    OnlineGame.CreateGame(_shipArrangement);
                    PlayPage window = new PlayPage(OnlineGame);
                    WindowConfig.MainPage.NavigationService.Navigate(window, UriKind.Relative);
                }
                else
                {
                    PlacingPage window = new PlacingPage(OnlineGame);
                    WindowConfig.MainPage.NavigationService.Navigate(window, UriKind.Relative);
                }
                Close();
            }
            else
            {
                WaitingWindow window = new WaitingWindow(OnlineGame, _shipArrangement, _placement);
                window.Show();
                window.Wait();
                Close();
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Game game = FileSystem.LoadGame(((Button)sender).Content.ToString());

            if (game.GameConfig.IsOnline)
            {
                OnlineGame onlineGame = new OnlineGame(PlayerRole.Server, PlacementState.Loaded);
                onlineGame.Game       = game;
                WindowConfig.IsLoaded = true;
                WaitingWindow window = new WaitingWindow(onlineGame, null, PlacementState.Loaded);
                window.SetNavigationService(NavigationService);
                window.Show();
                window.Wait();
            }
            else
            {
                WindowConfig.game     = game;
                WindowConfig.IsLoaded = true;
                PlayPage playPage = new PlayPage(WindowConfig.game);
                NavigationService.Navigate(playPage, UriKind.Relative);
            }
        }