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

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

Introduction

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

Prototype

public void writeArrayEnd() 

Source Link

Usage

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

License:Apache License

@Override
public void write(Json json) {

    if (SerializationHelper.getInstance().getMode() == Mode.MODEL) {
        json.writeValue("id", id);
        json.writeValue("target", target);
        json.writeValue("state", state);
        json.writeValue("icon", icon);
        json.writeArrayStart("actions");
        for (Action a : actions) {
            ActionUtils.writeJson(a, json);
        }//from ww w.j  a va2 s . c o  m
        json.writeArrayEnd();
    } else {
        json.writeValue("ip", ip);

        json.writeArrayStart("actions");
        for (Action a : actions) {
            if (a instanceof Serializable) {
                json.writeObjectStart();
                ((Serializable) a).write(json);
                json.writeObjectEnd();
            }
        }
        json.writeArrayEnd();
    }
}

From source file:com.github.fauu.helix.manager.AreaManager.java

License:Open Source License

public void create(String name, int width, int length) {
    Json json = new Json();

    IntVector2 dimensions = new IntVector2(width, length);

    FileHandle file = Gdx.files.internal("area/" + name + ".json");

    try {//w  ww .  j  av  a 2s . co  m
        json.setWriter(new JsonWriter(new FileWriter(file.file())));
    } catch (IOException e) {
        e.printStackTrace();
    }

    json.writeObjectStart();
    json.writeValue("width", dimensions.x);
    json.writeValue("length", dimensions.y);
    json.writeArrayStart("tiles");
    for (int y = 0; y < dimensions.y; y++) {
        for (int x = 0; x < dimensions.x; x++) {
            json.writeObjectStart();
            json.writeValue("permissions", TilePermission.LEVEL0.toString());
            json.writeObjectEnd();
        }
    }
    json.writeArrayEnd();
    json.writeObjectEnd();

    try {
        json.getWriter().close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.github.fauu.helix.manager.AreaManager.java

License:Open Source License

public void save() {
    Json json = new Json();

    String name = nameMapper.get(area).get();

    FileHandle file = Gdx.files.internal("area/" + name + ".json");

    IntVector2 dimensions = dimensionsMapper.get(area).get();

    AreaType type = areaTypeMapper.get(area).get();

    try {// w  ww.  jav  a 2 s.c  o m
        json.setWriter(new JsonWriter(new FileWriter(file.file())));
    } catch (IOException e) {
        e.printStackTrace();
    }

    json.writeObjectStart();
    json.writeValue("width", dimensions.x);
    json.writeValue("length", dimensions.y);
    json.writeValue("type", type);
    json.writeArrayStart("tiles");
    Tile[][] tiles = tilesMapper.get(area).get();
    for (int y = 0; y < dimensions.y; y++) {
        for (int x = 0; x < dimensions.x; x++) {
            Tile tile = tiles[y][x];

            json.writeObjectStart();

            json.writeValue("permissions", tile.getPermissions().toString());

            if (tile.getAreaPassage() != null) {
                TileAreaPassage passage = tile.getAreaPassage();

                json.writeObjectStart("passage");

                json.writeValue("area", passage.getTargetAreaName());

                json.writeObjectStart("position");
                json.writeValue("x", passage.getTargetCoords().x);
                json.writeValue("y", passage.getTargetCoords().y);
                json.writeObjectEnd();

                json.writeObjectEnd();
            }

            json.writeObjectEnd();
        }
    }
    json.writeArrayEnd();
    json.writeObjectEnd();

    try {
        json.getWriter().close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

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

License:Open Source License

@Override
public void write(Json json) {
    json.writeArrayStart(EFFECTS_KEY);/*from w  ww .  j  a va2  s.c om*/
    this.effects.stream().forEach((Effect effect) -> {
        json.writeObjectStart();
        json.writeValue(EFFECT_CLASS_KEY, effect.getClass().getName());
        json.writeValue(EFFECT_DATA_KEY, effect, effect.getClass());
        json.writeObjectEnd();
    });
    json.writeArrayEnd();
}

From source file:com.jupiter.europa.entity.effects.MultiEffect.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeArrayStart(EFFECTS_KEY);// ww  w  .j  ava 2  s  .c o m
    for (Effect effect : this.effects) {
        json.writeObjectStart();
        json.writeValue(EFFECT_CLASS_KEY, effect.getClass().getName());
        json.writeValue(EFFECT_DATA_KEY, effect, effect.getClass());
        json.writeObjectEnd();
    }
    json.writeArrayEnd();
}

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

License:Open Source License

@Override
public void write(Json json) {
    json.writeValue(OLD_ID_KEY, this.getId());

    json.writeArrayStart(COMPONENTS_KEY);
    for (Component component : this.getComponents()) {
        if (component instanceof Serializable) {
            json.writeObjectStart();//from   w  w w .  java  2s  .  com
            json.writeValue(COMPONENT_CLASS_KEY, component.getClass().getName());
            json.writeValue(COMPONENT_DATA_KEY, component, component.getClass());
            json.writeObjectEnd();
        }
    }
    json.writeArrayEnd();
}

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());
    }//from www.  j a v  a  2  s. c o m
    json.writeArrayEnd();
}

From source file:com.jupiter.europa.entity.trait.TraitPool.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeValue(CAPACITY_KEY, this.capacity);

    json.writeArrayStart(SELECTED_KEY);//ww w .  j  ava  2 s .  c o  m
    this.selected.stream().forEach((T item) -> {
        json.writeObjectStart();
        json.writeValue(ITEM_CLASS_KEY, item.getClass().getName());
        json.writeValue(ITEM_DATA_KEY, item, item.getClass());
        json.writeObjectEnd();
    });
    json.writeArrayEnd();
}

From source file:com.strategames.engine.gameobject.types.Door.java

License:Open Source License

@Override
protected void writeValues(Json json) {
    json.writeArrayStart("nextLevelPosition");
    json.writeValue(entryLevel[0]);// w  w  w.jav  a2s  .co m
    json.writeValue(entryLevel[1]);
    json.writeArrayEnd();
}

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

License:Open Source License

public static void register() {
    Config.json.addClassTag("start", Start.class);
    Config.json.addClassTag("coordinate", Grid2D.Coordinate.class);
    Config.json.setElementType(Start.class, "order", String.class);
    Config.json.setSerializer(Grid2D.Coordinate.class, new Json.Serializer<Grid2D.Coordinate>() {
        @Override/*from   w  w w  .  ja v a 2  s.c  om*/
        public void write(Json json, Grid2D.Coordinate object, Class knownType) {
            json.writeArrayStart();
            json.writeValue(object.x());
            json.writeValue(object.y());
            json.writeArrayEnd();
        }

        @Override
        public Grid2D.Coordinate read(Json json, JsonValue jsonData, Class type) {
            return new Grid2D.Coordinate(jsonData.getInt(0), jsonData.getInt(1));
        }
    });
}