Search in sources :

Example 31 with SpriteActor

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

the class I18NHandler method getUsedKeys.

private void getUsedKeys(Scene s, ArrayList<String> usedKeys) {
    for (Verb v : s.getVerbManager().getVerbs().values()) getUsedKeys(v, usedKeys);
    for (BaseActor a : s.getActors().values()) {
        if (a instanceof InteractiveActor) {
            InteractiveActor ia = (InteractiveActor) a;
            if (ia.getDesc() != null && !ia.getDesc().isEmpty() && ia.getDesc().charAt(0) == I18N.PREFIX)
                usedKeys.add(ia.getDesc().substring(1));
            for (Verb v : ia.getVerbManager().getVerbs().values()) getUsedKeys(v, usedKeys);
            if (a instanceof CharacterActor) {
                CharacterActor ca = (CharacterActor) a;
                if (ca.getDialogs() != null) {
                    for (Dialog d : ca.getDialogs().values()) {
                        for (DialogOption o : d.getOptions()) {
                            if (o.getText() != null && !o.getText().isEmpty() && o.getText().charAt(0) == I18N.PREFIX)
                                usedKeys.add(o.getText().substring(1));
                            if (o.getResponseText() != null && !o.getResponseText().isEmpty() && o.getResponseText().charAt(0) == I18N.PREFIX)
                                usedKeys.add(o.getResponseText().substring(1));
                        }
                    }
                }
            }
            if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof TextRenderer) {
                TextRenderer r = (TextRenderer) ((SpriteActor) a).getRenderer();
                String k = r.getText();
                if (k != null && !k.isEmpty() && k.charAt(0) == I18N.PREFIX)
                    usedKeys.add(k.substring(1));
            }
        }
    }
}
Also used : Dialog(com.bladecoder.engine.model.Dialog) Verb(com.bladecoder.engine.model.Verb) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) CharacterActor(com.bladecoder.engine.model.CharacterActor) DialogOption(com.bladecoder.engine.model.DialogOption) TextRenderer(com.bladecoder.engine.model.TextRenderer)

Example 32 with SpriteActor

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

the class InventoryUI method draw.

@Override
public void draw(Batch batch, float alpha) {
    Inventory inventory = World.getInstance().getInventory();
    if (!inventory.isVisible()) {
        setVisible(false);
        return;
    }
    if (style.background != null) {
        style.background.draw(batch, getX(), getY(), getWidth(), getHeight());
    }
    // DRAW ITEMS
    int capacity = cols * rows;
    for (int i = 0; i < inventory.getNumItems() && i < capacity; i++) {
        SpriteActor a = inventory.get(i);
        ActorRenderer r = a.getRenderer();
        float size = (tileSize - rowSpace) / (r.getHeight() > r.getWidth() ? r.getHeight() : r.getWidth());
        float x = i % cols;
        float y = (rows - 1) - i / cols;
        if (style.itemBackground != null) {
            style.itemBackground.draw(batch, getX() + x * tileSize + x * rowSpace + margin, getY() + y * tileSize + y * rowSpace + margin, tileSize, tileSize);
        }
        r.draw((SpriteBatch) batch, getX() + x * tileSize + x * rowSpace + tileSize / 2 + margin, getY() + (tileSize - r.getHeight() * size) / 2 + y * tileSize + y * rowSpace + margin, size, 0f, a.getTint());
    }
    super.draw(batch, alpha);
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) ActorRenderer(com.bladecoder.engine.model.ActorRenderer) Inventory(com.bladecoder.engine.model.Inventory)

Aggregations

SpriteActor (com.bladecoder.engine.model.SpriteActor)32 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)16 BaseActor (com.bladecoder.engine.model.BaseActor)12 CharacterActor (com.bladecoder.engine.model.CharacterActor)10 Vector2 (com.badlogic.gdx.math.Vector2)8 Scene (com.bladecoder.engine.model.Scene)7 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)6 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)6 AnchorActor (com.bladecoder.engine.model.AnchorActor)5 TextRenderer (com.bladecoder.engine.model.TextRenderer)5 Verb (com.bladecoder.engine.model.Verb)5 Polygon (com.badlogic.gdx.math.Polygon)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)4 Rectangle (com.badlogic.gdx.math.Rectangle)3 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)3 Dialog (com.bladecoder.engine.model.Dialog)3 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)3 SceneLayer (com.bladecoder.engine.model.SceneLayer)3 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)3 World (com.bladecoder.engine.model.World)3