Example #1
0
        private void ColButton_Click(object sender, EventArgs e)
        {
            ColButton buttonPressed     = sender as ColButton;
            bool      gameWon           = false;
            int       selectedCol       = buttonPressed.Col;
            int       lastRowInsertedTo = -1;

            if (coinFallTimer.Enabled == false && buttonPressed != null && !m_GameBoard.CheckIfBoardColumnFull(selectedCol))
            {
                m_GameLogic.MakeMove(m_GameBoard, currentPlayerCoin, selectedCol, ref lastRowInsertedTo, ref gameWon);
                if (gameWon)
                {
                    m_GameState = GameState.Victory;
                    matchOver   = true;
                }

                if (m_GameBoard.CheckIfBoardFull() && m_GameState == GameState.ContinuePlaying)
                {
                    m_GameState = GameState.Tie;
                    matchOver   = true;
                }

                CoinFallingAnimation(buttonPressed.Col, lastRowInsertedTo, m_GameState);
            }
        }
Example #2
0
        private void InitColButtons(int Col)
        {
            r_ColumnButtons.Capacity = Col;
            int yPosition     = 0;
            int nextXPosition = 0;

            for (int i = 0; i < r_ColumnButtons.Capacity; i++)
            {
                ColButton newColButton = new ColButton(nextXPosition, yPosition, i);
                newColButton.Click += ColButton_Click;
                r_ColumnButtons.Add(newColButton);
                nextXPosition += Properties.Resources.EmptyCell.Size.Width;
            }
        }