Search in sources :

Example 96 with Xml

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

the class ActionsConfig method exports.

/**
 * Export the action.
 *
 * @param node The xml node (must not be <code>null</code>).
 * @param action The action to export (must not be <code>null</code>).
 * @throws LionEngineException If unable to write node.
 */
private static void exports(Xml node, ActionRef action) {
    final Xml nodeAction = node.createChild(NODE_ACTION_REF);
    nodeAction.writeString(ATT_PATH, action.getPath());
    for (final ActionRef ref : action.getRefs()) {
        exports(nodeAction, ref);
    }
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 97 with Xml

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

the class AttackerConfig method exports.

/**
 * Exports the node from config.
 *
 * @param config The config reference (must not be <code>null</code>).
 * @return The attacker node.
 * @throws LionEngineException If unable to read node or invalid integer.
 */
public static Xml exports(AttackerConfig config) {
    Check.notNull(config);
    final Xml node = new Xml(NODE_ATTACKER);
    node.writeInteger(ATT_DELAY, config.getDelay());
    node.writeInteger(ATT_DISTANCE_MIN, config.getDistance().getMin());
    node.writeInteger(ATT_DISTANCE_MAX, config.getDistance().getMax());
    node.writeInteger(ATT_DAMAGES_MIN, config.getDamages().getMin());
    node.writeInteger(ATT_DAMAGES_MAX, config.getDamages().getMax());
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 98 with Xml

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

the class LayerableConfig method exports.

/**
 * Exports the layerable node from config.
 *
 * @param config The config reference (must not be <code>null</code>).
 * @return The layerable node.
 * @throws LionEngineException If unable to read node or invalid integer.
 */
public static Xml exports(LayerableConfig config) {
    Check.notNull(config);
    final Xml node = new Xml(NODE_LAYERABLE);
    node.writeInteger(ATT_REFRESH, config.getLayerRefresh());
    node.writeInteger(ATT_DISPLAY, config.getLayerDisplay());
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 99 with Xml

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

the class SurfaceConfig method exports.

/**
 * Create the surface data from node.
 *
 * @param config The config reference (must not be <code>null</code>).
 * @return The node data.
 * @throws LionEngineException If unable to write node.
 */
public static Xml exports(SurfaceConfig config) {
    Check.notNull(config);
    final Xml node = new Xml(NODE_SURFACE);
    node.writeString(ATT_IMAGE, config.getImage());
    config.getIcon().ifPresent(icon -> node.writeString(ATT_ICON, icon));
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 100 with Xml

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

the class CollidableFramedConfig method exports.

/**
 * Create an XML node from a collision.
 *
 * @param root The node root (must not be <code>null</code>).
 * @param collisions The collisions reference (must not be <code>null</code>).
 */
public static void exports(Xml root, Map<Integer, Collection<Collision>> collisions) {
    Check.notNull(root);
    Check.notNull(collisions);
    for (final Entry<Integer, Collection<Collision>> entry : collisions.entrySet()) {
        for (final Collision collision : entry.getValue()) {
            final Xml node = root.createChild(NODE_COLLISION_FRAMED);
            node.writeInteger(ATT_NUMBER, entry.getKey().intValue());
            node.writeInteger(ATT_OFFSETX, collision.getOffsetX());
            node.writeInteger(ATT_OFFSETY, collision.getOffsetY());
            node.writeInteger(ATT_WIDTH, collision.getWidth());
            node.writeInteger(ATT_HEIGHT, collision.getHeight());
            node.writeBoolean(ATT_MIRROR, collision.hasMirror());
        }
    }
}
Also used : Xml(com.b3dgs.lionengine.Xml) Collision(com.b3dgs.lionengine.game.feature.collidable.Collision) Collection(java.util.Collection)

Aggregations

Xml (com.b3dgs.lionengine.Xml)133 Test (org.junit.jupiter.api.Test)73 Media (com.b3dgs.lionengine.Media)63 Configurer (com.b3dgs.lionengine.game.Configurer)25 Setup (com.b3dgs.lionengine.game.feature.Setup)11 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 Animation (com.b3dgs.lionengine.Animation)4 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)4 Feature (com.b3dgs.lionengine.game.Feature)3 Force (com.b3dgs.lionengine.game.Force)3 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)3 Services (com.b3dgs.lionengine.game.feature.Services)3 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)3 Map (java.util.Map)3 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Origin (com.b3dgs.lionengine.Origin)1 UtilAssert.assertThrows (com.b3dgs.lionengine.UtilAssert.assertThrows)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Orientation (com.b3dgs.lionengine.game.Orientation)1