Search in sources :

Example 31 with XmlReader

use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.

the class SizeConfig method imports.

/**
 * Import the size data from configurer.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The size data.
 * @throws LionEngineException If unable to read node.
 */
public static SizeConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_SIZE);
    final int width = node.getInteger(ATT_WIDTH);
    final int height = node.getInteger(ATT_HEIGHT);
    return new SizeConfig(width, height);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Example 32 with XmlReader

use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.

the class ActionsConfig method imports.

/**
 * Create the action data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @param id The id supplier to handle unique instance if needed (must not be <code>null</code>).
 * @return The allowed actions.
 * @throws LionEngineException If unable to read node.
 */
public static List<ActionRef> imports(XmlReader root, Function<Class<? extends Feature>, Feature> id) {
    Check.notNull(root);
    if (!root.hasNode(NODE_ACTIONS)) {
        return Collections.emptyList();
    }
    final XmlReader node = root.getChild(NODE_ACTIONS);
    return getRefs(node, id);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Example 33 with XmlReader

use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.

the class ActionsConfig method getRefs.

/**
 * Get all actions and their references.
 *
 * @param node The current node to check (must not be <code>null</code>).
 * @param id The id supplier to handle unique instance if needed (must not be <code>null</code>).
 * @return The actions found.
 */
private static List<ActionRef> getRefs(XmlReader node, Function<Class<? extends Feature>, Feature> id) {
    final Collection<XmlReader> children = node.getChildren(NODE_ACTION_REF);
    final List<ActionRef> actions = new ArrayList<>(children.size());
    for (final XmlReader action : children) {
        final String path = action.getString(ATT_PATH);
        final boolean cancel = action.getBoolean(false, ATT_CANCEL);
        final boolean unique = action.getBoolean(false, ATT_UNIQUE);
        actions.add(new ActionRef(path, cancel, getRefs(action, id), unique ? id : null));
    }
    children.clear();
    return actions;
}
Also used : ArrayList(java.util.ArrayList) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 34 with XmlReader

use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.

the class AttackerConfig method imports.

/**
 * Imports the config from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The attacker data.
 * @throws LionEngineException If unable to read node or invalid integer.
 */
public static AttackerConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_ATTACKER);
    final int delay = node.getInteger(0, ATT_DELAY);
    final int distanceMin = node.getInteger(0, ATT_DISTANCE_MIN);
    final int distanceMax = node.getInteger(0, ATT_DISTANCE_MAX);
    final int damagesMin = node.getInteger(0, ATT_DAMAGES_MIN);
    final int damagesMax = node.getInteger(0, ATT_DAMAGES_MAX);
    return new AttackerConfig(delay, distanceMin, distanceMax, damagesMin, damagesMax);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Example 35 with XmlReader

use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.

the class LayerableConfig method imports.

/**
 * Imports the layerable config from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The layerable data.
 * @throws LionEngineException If unable to read node or invalid integer.
 */
public static LayerableConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_LAYERABLE);
    final int layerRefresh = node.getInteger(ATT_REFRESH);
    final int layerDisplay = node.getInteger(ATT_DISPLAY);
    return new LayerableConfig(layerRefresh, layerDisplay);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Aggregations

XmlReader (com.b3dgs.lionengine.XmlReader)45 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)12 LionEngineException (com.b3dgs.lionengine.LionEngineException)6 HashSet (java.util.HashSet)6 Collection (java.util.Collection)4 Xml (com.b3dgs.lionengine.Xml)2 Configurer (com.b3dgs.lionengine.game.Configurer)2 DeviceAxis (com.b3dgs.lionengine.io.DeviceAxis)2 DeviceMapper (com.b3dgs.lionengine.io.DeviceMapper)2 Set (java.util.Set)2 Animation (com.b3dgs.lionengine.Animation)1 Check (com.b3dgs.lionengine.Check)1 Constant (com.b3dgs.lionengine.Constant)1 AnimationConfig (com.b3dgs.lionengine.game.AnimationConfig)1 Feature (com.b3dgs.lionengine.game.Feature)1 Orientation (com.b3dgs.lionengine.game.Orientation)1 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)1 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1