Search in sources :

Example 11 with CharacterActor

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;
}
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 12 with CharacterActor

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);
}
Also used : Action(com.bladecoder.engine.actions.Action) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor) Dialog(com.bladecoder.engine.model.Dialog) Verb(com.bladecoder.engine.model.Verb) BaseActor(com.bladecoder.engine.model.BaseActor) DialogOption(com.bladecoder.engine.model.DialogOption)

Example 13 with CharacterActor

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;
}
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 CharacterActor

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

Example 15 with CharacterActor

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

Aggregations

CharacterActor (com.bladecoder.engine.model.CharacterActor)21 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)13 BaseActor (com.bladecoder.engine.model.BaseActor)11 SpriteActor (com.bladecoder.engine.model.SpriteActor)10 Dialog (com.bladecoder.engine.model.Dialog)7 Scene (com.bladecoder.engine.model.Scene)7 Verb (com.bladecoder.engine.model.Verb)7 DialogOption (com.bladecoder.engine.model.DialogOption)6 Vector2 (com.badlogic.gdx.math.Vector2)5 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Rectangle (com.badlogic.gdx.math.Rectangle)3 Action (com.bladecoder.engine.actions.Action)3 World (com.bladecoder.engine.model.World)3 LookAtAction (com.bladecoder.engine.actions.LookAtAction)2 SayAction (com.bladecoder.engine.actions.SayAction)2 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)2 AnchorActor (com.bladecoder.engine.model.AnchorActor)2 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)2 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)2 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)2