Search in sources :

Example 1 with SceneLayer

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

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

the class EditLayerDialog method inputsToModel.

@Override
protected void inputsToModel(boolean create) {
    if (create) {
        e = new SceneLayer();
    }
    // TODO if the name is changed. Change all actor layer name.
    e.setName(name.getText());
    e.setVisible(Boolean.parseBoolean(visible.getText()));
    e.setDynamic(Boolean.parseBoolean(dynamic.getText()));
    e.setParallaxMultiplier(Float.parseFloat(parallax.getText()));
    if (create) {
        parent.getLayers().add(e);
    }
    // TODO UNDO OP
    // UndoOp undoOp = new UndoAddElement(doc, e);
    // Ctx.project.getUndoStack().add(undoOp);
    Ctx.project.setModified();
}
Also used : SceneLayer(com.bladecoder.engine.model.SceneLayer)

Example 3 with SceneLayer

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

the class EditSceneDialog method inputsToModel.

@Override
protected void inputsToModel(boolean create) {
    if (create) {
        e = new Scene();
        // CREATE DEFAULT LAYERS: BG, DYNAMIC, FG
        SceneLayer l = new SceneLayer();
        l.setName("foreground");
        l.setVisible(true);
        l.setDynamic(false);
        e.addLayer(l);
        l = new SceneLayer();
        l.setName("dynamic");
        l.setVisible(true);
        l.setDynamic(true);
        e.addLayer(l);
        l = new SceneLayer();
        l.setName("background");
        l.setVisible(true);
        l.setDynamic(false);
        e.addLayer(l);
    } else {
        parent.getScenes().remove(e.getId());
    }
    e.setId(ElementUtils.getCheckedId(id.getText(), World.getInstance().getScenes().keySet().toArray(new String[0])));
    e.setBackgroundAtlas(backgroundAtlas.getText());
    e.setBackgroundRegionId(backgroundRegion.getText());
    boolean dv = Boolean.parseBoolean(depthVector.getText());
    if (dv == true && e.getDepthVector() == null) {
        // create depth vector
        e.setDepthVector(new Vector2(World.getInstance().getHeight(), 0));
    } else if (dv == false && e.getDepthVector() != null) {
        // Remove depth vector
        e.setDepthVector(null);
    }
    e.setState(state.getText());
    MusicDesc md = null;
    if (music.getText() != null) {
        md = new MusicDesc();
        md.setFilename(music.getText());
        md.setLoop(Boolean.parseBoolean(loopMusic.getText()));
        md.setVolume(Float.parseFloat(volumeMusic.getText()));
        md.setInitialDelay(Float.parseFloat(initialMusicDelay.getText()));
        md.setRepeatDelay(Float.parseFloat(repeatMusicDelay.getText()));
        md.setStopWhenLeaving(Boolean.parseBoolean(stopWhenLeaving.getText()));
    }
    e.setMusicDesc(md);
    e.setSceneSize(Param.parseVector2(sceneSize.getText()));
    parent.addScene(e);
    if (parent.getScenes().size() == 1)
        parent.setInitScene(e.getId());
    // UNDO OP
    if (create) {
        Ctx.project.getUndoStack().add(new UndoCreateScene(e));
    } else {
        Ctx.project.getUndoStack().add(new UndoEditScene(e));
    }
    Ctx.project.setModified(this, Project.NOTIFY_ELEMENT_CREATED, null, e);
}
Also used : UndoEditScene(com.bladecoder.engineeditor.undo.UndoEditScene) SceneLayer(com.bladecoder.engine.model.SceneLayer) Vector2(com.badlogic.gdx.math.Vector2) UndoCreateScene(com.bladecoder.engineeditor.undo.UndoCreateScene) UndoCreateScene(com.bladecoder.engineeditor.undo.UndoCreateScene) Scene(com.bladecoder.engine.model.Scene) UndoEditScene(com.bladecoder.engineeditor.undo.UndoEditScene) MusicDesc(com.bladecoder.engine.model.MusicDesc)

Example 4 with SceneLayer

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

the class LayerList method toggleVisibility.

private void toggleVisibility() {
    SceneLayer e = list.getSelected();
    if (e == null)
        return;
    e.setVisible(!e.isVisible());
    Ctx.project.setModified();
}
Also used : SceneLayer(com.bladecoder.engine.model.SceneLayer)

Example 5 with SceneLayer

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

the class LayerList method up.

private void up() {
    int pos = list.getSelectedIndex();
    if (pos == -1 || pos == 0)
        return;
    Array<SceneLayer> items = list.getItems();
    SceneLayer e = items.get(pos);
    SceneLayer e2 = items.get(pos - 1);
    parent.getLayers().set(pos, e2);
    parent.getLayers().set(pos - 1, e);
    items.removeIndex(pos);
    items.insert(pos - 1, e);
    list.setSelectedIndex(pos - 1);
    upBtn.setDisabled(list.getSelectedIndex() == 0);
    downBtn.setDisabled(list.getSelectedIndex() == list.getItems().size - 1);
    Ctx.project.setModified();
}
Also used : SceneLayer(com.bladecoder.engine.model.SceneLayer)

Aggregations

SceneLayer (com.bladecoder.engine.model.SceneLayer)10 BaseActor (com.bladecoder.engine.model.BaseActor)4 Vector2 (com.badlogic.gdx.math.Vector2)3 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)3 SpriteActor (com.bladecoder.engine.model.SpriteActor)3 CharacterActor (com.bladecoder.engine.model.CharacterActor)2 Scene (com.bladecoder.engine.model.Scene)2 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)2 Color (com.badlogic.gdx.graphics.Color)1 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)1 Polygon (com.badlogic.gdx.math.Polygon)1 Vector3 (com.badlogic.gdx.math.Vector3)1 Task (com.badlogic.gdx.utils.Timer.Task)1 AnchorActor (com.bladecoder.engine.model.AnchorActor)1 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)1 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)1 MusicDesc (com.bladecoder.engine.model.MusicDesc)1 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)1 ParticleRenderer (com.bladecoder.engine.model.ParticleRenderer)1 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)1