示例#1
0
        /*
         * movePiece is a method that relocates piece on board, derives if piece can dominate again.
         */
        private void movePiece(Coordinates i_From, Coordinates i_To, out bool o_CanDominateAgain)
        {
            Piece    currentPiece = s_GameBoard[i_From];
            Movement currentMove  = getMovementByCoordinates(i_From, i_To);

            s_GameBoard[currentMove.To]     = currentPiece;
            currentPiece.CoordinatesOnBoard = currentMove.To;
            s_GameBoard.ClearCell(currentMove.From);

            if (currentMove.DominationMove)
            {
                dominatePiece(currentMove.DominatedPiece);

                o_CanDominateAgain = canDominateAgain(currentPiece);
            }
            else
            {
                o_CanDominateAgain = false;
            }

            CellChangeEventArgs arguments = new CellChangeEventArgs();

            arguments.From = i_From;
            arguments.To   = i_To;
            arguments.Team = GetCurrentPlayer().r_Team;
            OnCellChanged(arguments);

            if (isPieceOnUpperOrLowerBoardEdge(currentPiece))
            {
                currentPiece.MakeKing();
                arguments.PieceBecomeKing = true;
                OnPieceBecameKing(arguments);
            }
        }
示例#2
0
        /*
         * dominatePiece is a method that removes dominated piece from game.
         */
        private void dominatePiece(Piece i_DominatedPiece)
        {
            int row    = i_DominatedPiece.CoordinatesOnBoard.Y;
            int column = i_DominatedPiece.CoordinatesOnBoard.X;

            Player opposingPlayer = GetOpposingPlayer();

            s_GameBoard.ClearCell(i_DominatedPiece.CoordinatesOnBoard);
            opposingPlayer.RemovePiece(i_DominatedPiece);

            CellChangeEventArgs arguments = new CellChangeEventArgs();

            arguments.EatenPiece = new Coordinates(column, row);
            arguments.Team       = opposingPlayer.r_Team;

            OnPieceEaten(arguments);
        }
示例#3
0
 protected virtual void OnPieceEaten(CellChangeEventArgs e)
 {
     PieceEaten?.Invoke(e);
 }
示例#4
0
 protected virtual void OnPieceBecameKing(CellChangeEventArgs e)
 {
     PieceBecameKing?.Invoke(e);
 }
示例#5
0
        //--------------internal method is responsible for raising the event--------------

        protected virtual void OnCellChanged(CellChangeEventArgs e)
        {
            CellChanged?.Invoke(e);
        }