Search in sources :

Example 41 with InteractiveActor

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

the class RetroSceneScreen method drawDebugText.

private void drawDebugText(SpriteBatch batch) {
    World w = World.getInstance();
    w.getSceneCamera().getInputUnProject(worldViewport, unprojectTmp);
    Color color;
    sbTmp.setLength(0);
    if (EngineLogger.lastError != null) {
        sbTmp.append(EngineLogger.lastError);
        color = Color.RED;
    } else {
        sbTmp.append("( ");
        sbTmp.append((int) unprojectTmp.x);
        sbTmp.append(", ");
        sbTmp.append((int) unprojectTmp.y);
        sbTmp.append(") FPS:");
        sbTmp.append(Gdx.graphics.getFramesPerSecond());
        // sbTmp.append(" Density:");
        // sbTmp.append(Gdx.graphics.getDensity());
        // sbTmp.append(" UI Multiplier:");
        // sbTmp.append(DPIUtils.getSizeMultiplier());
        sbTmp.append(" UI STATE: ");
        sbTmp.append(state.toString());
        if (w.getCurrentScene().getPlayer() != null) {
            sbTmp.append(" Depth Scl: ");
            sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
        }
        color = Color.WHITE;
    }
    String strDebug = sbTmp.toString();
    textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, worldViewport.getScreenWidth(), Align.left, true);
    RectangleRenderer.draw(batch, 0, worldViewport.getScreenHeight() - textLayout.height - 10, textLayout.width, textLayout.height + 10, Color.BLACK);
    ui.getSkin().getFont("debug").draw(batch, textLayout, 0, worldViewport.getScreenHeight() - 5);
    // Draw actor states when debug
    if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {
        for (BaseActor a : w.getCurrentScene().getActors().values()) {
            Rectangle r = a.getBBox().getBoundingRectangle();
            sbTmp.setLength(0);
            sbTmp.append(a.getId());
            if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
                sbTmp.append(".").append(((InteractiveActor) a).getState());
            unprojectTmp.set(r.getX(), r.getY(), 0);
            w.getSceneCamera().scene2screen(worldViewport, unprojectTmp);
            if (w.getInventory().isVisible()) {
            // unprojectTmp.y += verbUI.getHeight();
            }
            ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
        }
    }
}
Also used : Color(com.badlogic.gdx.graphics.Color) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Rectangle(com.badlogic.gdx.math.Rectangle) BaseActor(com.bladecoder.engine.model.BaseActor) World(com.bladecoder.engine.model.World)

Example 42 with InteractiveActor

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

the class RetroSceneScreen method drawHotspots.

private void drawHotspots(SpriteBatch batch) {
    final World world = World.getInstance();
    for (BaseActor a : world.getCurrentScene().getActors().values()) {
        if (!(a instanceof InteractiveActor) || !a.isVisible() || a == world.getCurrentScene().getPlayer())
            continue;
        InteractiveActor ia = (InteractiveActor) a;
        if (!ia.canInteract())
            continue;
        Polygon p = a.getBBox();
        if (p == null) {
            EngineLogger.error("ERROR DRAWING HOTSPOT FOR: " + a.getId());
        }
        Rectangle r = a.getBBox().getBoundingRectangle();
        unprojectTmp.set(r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2, 0);
        world.getSceneCamera().scene2screen(worldViewport, unprojectTmp);
        if (world.getInventory().isVisible()) {
        // unprojectTmp.y += verbUI.getHeight();
        }
        if (ia.getDesc() == null) {
            float size = DPIUtils.ICON_SIZE * DPIUtils.getSizeMultiplier();
            Drawable drawable = ((TextureRegionDrawable) getUI().getSkin().getDrawable("circle")).tint(Color.RED);
            drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size, size);
        } else {
            BitmapFont font = getUI().getSkin().getFont("desc");
            String desc = ia.getDesc();
            if (desc.charAt(0) == I18N.PREFIX)
                desc = I18N.getString(desc.substring(1));
            textLayout.setText(font, desc);
            float textX = unprojectTmp.x - textLayout.width / 2;
            float textY = unprojectTmp.y + textLayout.height;
            RectangleRenderer.draw(batch, textX - 8, textY - textLayout.height - 8, textLayout.width + 16, textLayout.height + 16, Color.BLACK);
            font.draw(batch, textLayout, textX, textY);
        }
    }
}
Also used : InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Rectangle(com.badlogic.gdx.math.Rectangle) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) BaseActor(com.bladecoder.engine.model.BaseActor) World(com.bladecoder.engine.model.World) Polygon(com.badlogic.gdx.math.Polygon) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 43 with InteractiveActor

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

the class ActionCallbackSerialization method find.

private static String find(ActionCallback cb, Inventory inv) {
    for (int i = 0; i < inv.getNumItems(); i++) {
        InteractiveActor a = inv.get(i);
        String id = find(cb, a);
        if (id != null) {
            StringBuilder stringBuilder = new StringBuilder(INVENTORY_TAG);
            stringBuilder.append(SEPARATION_SYMBOL).append(id);
            return stringBuilder.toString();
        }
    }
    return null;
}
Also used : InteractiveActor(com.bladecoder.engine.model.InteractiveActor)

Aggregations

InteractiveActor (com.bladecoder.engine.model.InteractiveActor)43 BaseActor (com.bladecoder.engine.model.BaseActor)25 Scene (com.bladecoder.engine.model.Scene)17 SpriteActor (com.bladecoder.engine.model.SpriteActor)16 Verb (com.bladecoder.engine.model.Verb)14 CharacterActor (com.bladecoder.engine.model.CharacterActor)13 Vector2 (com.badlogic.gdx.math.Vector2)11 Rectangle (com.badlogic.gdx.math.Rectangle)7 Polygon (com.badlogic.gdx.math.Polygon)6 Action (com.bladecoder.engine.actions.Action)6 AnchorActor (com.bladecoder.engine.model.AnchorActor)6 Dialog (com.bladecoder.engine.model.Dialog)6 World (com.bladecoder.engine.model.World)6 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Color (com.badlogic.gdx.graphics.Color)4 LookAtAction (com.bladecoder.engine.actions.LookAtAction)4 SayAction (com.bladecoder.engine.actions.SayAction)4 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)4 DialogOption (com.bladecoder.engine.model.DialogOption)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)3