private void BackToGameSelector_Click(object sender, RoutedEventArgs e)
        {
            GameSelector gs = new GameSelector(players);

            this.Hide();
            gs.Show();
        }
        private void backButton_Click(object sender, RoutedEventArgs e)
        {
            GameSelector gs = new GameSelector(players);

            this.Visibility = Visibility.Hidden;
            gs.Show();
        }
Beispiel #3
0
        /// <summary>
        /// Use the text 'from the UI's textboxes to fill in the list of players
        /// </summary>
        public void StartButton_Click(object sender, RoutedEventArgs e)
        {
            string p1 = playerName1.Text;
            string p2 = playerName2.Text;
            string p3 = playerName3.Text;
            string p4 = playerName4.Text;

            string[] playernames = new string[] { p1, p2, p3, p4 };

            if (playernames.All(playername => isInvalidName(playername)))
            {
                Player pl1 = new Player(p1);
                Player pl2 = new Player(p2);
                Player pl3 = new Player(p3);
                Player pl4 = new Player(p4);

                this.players.Add(pl1);
                this.players.Add(pl2);
                this.players.Add(pl3);
                this.players.Add(pl4);

                //Show the players participating and go to the gameselector screen
                MessageBox.Show($"Spelers {playerName1.Text}, {playerName2.Text}, {playerName3.Text}, {playerName4.Text} gaan een spel starten, Veel plezier!");
                GameSelector gs = new GameSelector(players);
                this.Visibility = Visibility.Hidden;
                gs.Show();
            }
            else
            {
                MessageBox.Show("Niet alle namen bevatten alleen letters of nummers!");
            }
        }
        public override void EndGame()
        {
            //Close the game.
            //TO DO: check if game closes and gameselector starts up again
            active = false;
            System.Windows.Forms.Application.Exit();
            GameSelector gs = new GameSelector(players);

            gs.Show();
        }