Beispiel #1
0
 private void tryToMove(PictureBoxInTheBoard i_SenderPicBoxInTheBoard)
 {
     if (i_SenderPicBoxInTheBoard.Tag.ToString() == e_SquaerTag.OptionalMoveFrom.ToString())
     {
         Image DefaultBackGroundImage = m_Board.WhiteBackGround;
         if (i_SenderPicBoxInTheBoard.BackgroundImage.Tag.ToString() == GameBoardUI.e_TypeOfBackGround.WHITE.ToString())
         {
             i_SenderPicBoxInTheBoard.BackgroundImage     = m_Board.BlueBackGround;
             i_SenderPicBoxInTheBoard.BackgroundImage.Tag = GameBoardUI.e_TypeOfBackGround.BLUE;
             m_ChekerSelectedOnBoard      = true;
             i_SenderPicBoxInTheBoard.Tag = e_SquaerTag.OptionalMoveFrom;
             m_LastMoveFrom = i_SenderPicBoxInTheBoard.PointInTheBoard;
             invokeAllTheOptionalMoveSquare(i_SenderPicBoxInTheBoard);
         }
         else if (i_SenderPicBoxInTheBoard.BackgroundImage.Tag.ToString() == GameBoardUI.e_TypeOfBackGround.BLUE.ToString())
         {
             i_SenderPicBoxInTheBoard.BackgroundImage     = DefaultBackGroundImage;
             i_SenderPicBoxInTheBoard.BackgroundImage.Tag = GameBoardUI.e_TypeOfBackGround.WHITE;
             m_ChekerSelectedOnBoard = false;
             disableAllMoveToClickableSquare();
             foreach (KeyValuePair <Point, Point> kvp in m_AllTheClickableSquareReadyToMove)
             {
                 m_Board.GetBoard[kvp.Key.X, kvp.Key.Y].Tag = e_SquaerTag.OptionalMoveFrom;
             }
         }
     }
 }
Beispiel #2
0
        public void PictureBoxInTheBoard_Click(object sender, EventArgs e)
        {
            MessageBoxButtons    wrongInputExceptionMessageType = MessageBoxButtons.OK;
            PictureBoxInTheBoard picAsSender = sender as PictureBoxInTheBoard;

            if (picAsSender.Tag.ToString() == e_SquaerTag.WrongSelection.ToString())
            {
                if (m_ChekerSelectedOnBoard)
                {
                    MessageBox.Show("Wrong Move", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Wrong Selection", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
                }
            }
            else if (picAsSender.Tag.ToString() == e_SquaerTag.WrongChecker.ToString())
            {
                MessageBox.Show("Wrong Checker Selected", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
            }
            else if (picAsSender.Image != null)
            {
                tryToMove(picAsSender);
            }
            else if (picAsSender.Tag.ToString() == e_SquaerTag.OptionalMoveTo.ToString())
            {
                afterMoving(picAsSender);
            }
        }
Beispiel #3
0
        public void PictureBoxInTheBoard_Click(object sender, EventArgs e)
        {
            MessageBoxButtons    wrongInputExceptionMessageType = MessageBoxButtons.OK;
            PictureBoxInTheBoard picAsSender = sender as PictureBoxInTheBoard;

            if (picAsSender.Tag.ToString() == e_SquaerTag.WrongSelection.ToString())
            {
                if (m_ChekerSelectedOnBoard)
                {
                    MessageBox.Show("Wrong Move", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Wrong Selection", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
                }
            }
            else if (picAsSender.Tag.ToString() == e_SquaerTag.WrongChecker.ToString())
            {
                MessageBox.Show("Wrong Checker Selected", "Wrong", wrongInputExceptionMessageType, MessageBoxIcon.Warning);
            }
            else if (picAsSender.Image != null)
            {
                if (picAsSender.Tag.ToString() == e_SquaerTag.OptionalMoveFrom.ToString())
                {
                    Image DefaultBackGroundImage = m_Board.WhiteBackGround;
                    if (picAsSender.BackgroundImage.Tag.ToString() == GameBoardUI.e_TypeOfBackGround.WHITE.ToString())
                    {
                        picAsSender.BackgroundImage     = m_Board.BlueBackGround;
                        picAsSender.BackgroundImage.Tag = GameBoardUI.e_TypeOfBackGround.BLUE;
                        m_ChekerSelectedOnBoard         = true;
                        picAsSender.Tag = e_SquaerTag.OptionalMoveFrom;
                        m_LastMoveFrom  = picAsSender.PointInTheBoard;
                        invokeAllTheOptionalMoveSquare(picAsSender);
                    }
                    else if (picAsSender.BackgroundImage.Tag.ToString() == GameBoardUI.e_TypeOfBackGround.BLUE.ToString())
                    {
                        picAsSender.BackgroundImage     = DefaultBackGroundImage;
                        picAsSender.BackgroundImage.Tag = GameBoardUI.e_TypeOfBackGround.WHITE;
                        m_ChekerSelectedOnBoard         = false;
                        disableAllMoveToClickableSquare();
                        foreach (KeyValuePair <Point, Point> kvp in m_AllTheClickableSquareReadyToMove)
                        {
                            //// m_Board.GetBoard[kvp.Key.X, kvp.Key.Y].Enabled = true;

                            m_Board.GetBoard[kvp.Key.X, kvp.Key.Y].Tag = e_SquaerTag.OptionalMoveFrom;
                        }
                    }
                }
            }
            else if (picAsSender.Tag.ToString() == e_SquaerTag.OptionalMoveTo.ToString())
            {
                afterMoving(picAsSender);
            }
        }
Beispiel #4
0
        private void afterMoving(PictureBoxInTheBoard i_CurrentPicBoxThatMoveTo)
        {
            if (i_CurrentPicBoxThatMoveTo != null)
            {
                m_LastMoveTo = i_CurrentPicBoxThatMoveTo.PointInTheBoard;
            }

            m_WasMove = true;
            returnSqureToEmpty();
            if (m_WasMove)
            {
                if (!m_CurrentPlayer)
                { //// case this is the player 1
                    player1Moving();
                }
                else
                { //// case this is the player 2
                    player2Moving();
                }
            }
        }
Beispiel #5
0
        private void invokeAllTheOptionalMoveSquare(PictureBoxInTheBoard i_PicAsSender)
        {
            Point blueSquare = new Point();

            blueSquare.X = i_PicAsSender.PointInTheBoard.X;
            blueSquare.Y = i_PicAsSender.PointInTheBoard.Y;
            foreach (KeyValuePair <Point, Point> kpv in m_AllTheClickableSquareReadyToMove)
            {
                if (kpv.Key != i_PicAsSender.PointInTheBoard)
                {
                    ////m_Board.GetBoard[kpv.Key.X, kpv.Key.Y].Enabled = false;
                    m_Board.GetBoard[kpv.Key.X, kpv.Key.Y].Tag = e_SquaerTag.WrongChecker;
                }
            }

            if (i_PicAsSender.Image.Tag.ToString() == e_TypeUICheckers.BlackChecker.ToString() ||
                i_PicAsSender.Image.Tag.ToString() == e_TypeUICheckers.BlackQueen.ToString())
            {
                if (m_Game.AttackListOfPlayer1.Count > 0)
                {
                    enableMoveToSquare(m_Game.AttackListOfPlayer1, blueSquare);
                }
                else
                {
                    enableMoveToSquare(m_Game.MoveListOfPlayer1, blueSquare);
                }
            }
            else
            {
                if (m_Game.AttackListOfPlayer1.Count > 0)
                {
                    enableMoveToSquare(m_Game.AttackListOfPlayer2, blueSquare);
                }
                else
                {
                    enableMoveToSquare(m_Game.MoveListOfPlayer2, blueSquare);
                }
            }
        }
Beispiel #6
0
        private void createBoard(int i_BoardSize)
        {
            for (int i = 0; i < i_BoardSize; i++)
            {
                for (int j = 0; j < i_BoardSize; j++)
                {
                    m_ButtonMatrixGameBoard[i, j] = new PictureBoxInTheBoard();
                    m_ButtonMatrixGameBoard[i, j].PointInTheBoard = new Point(i, j);
                    if ((j % 2 == 0 && i % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
                    {
                        m_ButtonMatrixGameBoard[i, j].BackgroundImage     = m_BrownBackGround;
                        m_ButtonMatrixGameBoard[i, j].BackgroundImage.Tag = e_TypeOfBackGround.BROWN;
                    }
                    else
                    {
                        m_ButtonMatrixGameBoard[i, j].BackgroundImage     = m_WhiteBackGround;
                        m_ButtonMatrixGameBoard[i, j].BackgroundImage.Tag = e_TypeOfBackGround.WHITE;
                    }

                    m_ButtonMatrixGameBoard[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                    m_ButtonMatrixGameBoard[i, j].BackColor             = Color.Black;
                }
            }
        }
Beispiel #7
0
        private void afterMoving(PictureBoxInTheBoard i_CurrentPicBoxThatMoveTo)
        {
            if (i_CurrentPicBoxThatMoveTo != null)
            {
                m_LastMoveTo = i_CurrentPicBoxThatMoveTo.PointInTheBoard;
            }

            m_WasMove = true;
            returnSqureToEmpty();
            if (m_WasMove)
            {
                if (!m_CurrentPlayer)
                { //// case this is the player 1
                    changeVisibleStatusFoeArrows(ConstantsUI.k_ArrowPlayer2);
                    m_Game.MoveTheCheckerOfTheCorecctPlayer(
                        m_Game.Player1,
                        m_Game.Player2,
                        convertCheckerPositionPointToSquareOfLogic(m_LastMoveFrom),
                        convertCheckerPositionPointToSquareOfLogic(m_LastMoveTo),
                        ref m_wasAttack,
                        ref m_hasAnotherAttack);
                    if (!winnerOrDraw())
                    {
                        initCheckers();
                        updateScore();
                        enableOrDisableStartOverButton(ConstantsUI.k_Player2Turn);
                        m_WasMove = false;
                        if (!m_hasAnotherAttack)
                        {
                            if (m_Game.Player2.MachineOrNot)
                            {
                                computerMove();
                                changeVisibleStatusFoeArrows(ConstantsUI.k_ArrowPlayer1);
                            }
                            else
                            {
                                changeVisibleStatusFoeArrows(ConstantsUI.k_ArrowPlayer2);
                                m_CurrentPlayer = true; ////---> now player2 turn
                                if (m_Game.AttackListOfPlayer2.Count > 0)
                                {
                                    invokeClickOnChecker(m_Game.AttackListOfPlayer2);
                                }
                                else
                                {
                                    invokeClickOnChecker(m_Game.MoveListOfPlayer2);
                                }
                            }
                        }
                        else
                        { ////--->Combo one more attack -> turn stay in Player1
                            invokeClickOnChecker(m_Game.AttackListOfPlayer1);
                        }
                    }
                }
                else
                { //// case this is the player 2
                    ////changeVisibleStatusFoeArrows(ConstantsUI.k_ArrowPlayer1);
                    m_Game.MoveTheCheckerOfTheCorecctPlayer(
                        m_Game.Player2,
                        m_Game.Player1,
                        convertCheckerPositionPointToSquareOfLogic(m_LastMoveFrom),
                        convertCheckerPositionPointToSquareOfLogic(m_LastMoveTo),
                        ref m_wasAttack,
                        ref m_hasAnotherAttack);
                    if (!winnerOrDraw())
                    {
                        initCheckers();
                        updateScore();
                        enableOrDisableStartOverButton(ConstantsUI.k_Player1Turn);
                        m_WasMove = false;
                        if (!m_hasAnotherAttack)
                        {
                            m_CurrentPlayer = false; ////---> now player1 turn
                            if (m_Game.AttackListOfPlayer1.Count > 0)
                            {
                                invokeClickOnChecker(m_Game.AttackListOfPlayer1);
                            }
                            else
                            {
                                invokeClickOnChecker(m_Game.MoveListOfPlayer1);
                            }
                        }
                        else
                        { ////--->Combo one more attack -> turn stay in Player2
                            invokeClickOnChecker(m_Game.AttackListOfPlayer2);
                        }

                        changeVisibleStatusFoeArrows(ConstantsUI.k_ArrowPlayer1);
                    }
                }
            }
        }