List of usage examples for com.badlogic.gdx.utils JsonValue getInt
public int getInt(String name, int defaultValue)
From source file:com.siondream.core.physics.PhysicsLoader.java
License:Apache License
private Filter loadFilter(JsonValue root, Filter filter) { JsonValue filterValue = root.get("filter"); if (filterValue == null) { logger.info("no filter for shape, returning default one"); return filter; }/* w w w .ja va2 s .c o m*/ logger.info("loading filter"); CategoryBitsManager categoryManager = Env.game.getCategoryBitsManager(); filter.categoryBits = categoryManager.getCategoryBits(filterValue.getString("categoryBits", "")); filter.groupIndex = (short) filterValue.getInt("groupIndex", 0); filter.maskBits = 0; JsonValue maskBits = filterValue.get("maskBits"); JsonIterator maskBitsIt = maskBits.iterator(); while (maskBitsIt.hasNext()) { filter.maskBits |= categoryManager.getCategoryBits(maskBitsIt.next().asString()); } return filter; }
From source file:com.siondream.libgdxjam.physics.PhysicsDataLoader.java
License:Apache License
private Filter loadFilter(JsonValue root, Filter filter) { JsonValue filterValue = root.get("filter"); if (filterValue == null) { logger.info("no filter for shape, returning default one"); return filter; }/*from w w w. j a v a2 s . com*/ logger.info("loading filter"); filter.categoryBits = categories.getBits(filterValue.getString("categoryBits", "")); filter.groupIndex = (short) filterValue.getInt("groupIndex", 0); if (filterValue.has("maskBits")) { JsonValue maskBits = filterValue.get("maskBits"); if (maskBits.has("collide")) { JsonValue collide = maskBits.get("collide"); JsonIterator collideIt = collide.iterator(); while (collideIt.hasNext()) { short bits = categories.getBits(collideIt.next().asString()); filter.maskBits |= bits; } } if (maskBits.has("filter")) { JsonValue skip = maskBits.get("filter"); JsonIterator skipIt = skip.iterator(); while (skipIt.hasNext()) { short bits = categories.getBits(skipIt.next().asString()); filter.maskBits &= ~bits; } } } return filter; }
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; }// w ww. j a v a 2 s . com 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:edu.franklin.practicum.f15.strategygame.StrategyGame.java
private void loadConfiguration() { Logger.logMsg("loading configuration file"); FileHandle fh = Gdx.files.internal("config/config.json"); String configString = fh.readString(); JsonValue root = new JsonReader().parse(configString); JsonValue graphicsJson = root.get("graphics"); JsonValue graphicsWindowJson = graphicsJson.get("window"); WinWidth = graphicsWindowJson.getInt("width", WinWidth); WinHeight = graphicsWindowJson.getInt("height", WinHeight); SafeSpace = graphicsJson.getInt("safeSpace", SafeSpace); JsonValue gameplayJson = root.get("gameplay"); int ordersDrainRate = gameplayJson.getInt("ordersDrainRate"); JsonValue defaultMapSizeJson = gameplayJson.get("defaultMapSize"); DefaultMapWidth = defaultMapSizeJson.getInt("width", DefaultMapWidth); DefaultMapHeight = defaultMapSizeJson.getInt("height", DefaultMapHeight); MapWidth = DefaultMapWidth;/* w w w .ja v a 2 s. c o m*/ MapHeight = DefaultMapHeight; }
From source file:es.eucm.ead.engine.tracking.gleaner.GleanerGameTracker.java
License:Open Source License
/** * Configure the tracker//from www . ja va 2s . c om * * @param config the json configuration */ private void configure(JsonValue config) { press = config.getBoolean(PRESS, false); phases = config.getBoolean(PHASES, false); tracker.setMaxTracesPerQueue(config.getInt(MAX_TRACES, -1)); JsonValue variables = config.get(VARIABLES); if (variables != null) { if (variables.isArray()) { JsonValue current = variables.child(); while (current != null) { this.watchField(current.asString()); current = current.next(); } } else { logger.warn("Invalid configuration value for variables. It should be an array of strings."); } } }
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;/* w w w.ja v a2 s. c o m*/ if (shipNode.hasChild("guard")) { guard = load(hullConfigs, shipNode.get("guard"), itemManager); } else { guard = null; } return new ShipConfig(hull, items, money, density, guard, itemManager); }