Example #1
0
        private void createOtheloButtonBoard()
        {
            for (int i = 0; i < m_FormLogin.BoardSize; i++)
            {
                for (int j = 0; j < m_FormLogin.BoardSize; j++)
                {
                    m_ButtonMatrix[i, j] = new OtheloSquerButton(new Coin(i, j));

                    m_ButtonMatrix[i, j].Size        = new Size(50, 50);
                    m_ButtonMatrix[i, j].Location    = new System.Drawing.Point(50 * j, 50 * i);
                    m_ButtonMatrix[i, j].BorderStyle = BorderStyle.Fixed3D;
                    m_ButtonMatrix[i, j].Click      += new EventHandler(OtheloSquerButton_Click);

                    if ((i == m_FormLogin.BoardSize / 2 && j == m_FormLogin.BoardSize / 2) ||
                        (i == (m_FormLogin.BoardSize / 2) - 1 && j == (m_FormLogin.BoardSize / 2) - 1))
                    {
                        m_ButtonMatrix[i, j].Image    = Properties.Resources.CoinYellow;
                        m_ButtonMatrix[i, j].SizeMode = PictureBoxSizeMode.StretchImage;
                    }
                    else if ((i == m_FormLogin.BoardSize / 2 && j == (m_FormLogin.BoardSize / 2) - 1) ||
                             (i == (m_FormLogin.BoardSize / 2) - 1 && j == m_FormLogin.BoardSize / 2))
                    {
                        m_ButtonMatrix[i, j].Image    = Properties.Resources.CoinRed;
                        m_ButtonMatrix[i, j].SizeMode = PictureBoxSizeMode.StretchImage;
                    }

                    m_GroupBoxForMatrix.Controls.Add(m_ButtonMatrix[i, j]);
                }
            }
        }
Example #2
0
        private void OtheloSquerButton_Click(object sender, EventArgs e)
        {
            OtheloSquerButton choosenButton = sender as OtheloSquerButton;
            Coin choosenCoinByPlayer        = new Coin();

            if (choosenButton.BackColor == Color.LawnGreen)
            {
                choosenCoinByPlayer.Row   = choosenButton.OtheloCoin.Row;
                choosenCoinByPlayer.Colum = choosenButton.OtheloCoin.Colum;
                MoveAction(choosenCoinByPlayer);
            }
            while (m_FormLogin.AgainstComputer && m_OtheloGame.CurrPlayer.PlayerType == ePlayerType.COMPUTER)
            {
                MakeComputerMove();
            }
        }