예제 #1
0
        public static void RunGame()
        {
            FormInitializeGame formInitializeGame = new FormInitializeGame();

            if (formInitializeGame.ShowDialog() == DialogResult.OK)
            {
                if (formInitializeGame.FirstPlayerName.Length == 0 || (formInitializeGame.CheckBoxOfPlayer2IsChecked &&
                                                                       formInitializeGame.SecondPlayerName.Length == 0))
                {
                    if (MessageBox.Show(
                            "Invalid input",
                            "Please re-enter the name",
                            MessageBoxButtons.RetryCancel,
                            MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        RunGame();
                    }
                }
                else
                {
                    FormCheckersGame formCheckersGame = new FormCheckersGame(formInitializeGame);
                    formCheckersGame.ShowDialog();
                }
            }
        }
예제 #2
0
        public FormCheckersGame(FormInitializeGame i_FormInitializeGame)
        {
            this.Text            = "Checkers - Guy & David ";
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.StartPosition   = FormStartPosition.CenterScreen;
            Player player1 = new Player(
                i_FormInitializeGame.FirstPlayerName,
                ePlayerType.Human,
                0,
                eSquareType.Player1RegularPiece,
                eSquareType.Player1King,
                true);
            Player player2 = new Player(
                i_FormInitializeGame.SecondPlayerName == "[Computer]" ? "Computer"
                : i_FormInitializeGame.SecondPlayerName,
                i_FormInitializeGame.CheckBoxOfPlayer2IsChecked ? ePlayerType.Human : ePlayerType.Computer,
                0,
                eSquareType.Player2RegularPiece,
                eSquareType.Player2King,
                false);

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

            m_CheckersData = new CheckersData(m_BoardSize, player1, player2);
            m_CheckersData.GameOverOccured    += checkersData_GameOver;
            m_CheckersData.BoardChangeOccured += checkersData_BoardChanged;
            m_Board = new Button[m_BoardSize, m_BoardSize];
            Size    = new Size((m_BoardSize * k_ButtonSize) + 100, (m_BoardSize * k_ButtonSize) + 100);
        }