Search in sources :

Example 36 with XmlReader

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

the class SurfaceConfig method imports.

/**
 * Create the surface data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The surface data.
 * @throws LionEngineException If unable to read node.
 */
public static SurfaceConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_SURFACE);
    final String surface = node.getString(ATT_IMAGE);
    final String icon = node.getStringDefault(null, ATT_ICON);
    return new SurfaceConfig(surface, icon);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Example 37 with XmlReader

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

the class CollisionConfig method imports.

/**
 * Create the collision data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The collisions data.
 * @throws LionEngineException If unable to read node.
 */
public static CollisionConfig imports(XmlReader root) {
    Check.notNull(root);
    final Map<String, Collision> collisions = new HashMap<>(0);
    final Collection<XmlReader> children;
    if (root.hasNode(NODE_COLLISIONS)) {
        children = root.getChild(NODE_COLLISIONS).getChildren(NODE_COLLISION);
    } else {
        children = Collections.emptyList();
    }
    for (final XmlReader node : children) {
        final String coll = node.getString(ATT_NAME);
        final Collision collision = createCollision(node);
        collisions.put(coll, collision);
    }
    children.clear();
    return new CollisionConfig(collisions);
}
Also used : HashMap(java.util.HashMap) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 38 with XmlReader

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

the class ProducibleConfig method imports.

/**
 * Create the producible data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The producible data.
 * @throws LionEngineException If unable to read node.
 */
public static ProducibleConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_PRODUCIBLE);
    final SizeConfig size = SizeConfig.imports(root);
    final int time = node.getInteger(ATT_STEPS);
    return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
Also used : SizeConfig(com.b3dgs.lionengine.game.SizeConfig) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 39 with XmlReader

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

the class LauncherConfig method imports.

/**
 * Import the launcher data from node.
 *
 * @param node The node reference (must not be <code>null</code>).
 * @return The launcher data.
 * @throws LionEngineException If unable to read node.
 */
public static LauncherConfig imports(XmlReader node) {
    Check.notNull(node);
    final Collection<XmlReader> children = node.getChildren(LaunchableConfig.NODE_LAUNCHABLE);
    final Collection<LaunchableConfig> launchables = new ArrayList<>(children.size());
    for (final XmlReader launchable : children) {
        launchables.add(LaunchableConfig.imports(launchable));
    }
    children.clear();
    final int level = node.getInteger(0, ATT_LEVEL);
    final int delay = node.getInteger(0, ATT_DELAY);
    final boolean mirrorable = node.getBoolean(true, ATT_MIRRORABLE);
    return new LauncherConfig(level, delay, mirrorable, launchables);
}
Also used : ArrayList(java.util.ArrayList) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 40 with XmlReader

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

the class TransitionsConfig method importTiles.

/**
 * Import all tiles from their nodes.
 *
 * @param nodesTile The tiles nodes (must not be <code>null</code>).
 * @return The imported tiles.
 */
private static Collection<Integer> importTiles(Collection<XmlReader> nodesTile) {
    final Collection<Integer> tiles = new HashSet<>(nodesTile.size());
    for (final XmlReader nodeTile : nodesTile) {
        final Integer tile = Integer.valueOf(TileConfig.imports(nodeTile));
        tiles.add(tile);
    }
    return tiles;
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader) HashSet(java.util.HashSet)

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