Search in sources :

Example 21 with CharacterActor

use of com.bladecoder.engine.model.CharacterActor 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)

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