Search in sources :

Example 1 with CharacterActor

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

the class DefaultSceneScreen method sceneClick.

private void sceneClick(int button, int count) {
    World w = World.getInstance();
    w.getSceneCamera().getInputUnProject(viewport, unprojectTmp);
    Scene s = w.getCurrentScene();
    CharacterActor player = s.getPlayer();
    if (currentActor != null) {
        if (EngineLogger.debugMode()) {
            EngineLogger.debug(currentActor.toString());
        }
        // DOUBLE CLICK: Fastwalk when leaving scene.
        if (count > 1) {
            if (count == 2 && fastLeave && !recorder.isRecording() && player != null && currentActor.getVerb(Verb.LEAVE_VERB) != null) {
                player.fastWalk();
            }
            return;
        }
        actorClick(currentActor, button);
    } else if (player != null) {
        if (count > 1)
            return;
        if (s.getPlayer().getVerb("goto") != null) {
            runVerb(s.getPlayer(), "goto", null);
        } else {
            Vector2 pos = new Vector2(unprojectTmp.x, unprojectTmp.y);
            if (recorder.isRecording()) {
                recorder.add(pos);
            }
            player.goTo(pos, null, false);
        }
    }
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) World(com.bladecoder.engine.model.World) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 2 with CharacterActor

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

the class SayDialogAction method resume.

@Override
public void resume() {
    World w = World.getInstance();
    BaseActor actor = w.getCurrentScene().getActor(characterName, false);
    if (characterTurn) {
        characterTurn = false;
        if (previousAnim != null) {
            SpriteActor player = World.getInstance().getCurrentScene().getPlayer();
            player.startAnimation(previousAnim, null);
        }
        if (responseText != null) {
            Rectangle boundingRectangle = actor.getBBox().getBoundingRectangle();
            float x = boundingRectangle.getX() + boundingRectangle.getWidth() / 2;
            float y = boundingRectangle.getY() + boundingRectangle.getHeight();
            World.getInstance().getTextManager().addText(responseText, x, y, false, Text.Type.TALK, ((CharacterActor) actor).getTextColor(), null, actor.getId(), responseVoiceId, this);
            if (actor instanceof CharacterActor) {
                startTalkAnim((CharacterActor) actor);
            }
        } else {
            previousAnim = null;
            super.resume();
        }
    } else {
        if (actor instanceof SpriteActor && previousAnim != null) {
            ((SpriteActor) actor).startAnimation(previousAnim, null);
        }
        super.resume();
    }
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) World(com.bladecoder.engine.model.World) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 3 with CharacterActor

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

the class SetActorAttrAction method run.

@Override
public boolean run(VerbRunner cb) {
    Scene s = actor.getScene();
    BaseActor a = s.getActor(actor.getActorId(), true);
    if (a == null) {
        EngineLogger.error("SetActorAttr - Actor not found:" + this.actor.getActorId());
        return false;
    }
    if (visible != null)
        a.setVisible(visible);
    if (interaction != null) {
        if (a instanceof InteractiveActor)
            ((InteractiveActor) a).setInteraction(interaction);
        else
            EngineLogger.error("'Interaction' property not supported for actor:" + a.getId());
    }
    if (layer != null) {
        if (a instanceof InteractiveActor) {
            InteractiveActor iActor = (InteractiveActor) a;
            String oldLayer = iActor.getLayer();
            s.getLayer(oldLayer).remove(iActor);
            iActor.setLayer(layer);
            SceneLayer l = s.getLayer(layer);
            l.add(iActor);
            if (!l.isDynamic())
                l.orderByZIndex();
        } else
            EngineLogger.error("'layer' property not supported for actor:" + a.getId());
    }
    if (zIndex != null) {
        if (a instanceof InteractiveActor) {
            InteractiveActor iActor = (InteractiveActor) a;
            iActor.setZIndex(zIndex);
            SceneLayer l = s.getLayer(iActor.getLayer());
            if (!l.isDynamic())
                l.orderByZIndex();
        } else
            EngineLogger.error("'zIndex' property not supported for actor:" + a.getId());
    }
    if (scale != null) {
        if (a instanceof SpriteActor)
            ((SpriteActor) a).setScale(scale);
        else
            EngineLogger.error("'scale' property not supported for actor:" + a.getId());
    }
    if (rotation != null) {
        if (a instanceof SpriteActor)
            ((SpriteActor) a).setRot(rotation);
        else
            EngineLogger.error("'rotation' property not supported for actor:" + a.getId());
    }
    if (tint != null) {
        if (a instanceof SpriteActor)
            ((SpriteActor) a).setTint(tint);
        else
            EngineLogger.error("'tint' property not supported for actor:" + a.getId());
    }
    if (fakeDepth != null) {
        if (a instanceof SpriteActor) {
            ((SpriteActor) a).setFakeDepth(fakeDepth);
        } else
            EngineLogger.error("'fakeDepth' property not supported for actor:" + a.getId());
    }
    if (standAnimation != null) {
        if (a instanceof CharacterActor)
            ((CharacterActor) a).setStandAnim(standAnimation);
        else
            EngineLogger.error("'standAnimation' property not supported for actor:" + a.getId());
    }
    if (walkAnimation != null) {
        if (a instanceof CharacterActor)
            ((CharacterActor) a).setWalkAnim(walkAnimation);
        else
            EngineLogger.error("'walkAnimation' property not supported for actor:" + a.getId());
    }
    if (talkAnimation != null) {
        if (a instanceof CharacterActor)
            ((CharacterActor) a).setTalkAnim(talkAnimation);
        else
            EngineLogger.error("'talkAnimation' property not supported for actor:" + a.getId());
    }
    if (walkingSpeed != null) {
        if (a instanceof CharacterActor)
            ((CharacterActor) a).setWalkingSpeed(walkingSpeed);
        else
            EngineLogger.error("'walkingSpeed' property not supported for actor:" + a.getId());
    }
    if (uiActor != null) {
        if (a instanceof InteractiveActor) {
            if (uiActor)
                setUIActor(s, (InteractiveActor) a);
            else
                removeUIActor(s, (InteractiveActor) a);
        } else
            EngineLogger.error("'uiActor' property not supported for actor:" + a.getId());
    }
    return false;
}
Also used : SceneLayer(com.bladecoder.engine.model.SceneLayer) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 4 with CharacterActor

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

the class SetDialogOptionAttrAction method run.

@Override
public boolean run(VerbRunner cb) {
    final Scene s = actor.getScene();
    CharacterActor a = (CharacterActor) s.getActor(actor.getActorId(), true);
    Dialog d = a.getDialog(dialog);
    if (d == null) {
        EngineLogger.error("SetDialogOptionAttrAction: Dialog '" + dialog + "' not found");
        return false;
    }
    DialogOption o = d.getOptions().get(option);
    if (o == null) {
        EngineLogger.error("SetDialogOptionAttrAction: Option '" + option + "' not found");
        return false;
    }
    if (visible != null)
        o.setVisible(visible);
    return false;
}
Also used : Dialog(com.bladecoder.engine.model.Dialog) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor) DialogOption(com.bladecoder.engine.model.DialogOption)

Example 5 with CharacterActor

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

the class TalktoAction method run.

@Override
public boolean run(VerbRunner cb) {
    CharacterActor a = (CharacterActor) World.getInstance().getCurrentScene().getActor(actor, false);
    World.getInstance().setCurrentDialog(a.getDialog(dialog));
    return false;
}
Also used : CharacterActor(com.bladecoder.engine.model.CharacterActor)

Aggregations

CharacterActor (com.bladecoder.engine.model.CharacterActor)21 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)13 BaseActor (com.bladecoder.engine.model.BaseActor)11 SpriteActor (com.bladecoder.engine.model.SpriteActor)10 Dialog (com.bladecoder.engine.model.Dialog)7 Scene (com.bladecoder.engine.model.Scene)7 Verb (com.bladecoder.engine.model.Verb)7 DialogOption (com.bladecoder.engine.model.DialogOption)6 Vector2 (com.badlogic.gdx.math.Vector2)5 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Rectangle (com.badlogic.gdx.math.Rectangle)3 Action (com.bladecoder.engine.actions.Action)3 World (com.bladecoder.engine.model.World)3 LookAtAction (com.bladecoder.engine.actions.LookAtAction)2 SayAction (com.bladecoder.engine.actions.SayAction)2 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)2 AnchorActor (com.bladecoder.engine.model.AnchorActor)2 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)2 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)2 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)2