internal static void RunGame()
        {
            MyLogIn formInitializeGame = new MyLogIn();

            if (formInitializeGame.ShowDialog() == DialogResult.OK)
            {
                // if the initial parameters are not ok show a message
                if (formInitializeGame.FirstPlayerName.Length == 0 || (formInitializeGame.CheckBoxOfPlayer2IsChecked &&
                                                                       formInitializeGame.SecondPlayerName.Length == 0))
                {
                    if (MessageBox.Show(
                            "Invalid Parameters",
                            "Please enter Parameters Again",
                            MessageBoxButtons.RetryCancel,
                            MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        RunGame();
                    }
                }
                else
                {
                    CheckersForm formCheckersGame = new CheckersForm(formInitializeGame);
                    formCheckersGame.ShowDialog();
                }
            }
        }
示例#2
0
        public CheckersForm(MyLogIn i_MyLogIn)
        {
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.Text            = "Damka";
            User player1 = new User(
                i_MyLogIn.FirstPlayerName,
                eUserType.User,
                0,
                eTypeSign.O,
                eTypeSign.U,
                true);
            User player2 = new User(
                i_MyLogIn.SecondPlayerName == "[Computer]" ? "Computer"
                : i_MyLogIn.SecondPlayerName,
                i_MyLogIn.CheckBoxOfPlayer2IsChecked ? eUserType.User : eUserType.Computer,
                0,
                eTypeSign.X,
                eTypeSign.K,
                false);

            if (i_MyLogIn.RadioButtonBoardSize6X6IsChecked)
            {
                m_BoardSize = 6;
            }
            else if (i_MyLogIn.RadioButtonBoardSize8X8IsChecked)
            {
                m_BoardSize = 8;
            }
            else
            {
                m_BoardSize = 10;
            }

            m_CheckersBoardManagment                 = new BoardManagement(m_BoardSize, player1, player2);
            m_CheckersBoardManagment.IsGameOver     += GameOver;
            m_CheckersBoardManagment.IsBoardChanged += BoardChanged;
            m_Board = new Button[m_BoardSize, m_BoardSize];
            Size    = new Size((m_BoardSize * k_ButtonSize) + 100, (m_BoardSize * k_ButtonSize) + 100);
        }