use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class AttachmentPoint method read.
@Override
public void read(Json json, JsonValue jsonData) {
attachedToSlot = jsonData.getInt("slotId", -1);
type = Type.valueOf(jsonData.getString("type", Type.STATIC.name()));
if (type == Type.ATTACHED) {
attachmentType = AttachmentType.valueOf(jsonData.getString("attachmentType", AttachmentType.POSITION.name()));
boneName = jsonData.getString("boneName");
offset = json.readValue(Vector2.class, jsonData.get("offset"));
} else {
JsonValue arr = jsonData.get("value");
numericalValue.set(arr.get(0).asFloat(), arr.get(1).asFloat(), arr.get(2).asFloat());
}
}
use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class BvbProject method loadProject.
@Override
public void loadProject(FileHandle projectFileHandle, String data, boolean fromMemory) {
Json json = new Json();
JsonValue jsonValue = new JsonReader().parse(data);
bvBAddon.workspace.read(json, jsonValue);
}
use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class Prefab method load.
@Override
public void load(String data) {
JsonValue jsonValue = new JsonReader().parse(data);
Json json = new Json();
root = json.readValue(GameObject.class, jsonValue.get("root"));
}
use of com.badlogic.gdx.utils.JsonValue in project computercombat by janfic.
the class LoadingScreen method show.
@Override
public void show() {
this.skin = new Skin(Gdx.files.internal(Assets.SKIN));
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
Pixmap cursor = new Pixmap(Gdx.files.internal(Assets.CURSOR));
Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 0, 0));
this.progressBar = new ProgressBar(0, 1, 0.01f, false, skin.get("default-horizontal", ProgressBarStyle.class));
this.statusLabel = new Label("Loading Assets...", skin);
Table table = new Table(skin);
table.setFillParent(true);
table.add(statusLabel).row();
table.add(progressBar);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int index = 0;
int tries = 0;
JsonReader json = new JsonReader();
JsonValue parsed = json.parse(Gdx.files.internal("connections.json"));
List<String> connections = new ArrayList<>();
for (JsonValue jsonValue : parsed.child) {
connections.add(jsonValue.getString("ip") + " " + jsonValue.getString("port"));
}
System.out.println(connections);
boolean connected = false;
while (connected == false) {
try {
String[] connection = connections.get(index).split(" ");
game.setServerAPI(new ServerAPI(Gdx.net.newClientSocket(Net.Protocol.TCP, connection[0], Integer.parseInt(connection[1]), new SocketHints())));
connected = true;
Thread.sleep(5);
} catch (Exception e) {
tries++;
statusLabel.setText("Failed to Connect to server. Trying again. (" + tries + ")");
if (tries > 4) {
statusLabel.setText("Trying a different server...");
tries = 0;
index++;
index = index % connections.size();
}
}
}
game.getServerAPI().sendMessage(new Message(Type.CONNECTION_REQUEST, "CONNECTION_REQUEST"));
}
});
thread.start();
stage.addActor(table);
}
use of com.badlogic.gdx.utils.JsonValue in project computercombat by janfic.
the class MatchState method read.
@Override
public void read(Json json, JsonValue jsonData) {
json.setTypeName("class");
this.players = json.readValue("players", List.class, Player.class, jsonData);
json.setTypeName(null);
this.isGameOver = json.readValue("isGameOver", boolean.class, jsonData);
this.winner = json.readValue("winner", String.class, jsonData);
this.currentPlayerMove = json.readValue("currentPlayerMove", String.class, jsonData);
this.decks = json.readValue("decks", HashMap.class, Deck.class, jsonData);
HashMap<String, List<JsonValue>> v = json.readValue("activeEntities", HashMap.class, List.class, jsonData);
this.activeEntities = new HashMap<>();
for (String string : v.keySet()) {
List<Card> cards = new ArrayList<>();
for (JsonValue jsonValue : v.get(string)) {
Card c = json.readValue(Card.class, jsonValue);
cards.add(c);
}
activeEntities.put(string, cards);
}
this.computers = json.readValue("computers", HashMap.class, Card.class, jsonData);
String boardString = json.readValue("componentBoard", String.class, jsonData);
componentBoard = new Component[8][8];
assert (boardString.length() == 64);
for (int i = 0; i < boardString.length(); i++) {
int x = i / 8;
int y = i % 8;
try {
componentBoard[x][y] = new Component(Integer.parseInt("" + boardString.substring(i, i + 1)), x, y);
} catch (Exception e) {
e.printStackTrace();
}
}
json.setTypeName("class");
}
Aggregations