Exemplo n.º 1
0
    void MovePiece(Vector2 moveCoordinate)                                                                                         //moving the piece
    {
        ShowMoves();                                                                                                               //this hides the move buttons
        Vector2 movePos = new Vector2((moveCoordinate.x * gridSize) + gridOrigin.x, (moveCoordinate.y * gridSize) + gridOrigin.y); //selects move pos

        rectTransform.localPosition = movePos;                                                                                     //moves piece
        chessController.TakePiece(moveCoordinate, piece);                                                                          //asks controller to remove any piece landed on
        gridCoordinate = moveCoordinate;                                                                                           //updates grid coordinate

        if (CheckMovedTwoSquares())
        {
            chessController.AddEnPassant(this);
        }

        firstMove = false;

        if (CheckPawnUpgrade())
        {
            UpgradeToQueen();
        }

        chessController.EnablePieces();
        audioSource.Play();
    }