예제 #1
0
        private void SetButton(string i_Type, ButtonPositionOnBoard currentButton)
        {
            switch (i_Type)
            {
            case "X":
                currentButton.Text      = i_Type;
                currentButton.Image     = Properties.Resources.BlackGoodPiece;
                currentButton.ForeColor = Color.White;
                break;

            case "K":
                currentButton.Text      = i_Type;
                currentButton.Image     = Properties.Resources.BlackGoodPiece;
                currentButton.ForeColor = Color.White;
                break;

            case "O":
                currentButton.Text      = i_Type;
                currentButton.Image     = Properties.Resources.RedButton;
                currentButton.ForeColor = Color.White;
                break;

            default:
                currentButton.Text      = i_Type;
                currentButton.Image     = Properties.Resources.RedButton;
                currentButton.ForeColor = Color.White;
                break;
            }
        }
예제 #2
0
 private void BuildButtonSettings(ButtonPositionOnBoard i_Button, bool i_isEnabled, Point i_Point, string i_TypeOfPiece, Color i_Color, Size i_Size)
 {
     i_Button.Enabled   = i_isEnabled;
     i_Button.Location  = i_Point;
     i_Button.BackColor = i_Color;
     i_Button.Text      = i_TypeOfPiece;
     i_Button.Size      = i_Size;
 }
예제 #3
0
        private void SquareOneClick_Click_EventHandler(object sender, EventArgs e)
        {
            ButtonPositionOnBoard button = sender as ButtonPositionOnBoard;

            MakeBoardWhiteAndGray();

            if (m_CurrentPoint.X == -1 || m_CurrentPoint.Y == -1)
            {
                if (button.Text != string.Empty)
                {
                    m_CurrentPoint.X = button.X;
                    m_CurrentPoint.Y = button.Y;
                    button.BackColor = Color.LightBlue;
                    m_CurrentText    = button.Text;
                }
            }
            else
            {
                m_TargetPoint = new Point(button.X, button.Y);
                if (m_CurrentPoint == m_TargetPoint)
                {
                    button.BackColor = Color.White;
                    m_CurrentPoint.X = -1;
                    m_CurrentPoint.Y = -1;
                }
                else
                {
                    m_ButtonMatrix[m_CurrentPoint.X, m_CurrentPoint.Y].BackColor = Color.White;
                    PlayerMakingMoveClick();
                    SetLabelUpdatedScore();
                }
            }

            if (m_Player2Name == "Computer" && m_Game.CurrentTurn == "O")
            {
                ComputerMove();
                CheckIfCanContinue();
                SetLabelUpdatedScore();
                m_CurrentPoint.X = -1;
                m_CurrentPoint.Y = -1;
                SwitchEnabledButtons(m_Game.CurrentTurn);
            }
        }
예제 #4
0
        private void BuildTwoRowSpace()
        {
            int    row           = (m_BoardSize / 2) - 1;
            string emptyString   = string.Empty;
            Color  buttonColor   = m_ButtonMatrix[row - 1, m_BoardSize - 1].BackColor;
            Point  boardPosition = new Point(10, m_ButtonMatrix[row - 1, 0].Location.Y + 60);
            Size   positionSize  = new Size(60, 60);
            bool   isEnabled     = false;

            if (buttonColor == Color.White)
            {
                isEnabled = true;
            }

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < m_BoardSize; j++)
                {
                    ButtonPositionOnBoard currentButton = new ButtonPositionOnBoard(row, j);
                    BuildButtonSettings(currentButton, isEnabled, boardPosition, emptyString, buttonColor, positionSize);
                    m_ButtonMatrix[row, j]        = currentButton;
                    m_ButtonMatrix[row, j].Click += new EventHandler(SquareOneClick_Click_EventHandler);
                    Controls.Add(m_ButtonMatrix[row, j]);
                    isEnabled        = !isEnabled;
                    boardPosition.X += 60;
                    if (buttonColor == Color.Gray)
                    {
                        buttonColor = Color.White;
                    }
                    else
                    {
                        buttonColor = Color.Gray;
                    }
                }

                boardPosition.X  = 10;
                boardPosition.Y += 60;
                buttonColor      = m_ButtonMatrix[row, m_BoardSize - 1].BackColor;
                isEnabled        = m_ButtonMatrix[row, m_BoardSize - 1].Enabled;
                row++;
            }
        }
예제 #5
0
        private void BuildXRows()
        {
            int    row           = (m_BoardSize / 2) + 1;
            Point  boardPosition = new Point(10, m_ButtonMatrix[row - 1, 0].Location.Y + 60);
            Size   positionSize  = new Size(60, 60);
            bool   isEnabled;
            string pieceType   = "X";
            string emptyString = string.Empty;
            Color  buttonColor;

            for (int i = row; i < m_BoardSize; i++)
            {
                for (int j = 0; j < m_BoardSize; j++)
                {
                    ButtonPositionOnBoard currentButton = new ButtonPositionOnBoard(i, j);
                    if (j % 2 != i % 2)
                    {
                        buttonColor = Color.White;
                        isEnabled   = true;
                        BuildButtonSettings(currentButton, isEnabled, boardPosition, pieceType, buttonColor, positionSize);
                        currentButton.Image         = Properties.Resources.BlackGoodPiece;
                        m_ButtonMatrix[i, j]        = currentButton;
                        m_ButtonMatrix[i, j].Click += new EventHandler(SquareOneClick_Click_EventHandler);
                    }
                    else
                    {
                        buttonColor = Color.Gray;
                        isEnabled   = false;
                        BuildButtonSettings(currentButton, isEnabled, boardPosition, emptyString, buttonColor, positionSize);
                        m_ButtonMatrix[i, j] = currentButton;
                    }

                    Controls.Add(m_ButtonMatrix[i, j]);
                    isEnabled        = !isEnabled;
                    boardPosition.X += 60;
                }

                boardPosition.X  = 10;
                boardPosition.Y += 60;
            }
        }
예제 #6
0
        private void BuildORows()
        {
            Point  boardPosition = new Point(10, 60);
            Size   positionSize  = new Size(60, 60);
            bool   isEnabled     = false;
            string pieceType     = "O";
            string emptyString   = string.Empty;
            Color  buttonColor   = Color.Gray;

            for (int i = 0; i < (m_BoardSize / 2) - 1; i++)
            {
                for (int j = 0; j < m_BoardSize; j++)
                {
                    ButtonPositionOnBoard currentButton = new ButtonPositionOnBoard(i, j);
                    if (j % 2 != i % 2)
                    {
                        buttonColor = Color.White;
                        BuildButtonSettings(currentButton, isEnabled, boardPosition, pieceType, buttonColor, positionSize);
                        currentButton.Image         = Properties.Resources.RedButton;
                        m_ButtonMatrix[i, j]        = currentButton;
                        m_ButtonMatrix[i, j].Click += new EventHandler(SquareOneClick_Click_EventHandler);
                    }
                    else
                    {
                        buttonColor = Color.Gray;
                        BuildButtonSettings(currentButton, isEnabled, boardPosition, emptyString, buttonColor, positionSize);
                        m_ButtonMatrix[i, j] = currentButton;
                    }

                    Controls.Add(m_ButtonMatrix[i, j]);
                    isEnabled        = !isEnabled;
                    boardPosition.X += 60;
                }

                boardPosition.X = 10;
                boardPosition.Y = 60 + (60 * (i + 1));
                isEnabled       = m_ButtonMatrix[i, m_BoardSize - 1].Enabled;
            }
        }