/// <summary> /// Assagin all the values from the game that is currently active /// </summary> private void InitializePlayingGame() { AssaignImages(); imageP1.Source = iBeforeSelection; imageP2.Source = iBeforeSelection; textBlockWinner.Text = ""; var games = (from g in App.connection.Table<GameHistory>() select g).Last(); game = new GameHandler(games.NamePlayerOne, games.NamePlayerTwo, true); if (games.NamePlayerTwo == "Computer") { GridButtonsP1.Visibility = Visibility.Visible; GridButtonsP2.Visibility = Visibility.Collapsed; GridStartButtons.Visibility = Visibility.Collapsed; } else { vs = 1; GridButtonsP1.Visibility = Visibility.Visible; GridButtonsP2.Visibility = Visibility.Visible; GridStartButtons.Visibility = Visibility.Collapsed; } textBlockP1.Text = games.NamePlayerOne; textBlockP2.Text = games.NamePlayerTwo; textBlockPointsP1.Text = game.PointsP1.ToString(); textBlockPointsP2.Text = game.PointsP2.ToString(); }
/// <summary> /// User start the game /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_Start(object sender, RoutedEventArgs e) { if (vs == 0 && !String.IsNullOrEmpty(textBlockP1.Text)) { GridButtonsP1.Visibility = Visibility.Visible; GridStartButtons.Visibility = Visibility.Collapsed; game = new GameHandler(textBlockP1.Text, "Computer", false); } else if (vs == 1 && !String.IsNullOrEmpty(textBlockP1.Text) && !String.IsNullOrEmpty(textBlockP2.Text)) { GridButtonsP1.Visibility = Visibility.Visible; GridButtonsP2.Visibility = Visibility.Visible; GridStartButtons.Visibility = Visibility.Collapsed; game = new GameHandler(textBlockP1.Text, textBlockP2.Text, false); } else { var msg = new Windows.UI.Popups.MessageDialog("You must enter name(s) to play!", "Name(s) needed!"); msg.ShowAsync(); //Im aware of the async but in this case i dont need async and I think this do not affect the game. And I can´t find another way of using pop-up-message } }