Search in sources :

Example 26 with Scene

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

the class PositionAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene s = actor.getScene();
    BaseActor a = s.getActor(actor.getActorId(), true);
    float x = a.getX();
    float y = a.getY();
    if (target != null) {
        Scene ts = target.getScene();
        BaseActor anchorActor = ts.getActor(target.getActorId(), false);
        x = anchorActor.getX();
        y = anchorActor.getY();
        if (anchorActor instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) anchorActor).getRefPoint();
            x += refPoint.x;
            y += refPoint.y;
        }
        if (position != null) {
            float scale = EngineAssetManager.getInstance().getScale();
            x += position.x * scale;
            y += position.y * scale;
        }
    } else if (position != null) {
        float scale = EngineAssetManager.getInstance().getScale();
        x = position.x * scale;
        y = position.y * scale;
    }
    a.setPosition(x, y);
    return false;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) Scene(com.bladecoder.engine.model.Scene)

Example 27 with Scene

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

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

the class TextAction method run.

@Override
public boolean run(VerbRunner cb) {
    if (text == null)
        return false;
    float x = TextManager.POS_CENTER, y = TextManager.POS_CENTER;
    if (target != null) {
        Scene ts = target.getScene();
        BaseActor anchorActor = ts.getActor(target.getActorId(), true);
        x = anchorActor.getX();
        y = anchorActor.getY();
        if (anchorActor instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) anchorActor).getRefPoint();
            x += refPoint.x;
            y += refPoint.y;
        }
        if (pos != null) {
            float scale = EngineAssetManager.getInstance().getScale();
            x += pos.x * scale;
            y += pos.y * scale;
        }
    } else if (pos != null) {
        float scale = EngineAssetManager.getInstance().getScale();
        if (pos.x != TextManager.POS_CENTER)
            x = pos.x * scale;
        if (pos.y != TextManager.POS_CENTER)
            y = pos.y * scale;
    } else {
        if (type == Text.Type.SUBTITLE) {
            x = y = TextManager.POS_SUBTITLE;
        }
    }
    World.getInstance().getTextManager().addText(text, x, y, queue, type, color, style, null, voiceId, wait ? cb : null);
    return wait;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) Scene(com.bladecoder.engine.model.Scene)

Example 29 with Scene

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

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

the class ScreenPositionAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene s = actor.getScene();
    BaseActor a = s.getActor(actor.getActorId(), true);
    if (position != null) {
        float scale = EngineAssetManager.getInstance().getScale();
        Viewport viewport = ((SceneScreen) BladeEngine.getAppUI().getScreen(Screens.SCENE_SCREEN)).getViewport();
        Vector3 v = new Vector3(position.x * scale, position.y * scale, 0);
        if (anchor == Anchor.CENTER) {
            v.x += viewport.getWorldWidth() / 2;
            v.y += viewport.getWorldHeight() / 2;
        } else if (anchor == Anchor.TOP_LEFT) {
            v.x += 0;
            v.y += viewport.getWorldHeight();
        } else if (anchor == Anchor.TOP_RIGHT) {
            v.x += viewport.getWorldWidth();
            v.y += viewport.getWorldHeight();
        } else if (anchor == Anchor.BOTTOM_RIGHT) {
            v.x += viewport.getWorldWidth();
            v.y += 0;
        } else if (anchor == Anchor.BOTTOM_LEFT) {
            v.x += 0;
            v.y += 0;
        } else if (anchor == Anchor.TOP) {
            v.x += viewport.getWorldWidth() / 2;
            v.y += viewport.getWorldHeight();
        } else if (anchor == Anchor.BOTTOM) {
            v.x += viewport.getWorldWidth() / 2;
            v.y += 0;
        } else if (anchor == Anchor.LEFT) {
            v.x += 0;
            v.y += viewport.getWorldHeight() / 2;
        } else if (anchor == Anchor.RIGHT) {
            v.x += viewport.getWorldWidth();
            v.y += viewport.getWorldHeight() / 2;
        }
        // viewport.project(v);
        v.x *= viewport.getScreenWidth() / viewport.getWorldWidth();
        v.y *= viewport.getScreenHeight() / viewport.getWorldHeight();
        // v.y = viewport.getScreenHeight() - v.y;
        v.y = Gdx.graphics.getHeight() - v.y;
        World.getInstance().getCurrentScene().getCamera().unproject(v, 0, 0, viewport.getScreenWidth(), viewport.getScreenHeight());
        a.setPosition(v.x, v.y);
    }
    return false;
}
Also used : SceneScreen(com.bladecoder.engine.ui.SceneScreen) Viewport(com.badlogic.gdx.utils.viewport.Viewport) Vector3(com.badlogic.gdx.math.Vector3) BaseActor(com.bladecoder.engine.model.BaseActor) Scene(com.bladecoder.engine.model.Scene)

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