Search in sources :

Example 26 with BaseActor

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

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

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

the class PositionAnimAction method run.

@Override
public boolean run(VerbRunner cb) {
    float scale = EngineAssetManager.getInstance().getScale();
    BaseActor a = World.getInstance().getCurrentScene().getActor(actor, true);
    float x = a.getX();
    float y = a.getY();
    if (target != null) {
        BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
        x = target.getX();
        y = target.getY();
        if (target instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) target).getRefPoint();
            x += refPoint.x;
            y += refPoint.y;
        }
        if (pos != null) {
            x += pos.x * scale;
            y += pos.y * scale;
        }
    } else if (pos != null) {
        x = pos.x * scale;
        y = pos.y * scale;
    }
    if (speed == 0 || !(a instanceof SpriteActor)) {
        a.setPosition(x, y);
        return false;
    } else {
        // WARNING: only spriteactors support animation
        float s;
        if (mode != null && mode == Mode.SPEED) {
            Vector2 p0 = new Vector2(a.getX(), a.getY());
            s = p0.dst(x, y) / (scale * speed);
        } else {
            s = speed;
        }
        SpritePosTween t = new SpritePosTween();
        t.start((SpriteActor) a, repeat, count, x, y, s, interpolation, wait ? cb : null);
        ((SpriteActor) a).addTween(t);
    }
    return wait;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) SpritePosTween(com.bladecoder.engine.anim.SpritePosTween)

Example 29 with BaseActor

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

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

the class GotoAction method run.

@Override
public boolean run(VerbRunner cb) {
    CharacterActor actor = (CharacterActor) World.getInstance().getCurrentScene().getActor(this.actor, false);
    float x = actor.getX();
    float y = actor.getY();
    if (target != null) {
        BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
        x = target.getX();
        y = target.getY();
        if (target instanceof InteractiveActor) {
            Vector2 refPoint = ((InteractiveActor) target).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();
        x = pos.x * scale;
        y = pos.y * scale;
    }
    actor.goTo(new Vector2(x, y), wait ? cb : null, ignoreWalkZone);
    return wait;
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Aggregations

BaseActor (com.bladecoder.engine.model.BaseActor)40 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)26 Scene (com.bladecoder.engine.model.Scene)16 SpriteActor (com.bladecoder.engine.model.SpriteActor)13 CharacterActor (com.bladecoder.engine.model.CharacterActor)12 Vector2 (com.badlogic.gdx.math.Vector2)8 Verb (com.bladecoder.engine.model.Verb)8 Polygon (com.badlogic.gdx.math.Polygon)7 World (com.bladecoder.engine.model.World)7 Rectangle (com.badlogic.gdx.math.Rectangle)5 Action (com.bladecoder.engine.actions.Action)5 AnchorActor (com.bladecoder.engine.model.AnchorActor)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 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)4 SceneLayer (com.bladecoder.engine.model.SceneLayer)4 Color (com.badlogic.gdx.graphics.Color)3