Search in sources :

Example 91 with Xml

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

the class PathfindableConfigTest method testNoNode.

/**
 * Test without node.
 */
@Test
void testNoNode() {
    final Xml root = new Xml("test");
    final Media media = Medias.create("pathfindable.xml");
    root.save(media);
    assertTrue(PathfindableConfig.imports(new Configurer(media)).isEmpty());
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 92 with Xml

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

the class FovableConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Xml root = new Xml("test");
    root.add(FovableConfig.exports(1));
    final Media media = Medias.create("Object.xml");
    root.save(media);
    assertEquals(1, FovableConfig.imports(new Xml(media)));
    assertEquals(1, FovableConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 93 with Xml

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

the class FeaturableConfig method exportClass.

/**
 * Export the featurable node from class data.
 *
 * @param clazz The class name (must not be <code>null</code>).
 * @return The class node.
 * @throws LionEngineException If unable to export node.
 */
public static Xml exportClass(String clazz) {
    Check.notNull(clazz);
    final Xml node = new Xml(ATT_CLASS);
    node.setText(clazz);
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 94 with Xml

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

the class ForceConfig method exports.

/**
 * Export the force node from data.
 *
 * @param force The force reference (must not be <code>null</code>).
 * @return The force data.
 * @throws LionEngineException If unable to read node.
 */
public static Xml exports(Force force) {
    Check.notNull(force);
    final Xml node = new Xml(NODE_FORCE);
    node.writeDouble(ATT_VX, force.getDirectionHorizontal());
    node.writeDouble(ATT_VY, force.getDirectionVertical());
    node.writeDouble(ATT_VELOCITY, force.getVelocity());
    node.writeDouble(ATT_SENSIBILITY, force.getSensibility());
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 95 with Xml

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

the class ActionConfig method exports.

/**
 * Export the action node from data.
 *
 * @param config The config reference (must not be <code>null</code>).
 * @return The action node.
 * @throws LionEngineException If unable to save.
 */
public static Xml exports(ActionConfig config) {
    Check.notNull(config);
    final Xml nodeAction = new Xml(NODE_ACTION);
    nodeAction.writeString(ATT_NAME, config.getName());
    nodeAction.writeString(ATT_DESCRIPTION, config.getDescription());
    nodeAction.writeInteger(ATT_X, config.getX());
    nodeAction.writeInteger(ATT_Y, config.getY());
    nodeAction.writeInteger(ATT_WIDTH, config.getWidth());
    nodeAction.writeInteger(ATT_HEIGHT, config.getHeight());
    return nodeAction;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

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