Example usage for com.badlogic.gdx.utils Json writeValue

List of usage examples for com.badlogic.gdx.utils Json writeValue

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Json writeValue.

Prototype

public void writeValue(Object value, Class knownType, Class elementType) 

Source Link

Document

Writes the value, writing the class of the object if it differs from the specified known type.

Usage

From source file:com.bladecoder.engine.model.SpriteActor.java

License:Apache License

@Override
public void write(Json json) {
    super.write(json);
    json.writeValue("renderer", renderer, null);

    if (SerializationHelper.getInstance().getMode() == Mode.MODEL) {

    } else {/*from  w  w w  . j a va 2 s.com*/
        json.writeValue("posTween", posTween, null);
        json.writeValue("scaleTween", scaleTween, null);
    }

    json.writeValue("scale", scale);
    json.writeValue("depthType", depthType);
    json.writeValue("bboxFromRenderer", bboxFromRenderer);
}

From source file:com.jupiter.europa.entity.component.AttributesComponent.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeValue(BASE_ATTRIBUTES_KEY, this.baseAttributes, AttributeSet.class);
    json.writeValue(CURRENT_ATTRIBUTES_KEY, this.currentAttributes, AttributeSet.class);
}

From source file:com.jupiter.europa.entity.component.SkillsComponent.java

@Override
public void write(Json json) {
    json.writeValue(SKILL_SET_KEY, this.skills, SkillSet.class);
    json.writeValue(CLASS_SKILLS_KEY, this.classSkills.toArray(new Skills[this.classSkills.size()]));
}

From source file:com.jupiter.europa.entity.Party.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeValue(PARTY_MEMBERS_KEY, this.partyMembers, HashMap.class);

    json.writeArrayStart(ACTIVE_PARTY_MEMBERS_KEY);
    for (EuropaEntity entity : this.getActivePartyMembers()) {
        json.writeValue(Mappers.name.get(entity).getName());
    }/*w  w  w . j  a va 2s.co  m*/
    json.writeArrayEnd();
}

From source file:com.jupiter.europa.save.SaveGame.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeValue(NAME_KEY, this.name, String.class);
    json.writeValue(WORLD_KEY, this.world.getName(), String.class);
    json.writeValue(LEVEL_KEY, this.getLevel().getName(), String.class);
    json.writeValue(PARTY_KEY, this.party, Party.class);
}

From source file:com.kotcrab.vis.runtime.scene.IntMapJsonSerializer.java

License:Apache License

@Override
public void write(Json json, IntMap object, Class knownType) {
    json.writeObjectStart();/*ww w. j  a  v a2  s.co  m*/

    for (IntMap.Entry entry : (IntMap.Entries<?>) object.entries()) {
        json.writeValue(String.valueOf(entry.key), entry.value, null);
    }

    json.writeObjectEnd();
}

From source file:com.vlaaad.dice.pvp.messaging.messages.Spawned.java

License:Open Source License

public static void register() {
    Config.json.addClassTag("spawned", Spawned.class);
    Config.json.setSerializer(Spawned.class, new Json.Serializer<Spawned>() {
        @Override//from   w w  w . j av  a  2s.com
        public void write(Json json, Spawned object, Class knownType) {
            json.writeObjectStart();
            if (knownType == null)
                json.writeType(Spawned.class);
            json.writeValue("d", object.dice, Array.class);
            json.writeValue("p", object.potions, ObjectMap.class, Integer.class);
            json.writeValue("f", object.fraction.name, String.class);
            json.writeValue("packetIdx", object.packetIdx);
            json.writeObjectEnd();
        }

        @SuppressWarnings("unchecked")
        @Override
        public Spawned read(Json json, JsonValue jsonData, Class type) {
            Array<PlacedCreature> dice = json.readValue(Array.class, PlacedCreature.class, jsonData.get("d"));
            ObjectMap potions = json.readValue(ObjectMap.class, Integer.class, jsonData.get("p"));
            Fraction fraction = Fraction.valueOf(jsonData.getString("f"));
            Spawned spawned = new Spawned(dice, potions, fraction);
            spawned.packetIdx = jsonData.getInt("packetIdx");
            return spawned;
        }
    });
}

From source file:com.vlaaad.dice.pvp.messaging.messages.SpawnedToServer.java

License:Open Source License

public static void register() {
    Config.json.addClassTag("sts", SpawnedToServer.class);
    Config.json.setSerializer(SpawnedToServer.class, new Json.Serializer<SpawnedToServer>() {
        @Override/*from w  w w .j  ava 2  s  . c  om*/
        public void write(Json json, SpawnedToServer object, Class knownType) {
            json.writeObjectStart();
            if (knownType == null)
                json.writeType(SpawnedToServer.class);
            json.writeValue("d", object.dice, Array.class);
            json.writeValue("p", object.potions, ObjectMap.class, Integer.class);
            json.writeValue("packetIdx", object.packetIdx);
            json.writeObjectEnd();
        }

        @SuppressWarnings("unchecked")
        @Override
        public SpawnedToServer read(Json json, JsonValue jsonData, Class type) {
            Array<PlacedCreature> dice = json.readValue(Array.class, PlacedCreature.class, jsonData.get("d"));
            ObjectMap potions = json.readValue(ObjectMap.class, Integer.class, jsonData.get("p"));
            SpawnedToServer spawnedToServer = new SpawnedToServer(dice, potions);
            spawnedToServer.packetIdx = jsonData.getInt("packetIdx");
            return spawnedToServer;
        }
    });
}