Java 类com.badlogic.gdx.utils.JsonValue 实例源码

项目:gdx-gamesvcs    文件:NgioClient.java   
@Override
public boolean submitToLeaderboard(String leaderboardId, long score, String tag) {
    if (boardMapper == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot post score: No mapper for leader board ids provided.");
        return false;
    }

    Integer boardId = boardMapper.mapToGsId(leaderboardId);

    // no board available or not connected
    if (boardId == null || !isSessionActive())
        return false;

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("id", new JsonValue(boardId));
    parameters.addChild("value", new JsonValue(score));
    if (tag != null)
        parameters.addChild("tag", new JsonValue(tag));

    sendToGateway("ScoreBoard.postScore", parameters, null);

    return true;
}
项目:gdx-gamesvcs    文件:NgioClient.java   
@Override
public boolean submitEvent(String eventId, int increment) {
    // incrementing is not supported by Newgrounds, so we ignore the param

    if (!initialized) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot submit event before initialize() is called.");
        return false;
    }

    if (eventHostId == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot post event: No host id for logging events provided.");
        return false;
    }

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("event_name", new JsonValue(eventId));
    parameters.addChild("host", new JsonValue(eventHostId));

    sendToGateway("Event.logEvent", parameters, null);

    return true;
}
项目:gdx-gamesvcs    文件:NgioClient.java   
@Override
public boolean unlockAchievement(String achievementId) {
    if (medalMapper == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot unlock achievmenet: No mapper for achievement ids provided.");
        return false;
    }

    Integer medalId = medalMapper.mapToGsId(achievementId);

    // no board available or not connected
    if (medalId == null)
        return false;

    if (!isSessionActive())
        return false;

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("id", new JsonValue(medalId));

    sendToGateway("Medal.unlock", parameters, null);

    return true;
}
项目:gdx-gamesvcs    文件:GjScoreboardEntry.java   
protected static GjScoreboardEntry fromJson(JsonValue json, int rank, String currentPlayer) {
    GjScoreboardEntry gje = new GjScoreboardEntry();
    gje.rank = String.valueOf(rank);
    gje.score = json.getString("score");
    gje.sort = json.getLong("sort");
    gje.tag = json.getString("extra_data");
    String userId = json.getString("user_id");

    if (userId != null && !userId.isEmpty()) {
        gje.userId = userId;
        gje.displayName = json.getString("user");
        gje.currentPlayer = (currentPlayer != null && currentPlayer.equalsIgnoreCase(gje.displayName));
    } else
        gje.displayName = json.getString("guest");

    gje.stored = json.getString("stored");

    return gje;
}
项目:gdx-controllerutils    文件:ControllerMappings.java   
/**
 * Save mapping for this controller instance
 *
 * @return
 */
public JsonValue toJson() {
    JsonValue json = new JsonValue(JsonValue.ValueType.array);
    for (MappedInput mapping : mappingsByConfigured.values()) {
        JsonValue jsonmaping = new JsonValue(JsonValue.ValueType.object);
        jsonmaping.addChild("confId", new JsonValue(mapping.configuredInputId));
        if (mapping.controllerInput instanceof ControllerAxis)
            jsonmaping.addChild("axis", new JsonValue(((ControllerAxis) mapping.controllerInput).axisIndex));
        else if (mapping.controllerInput instanceof ControllerButton) {
            jsonmaping.addChild("button",
                    new JsonValue(((ControllerButton) mapping.controllerInput).buttonIndex));
            if (mapping.secondButtonForAxis != null)
                jsonmaping.addChild("buttonR", new JsonValue((mapping.secondButtonForAxis.buttonIndex)));
        } else if (mapping.controllerInput instanceof ControllerPovButton) {
            jsonmaping.addChild("pov", new JsonValue(((ControllerPovButton) mapping.controllerInput).povIndex));
            jsonmaping.addChild("vertical",
                    new JsonValue(((ControllerPovButton) mapping.controllerInput).povDirectionVertical));
        }
        json.addChild(jsonmaping);
    }
    return json;
}
项目:jenjin    文件:SkeletonJson.java   
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
    attachment.setWorldVerticesLength(verticesLength);
    float[] vertices = map.require("vertices").asFloatArray();
    if (verticesLength == vertices.length) {
        if (scale != 1) {
            for (int i = 0, n = vertices.length; i < n; i++)
                vertices[i] *= scale;
        }
        attachment.setVertices(vertices);
        return;
    }
    FloatArray weights = new FloatArray(verticesLength * 3 * 3);
    IntArray bones = new IntArray(verticesLength * 3);
    for (int i = 0, n = vertices.length; i < n;) {
        int boneCount = (int)vertices[i++];
        bones.add(boneCount);
        for (int nn = i + boneCount * 4; i < nn; i += 4) {
            bones.add((int)vertices[i]);
            weights.add(vertices[i + 1] * scale);
            weights.add(vertices[i + 2] * scale);
            weights.add(vertices[i + 3]);
        }
    }
    attachment.setBones(bones.toArray());
    attachment.setVertices(weights.toArray());
}
项目:nhglib    文件:InputJson.java   
@Override
public void parse(JsonValue jsonValue) {
    JsonValue contextsJson = jsonValue.get("contexts");

    for (JsonValue contextJson : contextsJson) {
        String name = contextJson.getString("name");
        JsonValue inputsJson = contextJson.get("inputs");

        InputContext inputContext = new InputContext(name);

        for (JsonValue inputJson : inputsJson) {
            //inputContext.addInput(inputFromJson(inputJson));
        }

        inputContexts.add(inputContext);
    }
}
项目:nhglib    文件:AssetJson.java   
@Override
public void parse(JsonValue jsonValue) {
    String alias = jsonValue.getString("alias");
    String source = jsonValue.getString("source");
    String classString = jsonValue.getString("classAlias");

    String dependenciesPath = jsonValue.getString(
            "dependenciesPath",
            getDefaultDependenciesPath(source));

    if (!dependenciesPath.endsWith("/")) {
        dependenciesPath += "/";
    }

    Class assetClass = SceneUtils.assetClassFromAlias(classString);

    output = new Asset(alias, source, assetClass);
    output.dependenciesPath = dependenciesPath;
}
项目:nhglib    文件:InputConfigurationsJson.java   
private StickConfiguration stickConfigurationFromJson(JsonValue stickConfigurationJson) {
    boolean invertHorizontalAxis = stickConfigurationJson.getBoolean("invertHorizontalAxis");
    boolean invertVerticalAxis = stickConfigurationJson.getBoolean("invertVerticalAxis");

    float deadZoneRadius = stickConfigurationJson.getFloat("deadZoneRadius");
    float horizontalSensitivity = stickConfigurationJson.getFloat("horizontalSensitivity");
    float verticalSensitivity = stickConfigurationJson.getFloat("verticalSensitivity");

    StickConfiguration stickConfiguration = new StickConfiguration();
    stickConfiguration.setInvertHorizontalAxis(invertHorizontalAxis);
    stickConfiguration.setInvertVerticalAxis(invertVerticalAxis);
    stickConfiguration.setDeadZoneRadius(deadZoneRadius);
    stickConfiguration.setHorizontalSensitivity(horizontalSensitivity);
    stickConfiguration.setVerticalSensitivity(verticalSensitivity);

    return stickConfiguration;
}
项目:nhglib    文件:ModelComponentJson.java   
@Override
public void parse(JsonValue jsonValue) {
    ModelComponent modelComponent =
            nhg.entities.createComponent(entity, ModelComponent.class);

    String type = jsonValue.getString("graphicsType");
    String asset = jsonValue.getString("asset", "");

    boolean enabled = jsonValue.getBoolean("enabled", true);

    JsonValue materialsJson = jsonValue.get("materials");

    if (materialsJson != null) {
        for (JsonValue mat : materialsJson) {
            PbrMaterialJson pbrMaterialJson = new PbrMaterialJson();
            pbrMaterialJson.parse(mat);

            modelComponent.pbrMaterials.add(pbrMaterialJson.get());
        }
    }

    modelComponent.type = ModelComponent.Type.fromString(type);
    modelComponent.asset = asset;
    modelComponent.enabled = enabled;
    output = modelComponent;
}
项目:nhglib    文件:InputHandlerOld.java   
public void fromJson(JsonValue jsonValue) {
    InputJson inputJson = new InputJson();
    inputJson.parse(jsonValue);

    for (InputContext inputContext : inputJson.get()) {
        addContext(inputContext);
    }

    InputConfigurationsJson configurationsJson = new InputConfigurationsJson();
    configurationsJson.parse(jsonValue);
    config = configurationsJson.get();

    mapKeyInputs();
    mapStickInputs();
    mapPointerInputs();
    mapMouseInputs();
}
项目:joe    文件:ParticleEffect.java   
public ParticleEffect(JsonValue json) {
    elapsed = 0;

    Vector2Pool vector2Pool = Vector2Pool.getInstance();
    position = vector2Pool.obtain(0, 0);
    sizeRange = vector2Pool.obtain(0, 0);
    durationRange = vector2Pool.obtain(0, 0);
    particlesRange = vector2Pool.obtain(0, 0);
    xOffsetRange = vector2Pool.obtain(0, 0);
    yOffsetRange = vector2Pool.obtain(0, 0);
    vxRange = vector2Pool.obtain(0, 0);
    vyRange = vector2Pool.obtain(0, 0);
    velocitySplits = vector2Pool.obtain(0, 0);
    angularVelocityRange = vector2Pool.obtain(0, 0);
    redRange = vector2Pool.obtain(0, 0);
    blueRange = vector2Pool.obtain(0, 0);
    greenRange = vector2Pool.obtain(0, 0);
    alphaRange = vector2Pool.obtain(0, 0);

    modifiers = new Array<ParticleModifier>();
    particles = new Array<Particle>();
    sprites = new Array<Sprite>();

    load(json);
}
项目:gdx-texture-packer-gui    文件:ScaleFactorJsonSerializer.java   
@Override
public ScaleFactorModel read(Json json, JsonValue jsonData, Class type) {
    String suffix = "";
    float factor = 1f;

    JsonValue.JsonIterator iterator = jsonData.iterator();
    while (iterator.hasNext()) {
        JsonValue value = iterator.next();
        switch (value.name) {
            case "suffix":
                suffix = value.asString();
                break;
            case "factor":
                factor = value.asFloat();
                break;
        }
    }
    return new ScaleFactorModel(suffix, factor);
}
项目:skin-composer    文件:StyleProperty.java   
@Override
public void read(Json json, JsonValue jsonValue) {
    try {
        name = jsonValue.getString("name");
        optional = jsonValue.getBoolean("optional");
        if (jsonValue.get("value").isNumber()) {
            type = Float.TYPE;
            value = Double.parseDouble(jsonValue.getString("value"));
        } else {
            type = ClassReflection.forName(jsonValue.getString("type"));
            if (jsonValue.get("value").isNull()) {
                value = null;
            } else {
                value = jsonValue.getString("value");
            }
        }
    } catch (ReflectionException ex) {
        Gdx.app.error(getClass().toString(), "Error reading from serialized object" , ex);
        DialogFactory.showDialogErrorStatic("Read Error...","Error reading from serialized object.\n\nOpen log?");
    }
}
项目:skin-composer    文件:JsonData.java   
@Override
public void read(Json json, JsonValue jsonData) {
    try {
        colors = json.readValue("colors", Array.class, jsonData);
        fonts = json.readValue("fonts", Array.class, jsonData);
        classStyleMap = new OrderedMap<>();
        for (JsonValue data : jsonData.get("classStyleMap").iterator()) {
            classStyleMap.put(ClassReflection.forName(data.name), json.readValue(Array.class, data));
        }
        for (Array<StyleData> styleDatas : classStyleMap.values()) {
            for (StyleData styleData : styleDatas) {
                styleData.jsonData = this;
            }
        }
        customClasses = json.readValue("customClasses", Array.class, CustomClass.class, new Array<>(), jsonData);
        for (CustomClass customClass : customClasses) {
            customClass.setMain(main);
        }
    } catch (ReflectionException e) {
        Gdx.app.log(getClass().getName(), "Error parsing json data during file read", e);
        main.getDialogFactory().showDialogError("Error while reading file...", "Error while attempting to read save file.\nPlease ensure that file is not corrupted.\n\nOpen error log?");
    }
}
项目:fabulae    文件:AnimationMap.java   
public ObjectMap<Integer, Array<AnimationDescription>> readTextureDescriptor(FileHandle textureDescriptor)
        throws IOException {

    JsonValue descriptor = new JsonReader().parse(textureDescriptor);

    JsonValue frame = descriptor.get("frame");
    frameWidth = frame.getInt("width");
    frameHeight = frame.getInt("height");
    frameDuration = 1 / frame.getFloat("fps");

    JsonValue offset = descriptor.get("middleOffset");
    middleOffset = new Vector2(offset.getInt("x", 0), offset.getInt("y", 0));
    middleOffsets = new ObjectMap<T, Vector2>();

    JsonValue object = descriptor.get("object");
    objectWidth = object.getInt("width");
    objectHeight = object.getInt("height");

    ObjectMap<Integer, Array<AnimationDescription>> returnValue = new ObjectMap<Integer, Array<AnimationDescription>>();
    for (JsonValue animation : descriptor.get("animations")) {
        readAnimation(animation, returnValue);
    }
    return returnValue;
}
项目:fabulae    文件:AnimationMap.java   
public AnimationDescription(T key, JsonValue line) {
    this.key = key;
    this.startingFrame = line.getInt("start");
    this.numberOfFrames = line.getInt("count");
    this.playMode = line.getInt("mode");
    this.sounds = readSoundInfo(line.get("sounds"));
    JsonValue offset = line.get("middleOffset");
    if (offset != null) {
        middleOffsets.put(key, new Vector2(offset.getInt("x"), offset.getInt("y")));
    }
    JsonValue bounds = line.get("bounds");
    if (bounds != null) {
        for (JsonValue rectangle : bounds) {
            this.bounds.put(Integer.valueOf(rectangle.name().trim()), new Rectangle(rectangle.getInt("x"),
                    rectangle.getInt("y"), rectangle.getInt("width"), rectangle.getInt("height")));
        }
    }
}
项目:RavTech    文件:RavInput.java   
@SuppressWarnings("unchecked")
public void reload () {
    RavTech.files.loadAsset("keybindings.json", String.class);
    RavTech.files.finishLoading();

    if ((!RavTech.settings.has("keybindings")))
        RavTech.settings.setValue("keybindings", RavTech.files.getAsset("keybindings.json", String.class));
    this.actionMaps.clear();
    Json json = new Json();

    ObjectMap<String, JsonValue> serializedActionMaps = json.fromJson(ObjectMap.class,
        RavTech.settings.getString("keybindings"));
    for (ObjectMap.Entry<String, JsonValue> entry : serializedActionMaps.entries()) {
        ActionMap actionMap = new ActionMap();
        actionMap.read(json, entry.value);
        this.actionMaps.put(entry.key, actionMap);
    }
    this.actionMaps.putAll(actionMaps);

    this.players.clear();
    Player player = new Player();
    for (int i = 0; i < inputDevices.size; i++)
        player.assignDevice(inputDevices.get(i), this.getActionMapForDevice(inputDevices.get(i)));
    players.add(player);
}
项目:RavTech    文件:RemoveChangeable.java   
@Override
public void undo () {
    JsonValue jsonData = new JsonReader().parse(gameComponent);
    Json json = new Json();
    GameObject tempObject = new GameObject();
    tempObject.readValue(json, jsonData);
    GameComponent toAddComponent = tempObject.getComponentByName(componentType);
    tempObject.getComponents().removeValue(tempObject.getComponentByName(componentType), true);
    tempObject.destroy();
    if (pathToComponent.lastIndexOf('/') == 0) {
        toAddComponent.setParent(null);
        RavTech.currentScene.addGameObject((GameObject)toAddComponent);
    } else {
        GameObject component = (GameObject)GameObjectTraverseUtil
            .gameComponentFromPath(pathToComponent.substring(0, pathToComponent.lastIndexOf('/')));
        toAddComponent.setParent(component);
        component.addComponent(toAddComponent);
    }
}
项目:RavTech    文件:Renderer.java   
@Override
public void read (Json json, JsonValue jsonData) {
    if (jsonData.has("sortingLayerName"))
        sortingLayerName = jsonData.getString("sortingLayerName");
    if (jsonData.has("sortingOrder"))
        sortingOrder = jsonData.getInt("sortingOrder");
    if (jsonData.has("enabled"))
        enabled = jsonData.getBoolean("enabled");
    if (jsonData.has("shader")) {
        Shader shader = new Shader("");
        shader.read(json, jsonData.get("shader"));
        this.shader = shader;
    }
    if(jsonData.has("srcBlendFunction"))
        srcBlendFunction = jsonData.getInt("srcBlendFunction");
    if(jsonData.has("dstBlendFunction"))
        srcBlendFunction = jsonData.getInt("dstBlendFunction");
}
项目:cocos2d-java    文件:BhTreeLoader.java   
public BhTree<T> parseJsonModelAndCreate(JsonValue jv_root) {
    BhTree<T> bht = new BhTree<T>();
    BhTreeModel model = parseJsonModel(jv_root);
    CCLog.debug(TAG, model.toString());
    bht.setup(model);
    return bht;
}
项目:cocos2d-java    文件:BhTreeLoader.java   
final StructBHTNode parseBHTNode(int depth, JsonValue jv) {
    String name = jv.name;
    String args = jv.getString("args", null);
    String key = jv.getString("key", null);
    StructBHTNode BHTNode = new StructBHTNode();
    BHTNode.type = name;
    BHTNode.args = args;
    BHTNode.key = key;
    BHTNode.depth = depth;

    int childrenCount = jv.size;
    if(args != null) {
        childrenCount -= 1;
    }
    if(key != null) {
        childrenCount -= 1;
    }
    if(childrenCount > 0) {
        BHTNode.children = new StructBHTNode[childrenCount];
    }

    for(int i = 0, count = 0; i < jv.size; ++i) {
        JsonValue jv_child = jv.get(i);
        if(jv_child.name == null) {
            CCLog.error(TAG, "child name cannot be null!");
            throw new GdxRuntimeException("child name cannot be null!");
        }
        if(jv_child.name.equals("args") || jv_child.name.equals("key")) {
            continue;
        }

        BHTNode.children[count++] = parseBHTNode(depth+1, jv_child);
    }
    return BHTNode;
}
项目:gdx-gamesvcs    文件:NgioClient.java   
/**
 * Call newgrounds.io gateway
 *
 * @param component  see http://www.newgrounds.io/help/components/
 * @param parameters also see NG doc
 * @param req        callback object
 */
protected void sendToGateway(String component, JsonValue parameters, RequestResultRunnable req) {
    // if no callback is needed, provide a no-op callback
    if (req == null)
        req = new RequestResultRunnable() {
            @Override
            public void run(String json) {
            }
        };

    sendForm("{\"app_id\": \"" + ngAppId + "\",\"session_id\":\"" + sessionId + "\","
                    + "\"call\": {\"component\": \"" + component + "\",\"parameters\": " +
                    (parameters == null ? "{}" : parameters.toJson(JsonWriter.OutputType.json)) + "}}\n",
            req);
}
项目:gdx-gamesvcs    文件:GjTrophy.java   
protected static GjTrophy fromJson(JsonValue json) {
    GjTrophy trophy = new GjTrophy();
    trophy.difficulty = json.getString("difficulty");
    trophy.trophyAchieved = json.getString("achieved");
    trophy.iconUrl = json.getString("image_url");
    trophy.trophyDesc = json.getString("description");
    trophy.trophyTitle = json.getString("title");
    trophy.trophyId = json.getString("id");

    return trophy;
}
项目:gdx-gamesvcs    文件:GameJoltClient.java   
/**
 * Helper method when just interested if GameJolt request was successful
 */
protected boolean parseSuccessFromResponse(String json) {
    JsonValue response = null;
    boolean success;
    try {
        response = new JsonReader().parse(json).get("response");
        success = response != null && response.getBoolean("success");
    } catch (Throwable t) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot parse GameJolt response: " + json, t);
        success = false;
    }
    return success;
}
项目:Planet-Generator    文件:Ring.java   
@Override
public void read(Json json, JsonValue jsonData) {
    minRadius = json.readValue("minimumRadius", Float.class, jsonData);
    maxRadius = json.readValue("maximumRadius", Float.class, jsonData);
    angularVelocity = json.readValue("angularVelocity", Float.class, jsonData);
    zTilt = json.readValue("zTilt", Float.class, jsonData);
    xTilt = json.readValue("xTilt", Float.class, jsonData);
    colors = json.readValue("colorGroup", ColorGroup.class, jsonData);

    this.baseObjectCount = json.readValue("objectCount", Integer.class, jsonData);
    objects = new Array<>(baseObjectCount);
}
项目:Planet-Generator    文件:Star.java   
@Override
public void read(Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    setSprite(new Sprite());
    int size = json.readValue("size", Integer.class, jsonData);
    getSprite().setSize(size, size);
    int x = json.readValue("xPos", Integer.class, jsonData);
    int y = json.readValue("yPos", Integer.class, jsonData);
    getSprite().setPosition(x, y);
}
项目:Planet-Generator    文件:Orbiter.java   
@Override
public void read(Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    angularVelocity = json.readValue("angularVelocity", Float.class, jsonData);
    zTilt = json.readValue("zTilt", Float.class, jsonData);
    xTilt = json.readValue("xTilt", Float.class, jsonData);
    radius = json.readValue("radius", Float.class, jsonData);
    angle = json.readValue("angle", Float.class, jsonData);
    yOffset = json.readValue("yOffset", Float.class, jsonData);
    initializeMatrices();
}
项目:Planet-Generator    文件:Planet.java   
@Override
public void read(Json json, JsonValue jsonData) {
    super.read(json, jsonData);
    texture = json.readValue("texture", String.class, jsonData);
    getSprite().setSize(getSize(), getSize());
    radius = getSprite().getWidth()/2;
}
项目:conquest    文件:Level.java   
public static SerialArray<Tile> load(String map, HashMap<Integer, Player> players) {
    JsonValue value = reader.parse(map);
    float scale = value.getFloat("scale");
    JsonValue regions = value.get("regions");

    SerialArray<Tile> tiles = new SerialArray<>();

    for (JsonValue region : regions) {
        Color color = Color.valueOf(region.getString("color"));

        for (JsonValue tile : region.get("tiles")) {
            int x = tile.getInt("x"), y = tile.getInt("y");
            int width = tile.getInt("w"), height = tile.getInt("h");
            Tile t = new Tile(x * scale, y * scale, (int) (width * scale), (int) (height * scale), color);
            t.setRegion(region.name);
            t.setTroops(tile.getInt("troops"));

            if (tile.get("city") != null) {
                JsonValue city = tile.get("city");
                float cx = city.getInt("x") * scale, cy = city.getInt("y") * scale;
                City c = new City(cx + t.getX(), cy + t.getY(), city.getBoolean("major"));

                t.setCity(c);
            }

            if (players.get(tile.getInt("owner")) != null) {
                t.setOwner(players.get(tile.getInt("owner")));
            }

            t.setIndex(tile.getInt("index"));
            tiles.add(t);
        }
    }

    for (int i = 0; i < tiles.size; i++) {
        tiles.get(i).setContacts(tiles);
    }

    return tiles;
}
项目:bobbybird    文件:MenuState.java   
private void createMenu() {
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);

    FileHandle fileHandle = Gdx.files.local(Core.DATA_PATH + "/data.json");
    JsonReader reader = new JsonReader();
    JsonValue val = reader.parse(fileHandle);

    Label title = new Label(val.getString("title"), skin, "title");
    root.add(title).padTop(50.0f).padBottom(75.0f);

    root.row();
    BouncingImage image = new BouncingImage(getCharacter());
    root.add(image);

    root.row();
    ImageButton imageButton = new  ImageButton(skin, "play");
    root.add(imageButton).padTop(75.0f).expandY().top();
    imageButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            getCore().getAssetManager().get(Core.DATA_PATH + "/sfx/jump.wav", Sound.class).play();
            showCharacterDialog();
        }
    });
}
项目:gdx-controllerutils    文件:ControllerMappings.java   
/**
 * @return all mappings as a json value
 */
public JsonValue toJson() {
    JsonValue json = new JsonValue(JsonValue.ValueType.array);
    if (mappedInputs != null)
        for (MappedInputs controllerMapping : mappedInputs.values())
            if (controllerMapping.isRecorded) {
                JsonValue controllerJson = new JsonValue(JsonValue.ValueType.object);
                controllerJson.addChild("name", new JsonValue(controllerMapping.getControllerName()));
                controllerJson.addChild("mapping", controllerMapping.toJson());
                json.addChild(controllerJson);
            }

    return json;
}
项目:gdx-controllerutils    文件:ControllerMappings.java   
public boolean fillFromJson(JsonValue json) {
    // initialize mapping map and controller information if not already present
    if (mappedInputs == null)
        mappedInputs = new HashMap<>();

    for (JsonValue controllerJson = json.child; controllerJson != null; controllerJson = controllerJson.next) {
        String controllerName = controllerJson.getString("name");

        if (mappedInputs.containsKey(controllerName))
            mappedInputs.remove(controllerName);

        MappedInputs newMapping = new MappedInputs(controllerName);
        mappedInputs.put(controllerName, newMapping);

        newMapping.isRecorded = true;

        for (JsonValue mappingsJson = controllerJson.get("mapping").child; mappingsJson != null;
             mappingsJson = mappingsJson.next) {

            int confId = mappingsJson.getInt("confId");

            if (mappingsJson.has("axis")) {
                newMapping.putMapping(new MappedInput(confId, new ControllerAxis(mappingsJson.getInt("axis"))));
            } else if (mappingsJson.has("pov")) {
                newMapping.putMapping(new MappedInput(confId, new ControllerPovButton(mappingsJson.getInt("pov"),
                        mappingsJson.getBoolean("vertical"))));
            } else if (mappingsJson.has("buttonR")) {
                newMapping.putMapping(new MappedInput(confId, new ControllerButton(mappingsJson.getInt("button")),
                        new ControllerButton(mappingsJson.getInt("buttonR"))));
            } else if (mappingsJson.has("button")) {
                newMapping.putMapping(new MappedInput(confId, new ControllerButton(mappingsJson.getInt("button"))));
            }
        }
    }

    return true;
}
项目:gdx-fireapp    文件:JsonListMapDeserializer.java   
protected Object processJsonValue(Json json, JsonValue jsonData)
{
    if (jsonData.isObject()) {
        return processObject(json, jsonData);
    } else if (jsonData.isValue()) {
        return processValue(json, jsonData);
    } else {
        return null;
    }
}
项目:gdx-fireapp    文件:JsonListMapDeserializer.java   
protected Object processValue(Json json, JsonValue jsonData)
{
    if (jsonData.isBoolean())
        return jsonData.asBoolean();
    else if (jsonData.isDouble())
        return jsonData.asDouble();
    else if (jsonData.isLong())
        return jsonData.asLong();
    else if (jsonData.isNull())
        return null;
    else if (jsonData.isString())
        return jsonData.asString();
    return null;
}
项目:fluffybalance    文件:LeaderBoardController.java   
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
    String result = httpResponse.getResultAsString();

    Json json = new Json();

    ArrayList list = json.fromJson(ArrayList.class, result);
    Array<LeaderBoardEntry> leaderBoardEntries = new Array<LeaderBoardEntry>();

    if (list != null) {
        for (Object entry : list) {
            if (entry != null && entry instanceof JsonValue) {
                JsonValue jsonEntry = (JsonValue) entry;

                // the reflection does not seem to work on iOS
                // LeaderBoardEntry leaderBoardEntry = json.readValue(
                //    LeaderBoardEntry.class, (JsonValue)entry);
                LeaderBoardEntry leaderBoardEntry = new LeaderBoardEntry();
                try {
                    leaderBoardEntry.name = jsonEntry.getString("name");
                    leaderBoardEntry.rank = jsonEntry.getInt("rank");
                    leaderBoardEntry.score = jsonEntry.getInt("score");
                } catch (IllegalArgumentException e) {
                    Gdx.app.log(TAG, "failed to read json: " + e.toString());
                    return;
                }

                leaderBoardEntries.add(leaderBoardEntry);
            }
        }
    }

    mListener.onSuccess(leaderBoardEntries);
}
项目:Onyx    文件:BoundsSerializer.java   
@Override
public Bounds read(Json json, JsonValue jsonData, Class type) {
    int width = jsonData.getInt("width");
    int height = jsonData.getInt("height");
    Bounds bounds = new Bounds(width, height);
    return bounds;
}
项目:jenjin    文件:SkeletonJson.java   
void readCurve (JsonValue map, CurveTimeline timeline, int frameIndex) {
    JsonValue curve = map.get("curve");
    if (curve == null) return;
    if (curve.isString() && curve.asString().equals("stepped"))
        timeline.setStepped(frameIndex);
    else if (curve.isArray()) {
        timeline.setCurve(frameIndex, curve.getFloat(0), curve.getFloat(1), curve.getFloat(2), curve.getFloat(3));
    }
}
项目:cgc-game    文件:CGCStat.java   
public void read(Json json, JsonValue jsonData) 
{
    punchesLandedPrisoner = jsonData.getInt("punchesLandedPrisoner");
    punchesLandedCop = jsonData.getInt("punchesLandedCop");
    trainKillsPrisoner = jsonData.getInt("trainKillsPrisoner");
    trainKillsCop = jsonData.getInt("trainKillsCop");
    beaten = jsonData.getBoolean("beaten");
    captures = jsonData.getInt("captures");
    mapID = jsonData.getInt("mapId");
    mapCompletionTime = jsonData.getLong("mapTime");
    trainsDerailed = jsonData.getInt("trainsDerailed");
    startingPrisoners = jsonData.getInt("startingPrisoners");
    survivingPrisoners = jsonData.getInt("survivingPrisoners");
}
项目:nhglib    文件:PbrMaterialJson.java   
@Override
public void parse(JsonValue jsonValue) {
    pbrMaterial = new PbrMaterial();
    pbrMaterial.targetNode = jsonValue.getString("targetNode", "");

    String albedo = jsonValue.getString("albedo", "");
    String metalness = jsonValue.getString("metalness", "");
    String roughness = jsonValue.getString("roughness", "");
    String normal = jsonValue.getString("normal", "");
    String ambientOcclusion = jsonValue.getString("ambientOcclusion", "");

    if (albedo != null) {
        pbrMaterial.albedo = albedo;
    }

    if (metalness != null) {
        pbrMaterial.metalness = metalness;
    }

    if (roughness != null) {
        pbrMaterial.roughness = roughness;
    }

    if (normal != null) {
        pbrMaterial.normal = normal;
    }

    if (ambientOcclusion != null) {
        pbrMaterial.ambientOcclusion = ambientOcclusion;
    }
}