Example #1
0
        private void changeUserButton_Click(object sender, EventArgs e)
        {
            ChangeUser   changeUserForm = new ChangeUser(users, uniqueID, false);
            DialogResult result         = changeUserForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                currentUser.defaultUser = false;

                changeUserForm.selectedUser.makeDefaultUser();
                currentUser = changeUserForm.selectedUser;

                changeToNewUser(currentUser);
                sortUsers();
                foreach (User u in users)
                {
                    SerializeUser(u);
                }
                usersCount = users.Count();
            }
            else
            {
                if (users[0].isDefault())
                {
                    changeToNewUser(users[0]);
                }
            }
        }
Example #2
0
        public void initializeGame()
        {
            ChoosePlayingStyle chooseForm = new ChoosePlayingStyle();
            DialogResult       style      = chooseForm.ShowDialog();

            if (style == DialogResult.OK)
            {
                // MessageBox.Show(this.Width + " " + this.Height);
                ChangeUser userForm = new ChangeUser(users, uniqueID, true);
                if (userForm.ShowDialog() == DialogResult.OK)
                {
                    initializeSecondPlayer(userForm.selectedUser);

                    foreach (User u in users)
                    {
                        SerializeUser(u);
                    }

                    from = new ChoosingCombinations(player1Name.Text, secondPlayerName.Text, false);

                    DialogResult result = from.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        game = new Game(from.player1Comb, from.player2Comb, player1Name.Text, secondPlayerName.Text, false);
                        game.setUsers(currentUser, userForm.selectedUser);
                        fullScreenButton.Visible = false;
                        quitButton.Visible       = false;
                        rankingsButton.Visible   = false;

                        setStartGame();
                        try
                        {
                            soundplayer = new SoundPlayer(@"C:\Users\User\Desktop\Proekt VP\VP-FruityMatch\FruityMatch\Resources\you-dont-know-me.wav");
                            soundplayer.Play();
                        }
                        catch (Exception e)
                        {
                            //  MessageBox.Show("no music for u");
                        }
                    }
                    else
                    {
                        terminateGame();
                    }
                }
            }
            else if (style == DialogResult.Yes)
            {
                User computerPlayer = new User("Grasshopper", -1);
                computerPlayer.changeAvatar(Properties.Resources.computer_avatar_still);
                from = new ChoosingCombinations(player1Name.Text, secondPlayerName.Text, true);
                DialogResult result = from.ShowDialog();
                if (result == DialogResult.OK)
                {
                    initializeSecondPlayer(computerPlayer);
                    game = new Game(from.player1Comb, from.player2Comb, player1Name.Text, secondPlayerName.Text, true);
                    game.setUsers(currentUser, computerPlayer);
                    fullScreenButton.Visible = false;
                    quitButton.Visible       = false;
                    rankingsButton.Visible   = false;
                    setStartGame();
                }
                else
                {
                    terminateGame();
                }
            }
        }