Search in sources :

Example 16 with Verb

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

the class VerbList method paste.

@Override
protected void paste() {
    Verb newElement = (Verb) ElementUtils.cloneElement(clipboard);
    // Check for id duplicates
    String[] keys = new String[parent.getVerbs().size()];
    Verb[] values = parent.getVerbs().values().toArray(new Verb[0]);
    for (int i = 0; i < keys.length; i++) {
        keys[i] = values[i].getId();
    }
    newElement.setId(ElementUtils.getCheckedId(newElement.getId(), keys));
    int pos = list.getSelectedIndex() + 1;
    list.getItems().insert(pos, newElement);
    parent.addVerb(newElement);
    if (scopePanel.getScope().equals(ScopePanel.WORLD_SCOPE))
        Ctx.project.getI18N().extractStrings(null, null, newElement);
    else if (scopePanel.getScope().equals(ScopePanel.SCENE_SCOPE))
        Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), null, newElement);
    else
        Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), newElement);
    list.setSelectedIndex(pos);
    list.invalidateHierarchy();
    Ctx.project.setModified();
}
Also used : UndoDeleteVerb(com.bladecoder.engineeditor.undo.UndoDeleteVerb) Verb(com.bladecoder.engine.model.Verb)

Example 17 with Verb

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

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

the class CheckInteractionVerbs method visit.

@Override
public void visit(BaseActor a) {
    if (a instanceof InteractiveActor) {
        ia = (InteractiveActor) a;
        hasLookat = false;
        hasPickup = false;
        hasTalkto = false;
        hasLeave = false;
        hasEnterExit = false;
        hasUse = false;
        if (ia.getInteraction()) {
            HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
            for (Verb v : verbs.values()) checkVerb(v);
            if (hasLeave || hasEnterExit)
                return;
            // discard inventory actors
            if (hasLookat) {
                if (ia instanceof SpriteActor) {
                    SpriteActor sa = (SpriteActor) ia;
                    if (sa.getRenderer() instanceof AtlasRenderer) {
                        AtlasRenderer r = (AtlasRenderer) sa.getRenderer();
                        HashMap<String, AnimationDesc> animations = r.getAnimations();
                        if (animations.size() == 0) {
                            EditorLogger.error("CheckInteractionVerbs: Actor with no animations! - " + sa.getScene().getId() + "." + sa.getId());
                        }
                        if (animations.get(r.getInitAnimation()).source.contains("inventory")) {
                            if (!hasUse)
                                EditorLogger.msg("CheckInteractionVerbs: Inventory item should has default 'use' - " + sa.getScene().getId() + "." + sa.getId());
                            return;
                        }
                    }
                }
            }
            // check for lookat and pickup/talk verbs
            if (!hasLookat || (!hasPickup && !hasTalkto)) {
                String msg = "CheckInteractionVerbs: " + a.getScene().getId() + "." + a.getId();
                if (!hasLookat)
                    EditorLogger.error(msg);
                else
                    EditorLogger.msg(msg);
            }
        }
    }
}
Also used : AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Verb(com.bladecoder.engine.model.Verb) SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationDesc(com.bladecoder.engine.anim.AnimationDesc)

Example 19 with Verb

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

the class RunVerbAction method getVerb.

private Verb getVerb() {
    Verb v = null;
    Scene s = World.getInstance().getCurrentScene();
    if (actor != null) {
        InteractiveActor a = (InteractiveActor) s.getActor(actor, true);
        v = a.getVerbManager().getVerb(verb, a.getState(), target);
    }
    if (v == null) {
        v = s.getVerbManager().getVerb(verb, s.getState(), target);
    }
    if (v == null) {
        v = World.getInstance().getVerbManager().getVerb(verb, null, target);
    }
    if (v == null)
        EngineLogger.error("Cannot find VERB: " + verb + " for ACTOR: " + actor);
    return v;
}
Also used : Verb(com.bladecoder.engine.model.Verb) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Scene(com.bladecoder.engine.model.Scene)

Example 20 with Verb

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

the class ModelTools method fixSaySubtitleActor.

public static final void fixSaySubtitleActor() {
    Map<String, Scene> scenes = World.getInstance().getScenes();
    for (Scene scn : scenes.values()) {
        Map<String, BaseActor> actors = scn.getActors();
        HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
        for (Verb v : verbs.values()) {
            ArrayList<Action> actions = v.getActions();
            for (Action act : actions) {
                if (act instanceof SayAction) {
                    try {
                        String stringValue = ActionUtils.getStringValue(act, "type");
                        if (stringValue.equals("SUBTITLE"))
                            ActionUtils.setParam(act, "actor", "$PLAYER");
                    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                        EditorLogger.printStackTrace(e);
                        return;
                    }
                }
            }
        }
        for (BaseActor a : actors.values()) {
            if (a instanceof InteractiveActor) {
                InteractiveActor ia = (InteractiveActor) a;
                verbs = ia.getVerbManager().getVerbs();
                for (Verb v : verbs.values()) {
                    ArrayList<Action> actions = v.getActions();
                    for (Action act : actions) {
                        if (act instanceof SayAction) {
                            try {
                                String stringValue = ActionUtils.getStringValue(act, "type");
                                if (stringValue.equals("SUBTITLE"))
                                    ActionUtils.setParam(act, "actor", "$PLAYER");
                            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                                EditorLogger.printStackTrace(e);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
    Ctx.project.setModified();
}
Also used : LookAtAction(com.bladecoder.engine.actions.LookAtAction) SayAction(com.bladecoder.engine.actions.SayAction) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Action(com.bladecoder.engine.actions.Action) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SayAction(com.bladecoder.engine.actions.SayAction) Scene(com.bladecoder.engine.model.Scene) Verb(com.bladecoder.engine.model.Verb) BaseActor(com.bladecoder.engine.model.BaseActor)

Aggregations

Verb (com.bladecoder.engine.model.Verb)26 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)14 Scene (com.bladecoder.engine.model.Scene)9 Action (com.bladecoder.engine.actions.Action)8 BaseActor (com.bladecoder.engine.model.BaseActor)8 CharacterActor (com.bladecoder.engine.model.CharacterActor)7 Dialog (com.bladecoder.engine.model.Dialog)6 SpriteActor (com.bladecoder.engine.model.SpriteActor)5 LookAtAction (com.bladecoder.engine.actions.LookAtAction)4 SayAction (com.bladecoder.engine.actions.SayAction)4 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)4 DialogOption (com.bladecoder.engine.model.DialogOption)4 TextRenderer (com.bladecoder.engine.model.TextRenderer)4 UndoDeleteVerb (com.bladecoder.engineeditor.undo.UndoDeleteVerb)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 AbstractControlAction (com.bladecoder.engine.actions.AbstractControlAction)2 AbstractIfAction (com.bladecoder.engine.actions.AbstractIfAction)2 CommentAction (com.bladecoder.engine.actions.CommentAction)2 DisableActionAction (com.bladecoder.engine.actions.DisableActionAction)2