Search in sources :

Example 11 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.

the class I18NHandler method putTranslationsInElement.

public void putTranslationsInElement(BaseActor a) {
    if (a instanceof InteractiveActor) {
        InteractiveActor ia = (InteractiveActor) a;
        // 1. DESC attribute
        ia.setDesc(getTranslation(ia.getDesc()));
        // 2. ACTIONS
        HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
        for (Verb v : verbs.values()) putTranslationsInElement(v, false);
        // 3. DIALOGS
        if (a instanceof CharacterActor) {
            HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
            if (dialogs != null) {
                for (Dialog d : dialogs.values()) putTranslationsInElement(d);
            }
        }
        // 4. Text for TextRenderer
        if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof TextRenderer) {
            TextRenderer r = (TextRenderer) ((SpriteActor) a).getRenderer();
            r.setText(getTranslation(r.getText()));
        }
    }
}
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)

Example 12 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.

the class ActorAnimationInputPanel method actorSelected.

private void actorSelected() {
    String s = actor.getSelected();
    SpriteActor a = null;
    if (Ctx.project.getSelectedActor() instanceof SpriteActor)
        a = (SpriteActor) Ctx.project.getSelectedActor();
    ArrayList<String> values = new ArrayList<String>();
    if (s != null && !s.isEmpty()) {
        a = (SpriteActor) Ctx.project.getSelectedScene().getActor(s, false);
    }
    if (a != null && a.getRenderer() instanceof AnimationRenderer) {
        HashMap<String, AnimationDesc> animations = ((AnimationRenderer) a.getRenderer()).getAnimations();
        if (!isMandatory()) {
            values.add("");
        }
        for (AnimationDesc anim : animations.values()) {
            values.add(anim.id);
            String flipped = AnimationRenderer.getFlipId(anim.id);
            if (!flipped.isEmpty()) {
                values.add(flipped);
            }
        }
    }
    String[] array = values.toArray(new String[values.size()]);
    Arrays.sort(array);
    animation.setItems(array);
    if (values.size() > 0)
        animation.setSelected("");
}
Also used : ArrayList(java.util.ArrayList) SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationDesc(com.bladecoder.engine.anim.AnimationDesc) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 13 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor 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;
}
Also used : InteractiveActor(com.bladecoder.engine.model.InteractiveActor) ArrayList(java.util.ArrayList) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 14 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.

the class CanvasDrawer method drawSelectedActor.

public void drawSelectedActor(BaseActor selectedActor) {
    // Gdx.gl20.glLineWidth(3);
    Gdx.gl20.glEnable(GL20.GL_BLEND);
    // Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    drawer.setProjectionMatrix(camera.combined);
    if (selectedActor instanceof AnchorActor) {
        drawer.begin(ShapeRenderer.ShapeType.Line);
        drawer.setColor(MOUSESELECTION_STROKE_COLOR);
        drawer.rect(selectedActor.getX() - Scene.ANCHOR_RADIUS, selectedActor.getY() - Scene.ANCHOR_RADIUS, Scene.ANCHOR_RADIUS * 2, Scene.ANCHOR_RADIUS * 2);
        drawer.end();
    } else {
        Polygon p = selectedActor.getBBox();
        Rectangle rect = p.getBoundingRectangle();
        drawer.begin(ShapeRenderer.ShapeType.Filled);
        drawer.setColor(MOUSESELECTION_FILL_COLOR);
        drawer.rect(rect.x, rect.y, rect.width, rect.height);
        drawer.end();
        drawer.begin(ShapeRenderer.ShapeType.Line);
        drawer.setColor(MOUSESELECTION_STROKE_COLOR);
        drawer.rect(rect.x, rect.y, rect.width, rect.height);
        // DRAW SELECTION BOUNDS
        if ((!(selectedActor instanceof SpriteActor) || !((SpriteActor) selectedActor).isBboxFromRenderer()) && !(selectedActor instanceof AnchorActor)) {
            float[] verts = selectedActor.getBBox().getTransformedVertices();
            for (int i = 0; i < verts.length; i += 2) drawer.rect(verts[i] - CORNER_DIST / 2, verts[i + 1] - CORNER_DIST / 2, CORNER_DIST, CORNER_DIST);
        }
        // DRAW REFPOINT
        if (selectedActor instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) selectedActor).getRefPoint();
            float orgX = selectedActor.getX() + refPoint.x;
            float orgY = selectedActor.getY() + refPoint.y;
            drawer.line(orgX - Scene.ANCHOR_RADIUS, orgY, orgX + Scene.ANCHOR_RADIUS, orgY);
            drawer.line(orgX, orgY - Scene.ANCHOR_RADIUS, orgX, orgY + Scene.ANCHOR_RADIUS);
        }
        drawer.end();
    }
}
Also used : AnchorActor(com.bladecoder.engine.model.AnchorActor) Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Rectangle(com.badlogic.gdx.math.Rectangle) SpriteActor(com.bladecoder.engine.model.SpriteActor) Polygon(com.badlogic.gdx.math.Polygon)

Example 15 with SpriteActor

use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.

the class ScnWidget method setSelectedFA.

public void setSelectedFA(String selFA) {
    if (selectedActor instanceof SpriteActor && ((SpriteActor) selectedActor).getRenderer() instanceof AnimationRenderer) {
        AnimationRenderer s = (AnimationRenderer) ((SpriteActor) selectedActor).getRenderer();
        if (selFA == null || (s.getAnimations().get(selFA) == null && s.getAnimations().get(AnimationRenderer.getFlipId(selFA)) == null)) {
            selFA = s.getInitAnimation();
        }
        if (selFA != null && (s.getAnimations().get(selFA) != null || s.getAnimations().get(AnimationRenderer.getFlipId(selFA)) != null)) {
            setAnimationRenderer(selectedActor, s.getAnimations().get(selFA));
            String animInScene = selFA;
            if (!inScene && s.getInitAnimation() != null)
                animInScene = s.getInitAnimation();
            try {
                ((SpriteActor) selectedActor).startAnimation(animInScene, Tween.Type.REPEAT, Tween.INFINITY, null);
            } catch (Exception e) {
                setAnimationRenderer(selectedActor, null);
                s.getAnimations().remove(selFA);
            }
        } else {
            setAnimationRenderer(selectedActor, null);
        }
    } else {
        setAnimationRenderer(selectedActor, null);
    }
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

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