Example #1
0
    private void DehighlightSquares( )
    {
        Square.GetComponent <SquareHandler>( ).DeHighlight( );

        foreach (Move move in legalMoves)
        {
            SquareHandler squareHandler = GameObject.Find(move.To.Name).GetComponent <SquareHandler>( );
            if (squareHandler.Highlighted)  /* possible overlap due to pawn promotion */
            {
                squareHandler.DeHighlight( );
            }
        }

        legalMoves.Clear( );
    }
Example #2
0
    private void HighlightSquares( )
    {
        Square.GetComponent <SquareHandler>( ).Highlight( );

        Square square = Board.GetSquare(Square.name);

        square.Piece.GenerateLegalMoves(legalMoves);

        foreach (Move move in legalMoves)
        {
            SquareHandler squareHandler = GameObject.Find(move.To.Name).GetComponent <SquareHandler>( );
            if (!squareHandler.Highlighted)  /* possible overlap due to pawn promotion */
            {
                squareHandler.Highlight(MOVE_HIGHLIGHT_ALPHA);
            }
        }
    }
Example #3
0
    private void ProcessMove(Move move = null)
    {
        move = move ?? Game.MoveHistory.Last;

        Square        fromSquare        = move.From;
        SquareHandler fromSquareHandler = GameObject.Find(fromSquare.Name).GetComponent <SquareHandler>( );

        PieceHandler movedPieceHandler = fromSquareHandler.Piece.GetComponent <PieceHandler>( );

        Square        toSquare        = move.To;
        SquareHandler toSquareHandler = GameObject.Find(toSquare.Name).GetComponent <SquareHandler>( );

        fromSquareHandler.Piece = null;

        if (toSquareHandler.Piece != null)
        {
            GameObject.Destroy(toSquareHandler.Piece);
            toSquareHandler.Piece = null;
        }

        toSquareHandler.Piece    = movedPieceHandler.gameObject;
        movedPieceHandler.Square = toSquareHandler.gameObject;

        movedPieceHandler.gameObject.transform.position = toSquareHandler.gameObject.transform.position;

        /* special cases */
        switch (move.Name)
        {
        case Move.MoveNames.CastleQueenSide:
        case Move.MoveNames.CastleKingSide:
            ProcessCastle(move);
            break;

        case Move.MoveNames.PawnPromotionBishop:
        case Move.MoveNames.PawnPromotionKnight:
        case Move.MoveNames.PawnPromotionQueen:
        case Move.MoveNames.PawnPromotionRook:
            ProcessPromotion(move, movedPieceHandler.gameObject);
            break;
        }
    }