Search in sources :

Example 26 with SpriteActor

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();
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle) SpriteActor(com.bladecoder.engine.model.SpriteActor) World(com.bladecoder.engine.model.World) CharacterActor(com.bladecoder.engine.model.CharacterActor) DialogOption(com.bladecoder.engine.model.DialogOption)

Example 27 with SpriteActor

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;
}
Also used : SpriteTintTween(com.bladecoder.engine.anim.SpriteTintTween) SpriteActor(com.bladecoder.engine.model.SpriteActor)

Example 28 with SpriteActor

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;
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 29 with SpriteActor

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;
}
Also used : SpriteAlphaTween(com.bladecoder.engine.anim.SpriteAlphaTween) SpriteActor(com.bladecoder.engine.model.SpriteActor)

Example 30 with SpriteActor

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);
            }
        }
    }
}
Also used : Dialog(com.bladecoder.engine.model.Dialog) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Verb(com.bladecoder.engine.model.Verb) SpriteActor(com.bladecoder.engine.model.SpriteActor) CharacterActor(com.bladecoder.engine.model.CharacterActor) TextRenderer(com.bladecoder.engine.model.TextRenderer)

Aggregations

SpriteActor (com.bladecoder.engine.model.SpriteActor)32 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)16 BaseActor (com.bladecoder.engine.model.BaseActor)12 CharacterActor (com.bladecoder.engine.model.CharacterActor)10 Vector2 (com.badlogic.gdx.math.Vector2)8 Scene (com.bladecoder.engine.model.Scene)7 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)6 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)6 AnchorActor (com.bladecoder.engine.model.AnchorActor)5 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Verb (com.bladecoder.engine.model.Verb)5 Polygon (com.badlogic.gdx.math.Polygon)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)4 Rectangle (com.badlogic.gdx.math.Rectangle)3 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)3 Dialog (com.bladecoder.engine.model.Dialog)3 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)3 SceneLayer (com.bladecoder.engine.model.SceneLayer)3 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)3 World (com.bladecoder.engine.model.World)3