示例#1
0
        private void doWhenButtonClicked(object sender, EventArgs e)
        {
            eTypeOfMove i_TypeOfMove;
            ButtonPoint i_CurrentBtn = sender as ButtonPoint;

            if (m_IsAnotherButtonPress)
            {
                if (m_Game.GameBoard.Matrix[i_CurrentBtn.PointLocation.X, i_CurrentBtn.PointLocation.Y].Status != eStatus.NotExistCoin)
                {
                    if (i_CurrentBtn != m_PressButton)
                    {
                        if (this.v_CanMoreSkip)
                        {
                            showWarningMessage("You must eat again with the coin that made eating");
                        }
                        else
                        {
                            showWarningMessage("Illegal Target!");
                        }
                    }

                    m_PressButton.BackColor = Color.White;
                }
                else
                {
                    i_TypeOfMove = m_Game.DoMove(m_PressButton.PointLocation, i_CurrentBtn.PointLocation);
                    if (i_TypeOfMove == eTypeOfMove.IllegalMove)
                    {
                        if (this.v_CanMoreSkip)
                        {
                            showWarningMessage("You must eat again with the coin that made eating");
                        }
                        else
                        {
                            showWarningMessage("Illegal Move!");
                        }
                    }
                    else if (i_TypeOfMove == eTypeOfMove.MustToEat)
                    {
                        showWarningMessage("You Must To Eat!");
                    }
                    else if (i_TypeOfMove == eTypeOfMove.CanMoreSkip)
                    {
                        int[] target = { i_CurrentBtn.PointLocation.X, i_CurrentBtn.PointLocation.Y };
                        m_Game.TryCreateKing(target);
                        this.v_CanMoreSkip = true;
                        m_PressButton      = i_CurrentBtn;
                    }
                    else
                    {
                        int[] target = { i_CurrentBtn.PointLocation.X, i_CurrentBtn.PointLocation.Y };
                        m_Game.TryCreateKing(target);
                        m_Playerturn = m_Game.ChangeTurn();
                        doMoveIFComputerTurn();
                        updatePlayerTurnLabel();
                        checkEndGame();
                        this.v_CanMoreSkip = false;
                    }

                    updateBoard();
                }

                if (this.v_CanMoreSkip)
                {
                    m_PressButton.BackColor = Color.LightBlue;
                }
                else
                {
                    m_PressButton          = null;
                    m_IsAnotherButtonPress = false;
                }
            }
            else
            {
                if (m_Playerturn == m_Game.GameBoard.Matrix[i_CurrentBtn.PointLocation.X, i_CurrentBtn.PointLocation.Y].Owner)
                {
                    m_PressButton           = i_CurrentBtn;
                    m_PressButton.BackColor = Color.LightBlue;
                    m_IsAnotherButtonPress  = true;
                }
                else
                {
                    showWarningMessage("Not your coin!");
                }
            }
        }