Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.digitalmeat.bot.data.game;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.utils.Json;
- import com.badlogic.gdx.utils.Json.Serializable;
- import com.badlogic.gdx.utils.JsonValue;
- public class Station implements Serializable {
- public String key;
- public String name;
- public StationType type;
- public ResourceLevels levels = new ResourceLevels();
- @Override
- public void write(Json json) {
- json.writeValue("key", key);
- json.writeValue("name", name);
- json.writeValue("type", type);
- json.writeValue("levels", levels);
- }
- @Override
- public void read(Json json, JsonValue data) {
- key = data.getString("key");
- name = data.getString("type");
- type = json.readValue("type", StationType.class, data);
- levels = json.readValue("levels", ResourceLevels.class, data);
- }
- public static Station read(String file) {
- Json json = new Json();
- return json.fromJson(Station.class, Gdx.files.internal(file));
- }
- public static void save(Station station, String file) {
- Json json = new Json();
- json.toJson(station, Gdx.files.local(file));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement