List of usage examples for com.badlogic.gdx.utils JsonValue getString
public String getString(int index)
From source file:be.ac.ucl.lfsab1509.bouboule.game.physicEditor.BodyEditorLoader.java
License:Open Source License
private RigidBodyModel readRigidBody(JsonValue bodyElem) { RigidBodyModel rbModel = new RigidBodyModel(); rbModel.name = bodyElem.getString("name"); rbModel.imagePath = bodyElem.getString("imagePath"); JsonValue originElem = bodyElem.get("origin"); rbModel.origin.x = originElem.getFloat("x"); rbModel.origin.y = originElem.getFloat("y"); // polygons//w w w . j ava 2s . c o m JsonValue polygonsElem = bodyElem.getChild("polygons"); for (; polygonsElem != null; polygonsElem = polygonsElem.next()) { PolygonModel polygon = new PolygonModel(); rbModel.polygons.add(polygon); JsonValue vertexElem = polygonsElem.child(); for (; vertexElem != null; vertexElem = vertexElem.next()) { float x = vertexElem.getFloat("x"); float y = vertexElem.getFloat("y"); polygon.vertices.add(new Vector2(x, y)); } polygon.buffer = new Vector2[polygon.vertices.size()]; } // circles JsonValue circleElem = bodyElem.getChild("circles"); for (; circleElem != null; circleElem = circleElem.next()) { CircleModel circle = new CircleModel(); rbModel.circles.add(circle); circle.center.x = circleElem.getFloat("cx"); circle.center.y = circleElem.getFloat("cy"); circle.radius = circleElem.getFloat("r"); } return rbModel; }
From source file:com.izacc.equipment.Item.java
public Item(JsonValue json) { this.file = json.getString("file"); this.name = json.getString("name"); this.description = json.getString("description"); this.disable = json.has("disable") ? json.getBoolean("disable") : false; this.packable = json.has("packable") ? json.getBoolean("packable") : true; this.isPermanent = json.has("isPermanent") ? json.getBoolean("isPermanent") : true; this.bonus = json.has("bonus") ? json.getFloat("bonus") : 0.0f; this.time = json.has("time") ? json.getInt("time") : 0; this.buy = json.has("buy") ? json.getInt("buy") : 0; this.sell = json.has("sell") ? json.getInt("sell") : 0; this.itemType = ItemType.valueOf(json.getString("itemType")); this.effectType = EffectType.valueOf(json.getString("type")); }
From source file:com.izacc.equipment.SpellCard.java
public SpellCard(JsonValue json) { super(json);/* w w w .j av a 2 s . co m*/ this.id = json.has("id") ? json.getInt("id") : 0; this.speed = json.has("speed") ? json.getFloat("speed") : 0.0f; this.damage = json.has("damage") ? json.getFloat("damage") : 0.0f; this.spellType = SpellType.valueOf(json.getString("spellType")); }
From source file:com.jupiter.europa.entity.component.CharacterClassComponent.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { if (jsonData.has(CHARACTER_CLASS_TYPE_KEY)) { String className = jsonData.getString(CHARACTER_CLASS_TYPE_KEY); if (jsonData.has(CHARACTER_CLASS_INSTANCE_KEY)) { try { Class<?> classType = Class.forName(className); if (CharacterClass.class.isAssignableFrom(classType)) { this.characterClass = (CharacterClass) json.fromJson(classType, jsonData.get(CHARACTER_CLASS_INSTANCE_KEY).prettyPrint(EuropaGame.PRINT_SETTINGS)); }/* w w w . ja v a 2s . com*/ } catch (ClassNotFoundException ex) { } } } // If a value was not assigned for whatver reason if (this.characterClass == null) { this.characterClass = new Champion(); } }
From source file:com.jupiter.europa.entity.component.EffectsComponent.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { if (jsonData.has(EFFECTS_KEY)) { JsonValue selectedData = jsonData.get(EFFECTS_KEY); if (selectedData.isArray()) { selectedData.iterator().forEach((JsonValue value) -> { if (value.has(EFFECT_CLASS_KEY) && value.has(EFFECT_DATA_KEY)) { String typeName = value.getString(EFFECT_CLASS_KEY); try { Class<?> type = Class.forName(typeName); if (Effect.class.isAssignableFrom(type)) { this.effects .add((Effect) json.fromJson(type, value.get(EFFECT_DATA_KEY).toString())); }//from w w w .java2 s. c om } catch (ClassNotFoundException ex) { } } }); } } }
From source file:com.jupiter.europa.entity.component.MovementResourceComponent.java
@Override public void read(Json json, JsonValue jsonData) { this.atlasPath = jsonData.getString(ATLAS_PATH_KEY); this.spriteSetName = jsonData.getString(SPRITE_SET_NAME_KEY); this.fetchTextures(); }
From source file:com.jupiter.europa.entity.component.NameComponent.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { if (jsonData.has(NAME_KEY)) { this.name = jsonData.getString(NAME_KEY); }/*from ww w .j a v a2 s . c om*/ }
From source file:com.jupiter.europa.entity.component.PositionComponent.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { String worldName = jsonData.getString(WORLD_KEY); String levelName = jsonData.getString(LEVEL_KEY); int tileX = jsonData.getInt(TILE_POSITION_X_KEY); int tileY = jsonData.getInt(TILE_POSITION_Y_KEY); int zOrderValue = jsonData.getInt(Z_ORDER_KEY); this.setLevel(EuropaGame.game.getWorld(worldName).getLevel(levelName)); this.setTilePosition(new Point(tileX, tileY)); this.zOrder = zOrderValue; this.facing = MovementDirections.valueOf(jsonData.getString(FACING_KEY)); }
From source file:com.jupiter.europa.entity.component.RaceComponent.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { if (jsonData.has(RACE_KEY)) { this.race = PlayerRaces.valueOf(jsonData.getString(RACE_KEY)); }// w w w .j a v a 2 s .c o m }
From source file:com.jupiter.europa.entity.effects.MultiEffect.java
License:Open Source License
@Override public void read(Json json, JsonValue jsonData) { if (jsonData.has(EFFECTS_KEY)) { List<Effect> readEffects = new ArrayList<>(); jsonData.get(EFFECTS_KEY).iterator().forEach((JsonValue value) -> { if (value.has(EFFECT_CLASS_KEY) && value.has(EFFECT_DATA_KEY)) { try { Class<?> type = Class.forName(value.getString(EFFECTS_KEY)); if (Effect.class.isAssignableFrom(type)) { readEffects.add((Effect) json.fromJson(type, value.get(EFFECT_DATA_KEY).toString())); }//www.j av a 2s.co m } catch (ClassNotFoundException ex) { } } }); this.effects = readEffects.toArray(new Effect[readEffects.size()]); } }