private void ButtonNext_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         OnlineGame = new OnlineGame(PlayerRole.Client, _placement, ServerUtils.StringToIP(KeyTextBox.Text));
         Thread.Sleep(2000);
         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();
     }
     catch (IndexOutOfRangeException exception)
     {
         LogService.Trace($"Невозможно подключиться: {exception.Message}");
         MessageBox.Show("Вы ввели неправильный ключ. Повторите попытку", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     catch (Exception exception)
     {
         LogService.Trace($"Невозможно подключиться: {exception.Message}");
         MessageBox.Show($"Ошибка подключения к серверу", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            ShipArrangement arr = FileSystem.LoadArrangement(((Button)sender).Content.ToString());

            WindowConfig.game = new Game(arr, _arrangementClient, _gameConfig);
            if (WindowConfig.GameState == WindowConfig.State.Offline)
            {
                PlayPage playPage = new PlayPage(WindowConfig.game);
                WindowConfig.NavigationService.Navigate(playPage, UriKind.Relative);
            }
            else
            {
                _onlineGame.CreateGame(arr);
                PlayPage page = new PlayPage(_onlineGame);
                WindowConfig.NavigationService.Navigate(page, UriKind.Relative);
            }
            Close();
        }
Exemple #3
0
 public void Wait()
 {
     while (!OnlineGame.Connect.Server.IsClientConnected)
     {
     }
     if (Placement == PlacementState.Manualy)
     {
         PlacingPage window = new PlacingPage(OnlineGame);
         WindowConfig.MainPage.NavigationService.Navigate(window, UriKind.Relative);
     }
     else if (Placement == PlacementState.Loaded)
     {
         OnlineGame.LoadGame(OnlineGame.Game);
         PlayPage window = new PlayPage(OnlineGame);
         _nService.Navigate(window, UriKind.Relative);
     }
     else
     {
         OnlineGame.CreateGame(Arrangment);
         PlayPage window = new PlayPage(OnlineGame);
         WindowConfig.MainPage.NavigationService.Navigate(window, UriKind.Relative);
     }
     Close();
 }