Example usage for com.badlogic.gdx.utils JsonValue hasChild

List of usage examples for com.badlogic.gdx.utils JsonValue hasChild

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils JsonValue hasChild.

Prototype

public boolean hasChild(String name) 

Source Link

Document

Returns true if a child with the specified name exists and has a child.

Usage

From source file:com.tnf.ptm.common.ShipConfig.java

License:Apache License

public static ShipConfig load(HullConfigManager hullConfigs, JsonValue rootNode, ItemManager itemManager) {
    if (rootNode == null) {
        return null;
    }//www. j a v a 2  s  . co m
    String hullName = rootNode.getString("hull");
    HullConfig hull = hullConfigs.getConfig(new ResourceUrn(hullName));
    String items = rootNode.getString("items");
    int money = rootNode.getInt("money", 0);
    float density = rootNode.getFloat("density", -1);
    ShipConfig guard;
    if (rootNode.hasChild("guard")) {
        guard = load(hullConfigs, rootNode.get("guard"), itemManager);
    } else {
        guard = null;
    }
    return new ShipConfig(hull, items, money, density, guard, itemManager);
}

From source file:org.destinationsol.game.ShipConfig.java

License:Apache License

public static ShipConfig load(HullConfigManager hullConfigs, JsonValue shipNode, ItemManager itemManager) {
    if (shipNode == null)
        return null;
    String hullName = shipNode.getString("hull");
    HullConfig hull = hullConfigs.getConfig(hullName);
    String items = shipNode.getString("items");
    int money = shipNode.getInt("money", 0);
    float density = shipNode.getFloat("density", -1);
    ShipConfig guard;//from   w w  w. ja va 2  s  . com
    if (shipNode.hasChild("guard")) {
        guard = load(hullConfigs, shipNode.get("guard"), itemManager);
    } else {
        guard = null;
    }
    return new ShipConfig(hull, items, money, density, guard, itemManager);
}