use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class InkManager method read.
@Override
public void read(Json json, JsonValue jsonData) {
BladeJson bjson = (BladeJson) json;
World w = bjson.getWorld();
final String name = json.readValue("storyName", String.class, jsonData);
if (bjson.getMode() == Mode.MODEL) {
story = null;
storyName = name;
// game and we will load the story in the STATE mode.
if (bjson.getInit()) {
loadThreaded(name, null);
}
} else {
wasInCutmode = json.readValue("wasInCutmode", Boolean.class, jsonData);
// READ STORY
final String storyString = json.readValue("story", String.class, jsonData);
if (storyString != null) {
loadThreaded(name, storyString);
}
// FOR BACKWARD COMPATIBILITY
if (jsonData.has("actions")) {
String sCb = json.readValue("cb", String.class, jsonData);
// READ ACTIONS
JsonValue actionsValue = jsonData.get("actions");
InkVerbRunner inkVerbRunner = new InkVerbRunner(w, this, StoryState.kDefaultFlowName, null, sCb);
verbRunners.put(StoryState.kDefaultFlowName, inkVerbRunner);
for (int i = 0; i < actionsValue.size; i++) {
JsonValue aValue = actionsValue.get(i);
Action a = ActionUtils.readJson(w, json, aValue);
inkVerbRunner.getActions().add(a);
}
inkVerbRunner.setIP(json.readValue("ip", Integer.class, jsonData));
actionsValue = jsonData.get("actionsSer");
int i = 0;
for (Action a : inkVerbRunner.getActions()) {
if (a instanceof Serializable && i < actionsValue.size) {
if (actionsValue.get(i) == null)
break;
((Serializable) a).read(json, actionsValue.get(i));
i++;
}
}
} else {
for (int i = 0; i < jsonData.get("verbRunners").size; i++) {
JsonValue jRunner = jsonData.get("verbRunners").get(i);
InkVerbRunner inkVerbRunner = new InkVerbRunner(w, this, jRunner.name, null, null);
verbRunners.put(jRunner.name, inkVerbRunner);
inkVerbRunner.read(json, jRunner);
}
}
}
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class CharacterActor method read.
@SuppressWarnings("unchecked")
@Override
public void read(Json json, JsonValue jsonData) {
super.read(json, jsonData);
BladeJson bjson = (BladeJson) json;
if (bjson.getMode() == Mode.MODEL) {
dialogs = json.readValue("dialogs", HashMap.class, Dialog.class, jsonData);
if (dialogs != null) {
for (Dialog d : dialogs.values()) d.setActor(this);
}
} else {
if (dialogs != null) {
JsonValue dialogsValue = jsonData.get("dialogs");
for (Dialog d : dialogs.values()) {
String id = d.getId();
JsonValue dValue = dialogsValue.get(id);
if (dValue != null)
d.read(json, dValue);
}
}
standAnim = json.readValue("standAnim", String.class, DEFAULT_STAND_ANIM, jsonData);
walkAnim = json.readValue("walkAnim", String.class, DEFAULT_WALK_ANIM, jsonData);
talkAnim = json.readValue("talkAnim", String.class, DEFAULT_TALK_ANIM, jsonData);
}
textStyle = json.readValue("textStyle", String.class, textStyle, jsonData);
walkingSpeed = json.readValue("walkingSpeed", float.class, walkingSpeed, jsonData);
textColor = json.readValue("textColor", Color.class, textColor, jsonData);
talkingTextPos = json.readValue("talkingTextPos", Vector2.class, talkingTextPos, jsonData);
if (talkingTextPos != null) {
float worldScale = EngineAssetManager.getInstance().getScale();
talkingTextPos.x *= worldScale;
talkingTextPos.y *= worldScale;
}
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class Dialog method read.
@SuppressWarnings("unchecked")
@Override
public void read(Json json, JsonValue jsonData) {
BladeJson bjson = (BladeJson) json;
if (bjson.getMode() == Mode.MODEL) {
id = json.readValue("id", String.class, jsonData);
// actor = json.readValue("actor", String.class, jsonData);
options = json.readValue("options", ArrayList.class, DialogOption.class, jsonData);
} else {
JsonValue optionsValue = jsonData.get("options");
int i = 0;
for (DialogOption o : options) {
JsonValue jsonValue = optionsValue.get(i);
if (jsonValue == null)
break;
o.read(json, jsonValue);
i++;
}
currentOption = json.readValue("currentOption", int.class, jsonData);
}
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class Inventory method read.
@Override
public void read(Json json, JsonValue jsonData) {
BladeJson bjson = (BladeJson) json;
visible = json.readValue("visible", Boolean.class, jsonData);
items.clear();
JsonValue jsonValueActors = jsonData.get("items");
SceneActorRef actorRef;
// GET ACTORS FROM HIS INIT SCENE.
for (int i = 0; i < jsonValueActors.size; i++) {
JsonValue jsonValueAct = jsonValueActors.get(i);
actorRef = new SceneActorRef(jsonValueAct.name);
Scene sourceScn = bjson.getWorld().getScene(actorRef.getSceneId());
BaseActor actor = sourceScn.getActor(actorRef.getActorId(), false);
sourceScn.removeActor(actor);
addItem((SpriteActor) actor);
}
// The state must be retrieved after getting actors from his init scene to restore verb cb properly.
for (int i = 0; i < jsonValueActors.size; i++) {
JsonValue jsonValueAct = jsonValueActors.get(i);
actorRef = new SceneActorRef(jsonValueAct.name);
SpriteActor actor = items.get(i);
actor.read(json, jsonValueAct);
}
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class UIActors method read.
@Override
public void read(Json json, JsonValue jsonData) {
actors.clear();
JsonValue jsonValueActors = jsonData.get("actors");
SceneActorRef actorRef;
// GET ACTORS FROM HIS INIT SCENE.
for (int i = 0; i < jsonValueActors.size; i++) {
JsonValue jsonValueAct = jsonValueActors.get(i);
actorRef = new SceneActorRef(jsonValueAct.name);
Scene sourceScn = w.getScene(actorRef.getSceneId());
BaseActor actor = sourceScn.getActor(actorRef.getActorId(), false);
sourceScn.removeActor(actor);
addActor((InteractiveActor) actor);
}
// to restore verb cb properly.
for (int i = 0; i < jsonValueActors.size; i++) {
JsonValue jsonValueAct = jsonValueActors.get(i);
InteractiveActor actor = actors.get(i);
actor.read(json, jsonValueAct);
}
}
Aggregations