示例#1
0
        private void updateTargetAndSourceCellCoinImage()
        {
            switch (r_Game.Board.GetCoin(m_TargetButtonCell.BoardLocation).Symbol)
            {
            case Coin.eCoinSymbol.O:
                m_TargetButtonCell.Image = r_Player1Image;
                break;

            case Coin.eCoinSymbol.X:
                m_TargetButtonCell.Image = r_Player2Image;
                break;

            case Coin.eCoinSymbol.U:
                m_TargetButtonCell.Image = r_Player1KingImage;
                break;

            case Coin.eCoinSymbol.K:
                m_TargetButtonCell.Image = r_Player2KingImage;
                break;
            }

            m_SourceButtonCell.BackColor = Color.White;
            m_SourceButtonCell.Image     = null;
            m_SourceButtonCell           = null;
        }
示例#2
0
 private void setNewRound()
 {
     r_Game.SetGame();
     arrangeCoins();
     updateScoreStatus();
     switchTurn();
     m_IsGameOver       = false;
     m_SourceButtonCell = null;
     m_TargetButtonCell = null;
 }
示例#3
0
 private void handleComputerMoveIfNecessary()
 {
     if (!m_IsGameOver && r_IsComputerPlayer && r_Game.CurrentTurn.Name.Equals("Computer"))
     {
         do
         {
             r_Game.SetComputerRandomMoveCells();
             m_SourceButtonCell = r_GameBoard[r_Game.SourceCell.Row, r_Game.SourceCell.Column];
             m_TargetButtonCell = r_GameBoard[r_Game.TargetCell.Row, r_Game.TargetCell.Column];
             r_Game.UpdateMove(m_SourceButtonCell.BoardLocation, m_TargetButtonCell.BoardLocation);
             handleCoinMove();
         }while (r_Game.CurrentTurn.Name.Equals("Computer") && r_Game.HasContinuousMoves());
     }
 }
示例#4
0
        private CellButton createNewCell(int i_Row, int i_Column, int i_Left, int i_Top)
        {
            CellButton currentButton = new CellButton(i_Row, i_Column);

            currentButton.Left      = i_Left;
            currentButton.Top       = i_Top;
            currentButton.BackColor = Color.White;
            currentButton.FlatStyle = FlatStyle.Flat;
            currentButton.Size      = new Size(k_CellSize, k_CellSize);
            currentButton.Click    += new EventHandler(cellButton_Click);
            Controls.Add(currentButton);

            return(currentButton);
        }
示例#5
0
        private void cellButton_Click(object sender, EventArgs e)
        {
            CellButton clickedCellButton = sender as CellButton;
            bool       isValidMove;

            if (m_SourceButtonCell == null)
            {
                if (r_Game.IsLegalSourceCell(clickedCellButton.BoardLocation))
                {
                    clickedCellButton.BackColor = Color.LightBlue;
                    m_SourceButtonCell          = clickedCellButton;
                }
                else
                {
                    r_IllegalSound.Play();
                }
            }
            else
            {
                if (clickedCellButton == m_SourceButtonCell)
                {
                    clickedCellButton.BackColor = Color.White;
                    m_SourceButtonCell          = null;
                }
                else
                {
                    isValidMove = r_Game.IsLegalOption(m_SourceButtonCell.BoardLocation, clickedCellButton.BoardLocation);

                    if (isValidMove)
                    {
                        m_TargetButtonCell = clickedCellButton;
                        r_Game.UpdateMove(m_SourceButtonCell.BoardLocation, m_TargetButtonCell.BoardLocation);
                        handleCoinMove();
                        handleComputerMoveIfNecessary();
                    }
                    else
                    {
                        r_IllegalSound.Play();
                        MessageBox.Show("Illegal Move! Please try again.");
                        m_SourceButtonCell.BackColor = Color.White;
                        m_SourceButtonCell           = null;
                    }
                }
            }
        }
示例#6
0
 private void disableCell(CellButton i_CellButton)
 {
     i_CellButton.Enabled   = false;
     i_CellButton.FlatStyle = FlatStyle.Flat;
     i_CellButton.BackColor = Color.DarkGray;
 }