use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class SayDialogAction method run.
@Override
public boolean run(VerbRunner cb) {
World w = World.getInstance();
if (w.getCurrentDialog() == null || w.getCurrentDialog().getCurrentOption() == null) {
EngineLogger.debug("SayDialogAction WARNING: Current dialog doesn't found.");
return false;
}
setVerbCb(cb);
DialogOption o = w.getCurrentDialog().getCurrentOption();
String playerText = o.getText();
responseText = o.getResponseText();
responseVoiceId = o.getResponseVoiceId();
characterName = w.getCurrentDialog().getActor();
characterTurn = true;
previousAnim = null;
// If the player or the character is talking restore to 'stand' pose
restoreStandPose(w.getCurrentScene().getPlayer());
if (w.getCurrentScene().getActor(characterName, false) instanceof SpriteActor)
restoreStandPose((CharacterActor) w.getCurrentScene().getActor(characterName, false));
if (playerText != null) {
CharacterActor player = w.getCurrentScene().getPlayer();
Rectangle boundingRectangle = player.getBBox().getBoundingRectangle();
float x = boundingRectangle.getX() + boundingRectangle.getWidth() / 2;
float y = boundingRectangle.getY() + boundingRectangle.getHeight();
w.getTextManager().addText(playerText, x, y, false, Text.Type.TALK, player.getTextColor(), null, player.getId(), o.getVoiceId(), this);
startTalkAnim(player);
} else {
resume();
}
return getWait();
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class TintAnimAction method run.
@Override
public boolean run(VerbRunner cb) {
SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actor, true);
SpriteTintTween t = new SpriteTintTween();
t.start(a, repeat, count, color, speed, interpolation, wait ? cb : null);
a.addTween(t);
return wait;
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class AnimationAction method run.
@Override
public boolean run(VerbRunner cb) {
// EngineLogger.debug(MessageFormat.format("ANIMATION_ACTION: {0}.{1}", animation.getActorId(), animation.getAnimationId()));
String actorId = animation.getActorId();
SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actorId, true);
String anim = animation.getAnimationId();
if (keepDirection) {
String c = ((AnimationRenderer) a.getRenderer()).getCurrentAnimationId();
if (anim.endsWith(AnimationRenderer.LEFT) && c.endsWith(AnimationRenderer.RIGHT) || anim.endsWith(AnimationRenderer.RIGHT) && c.endsWith(AnimationRenderer.LEFT)) {
anim = AnimationRenderer.getFlipId(anim);
}
}
a.startAnimation(anim, repeat, count, wait ? cb : null);
return wait;
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class AlphaAnimAction method run.
@Override
public boolean run(VerbRunner cb) {
SpriteActor a = (SpriteActor) World.getInstance().getCurrentScene().getActor(actor, true);
SpriteAlphaTween t = new SpriteAlphaTween();
t.start(a, repeat, count, alpha, speed, interpolation, wait ? cb : null);
a.addTween(t);
return wait;
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class I18NHandler method extractStrings.
public void extractStrings(String sceneid, BaseActor a) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// 1. DESC attribute
if (ia.getDesc() != null && !ia.getDesc().isEmpty() && ia.getDesc().charAt(0) != I18N.PREFIX) {
String key = genKey(sceneid, a.getId(), "desc");
String value = ia.getDesc();
ia.setDesc(key);
setTranslation(key, value);
}
// 2. ACTIONS
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) extractStrings(sceneid, a.getId(), v);
// 3. DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null)
for (Dialog d : dialogs.values()) extractStrings(sceneid, a.getId(), d);
}
// 4. Text for TextRenderer
if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof TextRenderer) {
TextRenderer r = (TextRenderer) ((SpriteActor) a).getRenderer();
String v = r.getText();
if (v != null && !v.isEmpty() && v.charAt(0) != I18N.PREFIX) {
String key = genKey(sceneid, a.getId(), "text");
r.setText(key, r.getText());
setTranslation(key, v);
}
}
}
}
Aggregations