Search in sources :

Example 21 with Scene

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

the class SceneList method copy.

@Override
protected void copy() {
    Scene e = list.getSelected();
    if (e == null)
        return;
    clipboard = (Scene) ElementUtils.cloneElement(e);
    toolbar.disablePaste(false);
    // TRANSLATIONS
    Ctx.project.getI18N().putTranslationsInElement(clipboard);
}
Also used : Scene(com.bladecoder.engine.model.Scene) UndoDeleteScene(com.bladecoder.engineeditor.undo.UndoDeleteScene)

Example 22 with Scene

use of com.bladecoder.engine.model.Scene 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 23 with Scene

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

the class SceneActorInputPanel method sceneSelected.

private void sceneSelected() {
    String s = scene.getSelected();
    if (s == null || s.isEmpty()) {
        s = Ctx.project.getSelectedScene().getId();
    }
    Scene scn = World.getInstance().getScene(s);
    actor.setItems(getActorValues(scn));
}
Also used : Scene(com.bladecoder.engine.model.Scene)

Example 24 with Scene

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

the class MoveToSceneAction method run.

@Override
public boolean run(VerbRunner cb) {
    final Scene s = actor.getScene();
    final String actorId = actor.getActorId();
    final World w = World.getInstance();
    if (actorId == null) {
        // if called in a scene verb and no actor is specified, we do nothing
        EngineLogger.error(getClass() + ": No actor specified");
        return false;
    }
    InteractiveActor a = (InteractiveActor) s.getActor(actorId, false);
    s.removeActor(a);
    if (s == w.getCurrentScene() && a instanceof Disposable)
        ((Disposable) a).dispose();
    Scene ts = null;
    if (scene == null)
        ts = w.getCurrentScene();
    else
        ts = w.getScene(scene);
    // the scene is cached.
    if ((ts == w.getCurrentScene() || w.getCachedScene(ts.getId()) != null) && a instanceof AssetConsumer) {
        ((AssetConsumer) a).loadAssets();
        EngineAssetManager.getInstance().finishLoading();
        ((AssetConsumer) a).retrieveAssets();
    }
    ts.addActor(a);
    return false;
}
Also used : Disposable(com.badlogic.gdx.utils.Disposable) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) AssetConsumer(com.bladecoder.engine.assets.AssetConsumer) Scene(com.bladecoder.engine.model.Scene) World(com.bladecoder.engine.model.World)

Example 25 with Scene

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

the class PickUpAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene scn = this.actor.getScene();
    InteractiveActor actor = (InteractiveActor) scn.getActor(this.actor.getActorId(), false);
    if (actor == null) {
        EngineLogger.error("PickUpAction - Actor not found:" + this.actor.getActorId());
        return false;
    }
    scn.removeActor(actor);
    if (actor instanceof SpriteActor) {
        SpriteActor a = (SpriteActor) actor;
        if (scn != World.getInstance().getCurrentScene() && World.getInstance().getCachedScene(scn.getId()) == null) {
            a.loadAssets();
            EngineAssetManager.getInstance().finishLoading();
            a.retrieveAssets();
        }
        if (a.getRenderer() instanceof AnimationRenderer) {
            if (animation != null)
                a.startAnimation(animation, null);
            else if (((AnimationRenderer) a.getRenderer()).getAnimations().get(a.getId() + ".inventory") != null)
                a.startAnimation(a.getId() + ".inventory", null);
        }
        World.getInstance().getInventory().addItem(a);
    }
    return false;
}
Also used : InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) Scene(com.bladecoder.engine.model.Scene) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Aggregations

Scene (com.bladecoder.engine.model.Scene)35 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)18 BaseActor (com.bladecoder.engine.model.BaseActor)16 Verb (com.bladecoder.engine.model.Verb)9 Vector2 (com.badlogic.gdx.math.Vector2)8 CharacterActor (com.bladecoder.engine.model.CharacterActor)8 SpriteActor (com.bladecoder.engine.model.SpriteActor)8 Action (com.bladecoder.engine.actions.Action)6 World (com.bladecoder.engine.model.World)5 LookAtAction (com.bladecoder.engine.actions.LookAtAction)4 SayAction (com.bladecoder.engine.actions.SayAction)4 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)4 Dialog (com.bladecoder.engine.model.Dialog)4 DialogOption (com.bladecoder.engine.model.DialogOption)4 Polygon (com.badlogic.gdx.math.Polygon)3 AnchorActor (com.bladecoder.engine.model.AnchorActor)3 UndoDeleteScene (com.bladecoder.engineeditor.undo.UndoDeleteScene)3 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)2 SceneLayer (com.bladecoder.engine.model.SceneLayer)2 VerbRunner (com.bladecoder.engine.model.VerbRunner)2