use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class ActorInputPanel method getValues.
private static String[] getValues(boolean mandatory, Param.Type type) {
Map<String, BaseActor> actors = Ctx.project.getSelectedScene().getActors();
ArrayList<BaseActor> filteredActors = new ArrayList<BaseActor>();
for (BaseActor a : actors.values()) {
if (type == Param.Type.CHARACTER_ACTOR) {
if (a instanceof CharacterActor)
filteredActors.add(a);
} else if (type == Param.Type.INTERACTIVE_ACTOR) {
if (a instanceof InteractiveActor)
filteredActors.add(a);
} else if (type == Param.Type.SPRITE_ACTOR) {
if (a instanceof SpriteActor)
filteredActors.add(a);
} else {
filteredActors.add(a);
}
}
String[] result = new String[filteredActors.size() + 1];
// Add player variable to the list
result[0] = Scene.VAR_PLAYER;
for (int i = 0; i < filteredActors.size(); i++) {
result[i + 1] = filteredActors.get(i).getId();
}
Arrays.sort(result);
return result;
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class ModelWalker method walk.
public void walk(World w) {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (StartVisitor sv : startVisitors) sv.start(w);
for (Scene scn : scenes.values()) {
for (SceneVisitor sv : sceneVisitors) sv.visit(scn);
Map<String, BaseActor> actors = scn.getActors();
// SCENE VERBS
HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
for (VerbVisitor vv : verbVisitors) vv.visit(scn, null, v);
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
for (ActionVisitor av : actionVisitors) av.visit(scn, null, v, act);
}
}
for (BaseActor a : actors.values()) {
for (ActorVisitor av : actorVisitors) av.visit(a);
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// ACTOR VERBS
verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
for (VerbVisitor vv : verbVisitors) vv.visit(scn, ia, v);
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
for (ActionVisitor av : actionVisitors) av.visit(scn, ia, v, act);
}
}
}
// DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null) {
for (Dialog d : dialogs.values()) {
for (DialogVisitor dv : dialogVisitors) dv.visit((CharacterActor) a, d);
ArrayList<DialogOption> options = d.getOptions();
for (DialogOption o : options) {
for (DialogOptionVisitor ov : optionVisitors) ov.visit((CharacterActor) a, d, o);
}
}
}
}
}
}
for (EndVisitor ev : endVisitors) ev.end(w);
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class SceneActorInputPanel method getActorValues.
private String[] getActorValues(Scene scn) {
Map<String, BaseActor> actors = scn.getActors();
ArrayList<BaseActor> filteredActors = new ArrayList<BaseActor>();
for (BaseActor a : actors.values()) {
if (type == Param.Type.SCENE_CHARACTER_ACTOR) {
if (a instanceof CharacterActor)
filteredActors.add(a);
} else if (type == Param.Type.SCENE_INTERACTIVE_ACTOR) {
if (a instanceof InteractiveActor)
filteredActors.add(a);
} else if (type == Param.Type.SCENE_SPRITE_ACTOR) {
if (a instanceof SpriteActor)
filteredActors.add(a);
} else {
filteredActors.add(a);
}
}
String[] result = new String[isMandatory() ? filteredActors.size() + 1 : filteredActors.size() + 2];
// Add player variable to the list
result[0] = Scene.VAR_PLAYER;
if (!isMandatory())
result[filteredActors.size() + 1] = "";
for (int i = 0; i < filteredActors.size(); i++) {
result[i + 1] = filteredActors.get(i).getId();
}
Arrays.sort(result);
return result;
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class LookAtAction method run.
@Override
public boolean run(VerbRunner cb) {
// EngineLogger.debug("LOOKAT ACTION");
InteractiveActor a = (InteractiveActor) World.getInstance().getCurrentScene().getActor(actor, true);
if (World.getInstance().getInventory().get(actor) == null) {
CharacterActor player = World.getInstance().getCurrentScene().getPlayer();
if (direction != null && player != null)
player.lookat(direction.getDirection());
else if (a != null && player != null) {
Rectangle bbox = a.getBBox().getBoundingRectangle();
player.lookat(new Vector2(bbox.x, bbox.y));
}
}
if (text != null) {
String actorId = World.getInstance().getCurrentScene().getPlayer() != null ? World.getInstance().getCurrentScene().getPlayer().getId() : null;
World.getInstance().getTextManager().addText(text, TextManager.POS_SUBTITLE, TextManager.POS_SUBTITLE, false, Text.Type.SUBTITLE, null, null, actorId, voiceId, wait ? cb : null);
return wait;
}
return false;
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class SayAction method resume.
@Override
public void resume() {
if (type == Text.Type.TALK) {
CharacterActor a = (CharacterActor) World.getInstance().getCurrentScene().getActor(actor, false);
a.startAnimation(previousAnim, Tween.Type.SPRITE_DEFINED, 0, null);
}
if (getWait())
super.resume();
}
Aggregations