Exemplo n.º 1
0
    private bool research(int testX, int testY, BoardController controller, string color)
    {
        GameObject piece=controller.getPiece(testX+1, testY);
        if (piece!=null&&piece.GetComponent<GamePiece>().canHoldRequests)
            if (check (testX+1, testY, color)) return true;
        piece=controller.getPiece(testX-1, testY);
        if (piece!=null&&piece.GetComponent<GamePiece>().canHoldRequests)
            if (check (testX-1, testY, color)) return true;
        piece=controller.getPiece(testX, testY+1);
        if (piece!=null&&piece.GetComponent<GamePiece>().canHoldRequests)
            if (check (testX, testY+1, color)) return true;
        piece=controller.getPiece(testX, testY-1);
        if (piece!=null&&piece.GetComponent<GamePiece>().canHoldRequests)
            if (check (testX, testY-1, color)) return true;

        piece=controller.getPiece(testX+1, testY+1);
        if (piece!=null&&(piece.GetComponent<GamePiece>().transportsRequestsDiagonallym()||controller.getPiece(testX, testY).GetComponent<GamePiece>().transportsRequestsDiagonallym()))
            if (check (testX+1, testY+1, color)) return true;
        piece=controller.getPiece(testX+1, testY-1);
        if (piece!=null&&(piece.GetComponent<GamePiece>().transportsRequestsDiagonallym()||controller.getPiece(testX, testY).GetComponent<GamePiece>().transportsRequestsDiagonallym()))
            if (check (testX+1, testY-1, color)) return true;
        piece=controller.getPiece(testX-1, testY+1);
        if (piece!=null&&(piece.GetComponent<GamePiece>().transportsRequestsDiagonallym()||controller.getPiece(testX, testY).GetComponent<GamePiece>().transportsRequestsDiagonallym()))
            if (check (testX-1, testY+1, color)) return true;
        piece=controller.getPiece(testX-1, testY-1);
        if (piece!=null&&(piece.GetComponent<GamePiece>().transportsRequestsDiagonallym()||controller.getPiece(testX, testY).GetComponent<GamePiece>().transportsRequestsDiagonallym()))
            if (check (testX-1, testY-1, color)) return true;

        for (int i=0; i<pointsChecked.Count; i++) {
            if (((Vector2)pointsChecked[i]).x==testX&&((Vector2)pointsChecked[i]).y==testY) {
                pointsChecked.RemoveAt(i);
                i--;
            }
        }

        return false;
    }