示例#1
0
 private void addCardButtons()
 {
     m_GameLogic.CreateBoardMatrix(m_FormMemoryGameSettings.BoardRows, m_FormMemoryGameSettings.BoardCols);
     m_ButtonsMatrix = new ButtonMemoryGameCard[m_FormMemoryGameSettings.BoardRows, m_FormMemoryGameSettings.BoardCols];
     for (int i = 0; i < m_FormMemoryGameSettings.BoardRows; i++)
     {
         for (int j = 0; j < m_FormMemoryGameSettings.BoardCols; j++)
         {
             m_ButtonsMatrix[i, j] = new ButtonMemoryGameCard();
             m_ButtonsMatrix[i, j].Location = new Point(3 + (j * m_ButtonsMatrix[i, j].Width), 3 + (i * 4 * 19));
             m_ButtonsMatrix[i, j].Size = new Size(70, 70);
             m_ButtonsMatrix[i, j].RowIndex = i;
             m_ButtonsMatrix[i, j].ColIndex = j;
             m_ButtonsMatrix[i, j].Click += new EventHandler(buttonMemoryGameCard_Click);
             this.Controls.Add(m_ButtonsMatrix[i, j]);
         }
     }
 }
示例#2
0
        private void buttonMemoryGameCard_Click(object sender, EventArgs e)
        {
            ButtonMemoryGameCard button = sender as ButtonMemoryGameCard;

            if (!m_IsMatching)
            {
                upsideDownCard();
            }

            if (button.Enabled == true)
            {
                if (!m_FirstClick)
                {
                    m_ButtonFirstCard = button;
                    revealFirstCard(button.RowIndex, button.ColIndex);
                }
                else
                {
                    if (!m_SecondClick)
                    {
                        if (m_ButtonFirstCard != button)
                        {
                            m_ButtonSecondCard = button;
                            revealSecondCard(button.RowIndex, button.ColIndex);
                        }
                    }
                }
            }
        }
示例#3
0
        private void revealFirstCard(int i_RowIndex, int i_ColIndex)
        {
            m_FirstClick = true;
            m_SecondClick = false;

            m_ButtonFirstCard.Text = m_GameLogic.BoardGame.Board[i_RowIndex, i_ColIndex].ToString();
            m_ButtonFirstCard.BackColor = m_LabelCurrentPlayer.BackColor;
            m_ButtonSecondCard = null;
        }
示例#4
0
        private void compuetrMove(int i_FirstCardRow, int i_FirstCardCol, int i_SecondCardRow, int i_SecondCardCol)
        {
            System.Threading.Thread.Sleep(450);

            if (m_GameLogic.ComputerPlay.IsComputerTurn != true)
            {
                exchangeTurns();
            }

            if (m_IsMatching == false)
            {
                upsideDownCard();
            }

            m_ButtonFirstCard = m_ButtonsMatrix[i_FirstCardRow, i_FirstCardCol];
            m_ButtonSecondCard = null;
            revealFirstCard(i_FirstCardRow, i_FirstCardCol);
            m_ButtonSecondCard = m_ButtonsMatrix[i_SecondCardRow, i_SecondCardCol];
            revealSecondCard(i_SecondCardRow, i_SecondCardCol);
            this.Refresh();
        }