Search in sources :

Example 6 with VerbRunner

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

the class ChooseAction method run.

@Override
public boolean run(VerbRunner cb) {
    VerbRunner v = (VerbRunner) cb;
    int startIp = v.getIP();
    int ip0 = startIp + 1;
    final List<Action> actions = v.getActions();
    int ip = skipControlIdBlock(actions, startIp);
    int numActions = ip - startIp - 1;
    if (numActions <= 0)
        return false;
    switch(chooseCriteria) {
        case ITERATE:
            chooseCount++;
            break;
        case RANDOM:
            chooseCount = MathUtils.random(0, numActions - 1);
            break;
        case CYCLE:
            chooseCount = (chooseCount + 1) % numActions;
            break;
    }
    v.setIP(ip);
    if (chooseCount < numActions) {
        return actions.get(ip0 + chooseCount).run(v);
    }
    return false;
}
Also used : VerbRunner(com.bladecoder.engine.model.VerbRunner)

Example 7 with VerbRunner

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

the class IfSceneAttrAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene s = (scene != null && !scene.isEmpty()) ? World.getInstance().getScene(scene) : World.getInstance().getCurrentScene();
    if (attr == SceneAttr.STATE) {
        if (!ActionUtils.compareNullStr(value, s.getState())) {
            gotoElse((VerbRunner) cb);
        }
    } else if (attr == SceneAttr.CURRENT_SCENE) {
        String scn = World.getInstance().getCurrentScene().getId();
        if (!ActionUtils.compareNullStr(value, scn)) {
            gotoElse((VerbRunner) cb);
        }
    } else if (attr == SceneAttr.PLAYER) {
        CharacterActor player = s.getPlayer();
        String id = player != null ? player.getId() : null;
        if (!ActionUtils.compareNullStr(value, id)) {
            gotoElse((VerbRunner) cb);
        }
    }
    return false;
}
Also used : VerbRunner(com.bladecoder.engine.model.VerbRunner) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 8 with VerbRunner

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

the class InkManager method cancel.

@Override
public void cancel() {
    ArrayList<Action> actions = getActions();
    for (Action c : actions) {
        if (c instanceof VerbRunner)
            ((VerbRunner) c).cancel();
    }
    ip = actions.size();
}
Also used : Action(com.bladecoder.engine.actions.Action) VerbRunner(com.bladecoder.engine.model.VerbRunner)

Aggregations

VerbRunner (com.bladecoder.engine.model.VerbRunner)8 BaseActor (com.bladecoder.engine.model.BaseActor)2 Scene (com.bladecoder.engine.model.Scene)2 Action (com.bladecoder.engine.actions.Action)1 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)1 CharacterActor (com.bladecoder.engine.model.CharacterActor)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 SpriteActor (com.bladecoder.engine.model.SpriteActor)1