Search in sources :

Example 1 with Orientation

use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.

the class CollisionConstraintConfig method imports.

/**
 * Create the collision constraint data from node.
 *
 * @param node The node reference (must not be <code>null</code>).
 * @return The collision constraint data.
 * @throws LionEngineException If error when reading node.
 */
public static CollisionConstraint imports(Xml node) {
    Check.notNull(node);
    final CollisionConstraint constraint = new CollisionConstraint();
    if (node.hasChild(NODE_CONSTRAINT)) {
        for (final Xml current : node.getChildren(NODE_CONSTRAINT)) {
            final Orientation orientation = Orientation.valueOf(current.readString(ATT_ORIENTATION));
            final String group = current.readString(ATT_GROUP);
            constraint.add(orientation, group);
        }
    }
    return constraint;
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) Orientation(com.b3dgs.lionengine.game.Orientation)

Example 2 with Orientation

use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.

the class CollisionConstraintConfig method exports.

/**
 * Export the collision constraint as a node.
 *
 * @param root The node root (must not be <code>null</code>).
 * @param constraint The collision constraint to export (must not be <code>null</code>).
 * @throws LionEngineException If error on writing.
 */
public static void exports(Xml root, CollisionConstraint constraint) {
    Check.notNull(root);
    Check.notNull(constraint);
    for (final Entry<Orientation, Collection<String>> entry : constraint.getConstraints().entrySet()) {
        final Orientation orientation = entry.getKey();
        for (final String group : entry.getValue()) {
            final Xml current = root.createChild(NODE_CONSTRAINT);
            current.writeEnum(ATT_ORIENTATION, orientation);
            current.writeString(ATT_GROUP, group);
        }
    }
}
Also used : Xml(com.b3dgs.lionengine.Xml) Collection(java.util.Collection) Orientation(com.b3dgs.lionengine.game.Orientation)

Example 3 with Orientation

use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.

the class OrientableModel method pointTo.

@Override
public void pointTo(int dtx, int dty) {
    final int tx = map.getInTileX(transformable);
    final int ty = map.getInTileY(transformable);
    final Orientation next = Orientation.get(tx, ty, dtx, dty);
    if (next != null) {
        orientation = next;
    }
}
Also used : Orientation(com.b3dgs.lionengine.game.Orientation)

Example 4 with Orientation

use of com.b3dgs.lionengine.game.Orientation in project lionengine by b3dgs.

the class CollisionConstraintConfig method imports.

/**
 * Create the collision constraint data from node.
 *
 * @param node The node reference (must not be <code>null</code>).
 * @return The collision constraint data.
 * @throws LionEngineException If error when reading node.
 */
public static CollisionConstraint imports(XmlReader node) {
    Check.notNull(node);
    final CollisionConstraint constraint = new CollisionConstraint();
    if (node.hasNode(NODE_CONSTRAINT)) {
        final Collection<XmlReader> children = node.getChildren(NODE_CONSTRAINT);
        for (final XmlReader current : children) {
            final Orientation orientation = current.getEnum(Orientation.class, ATT_ORIENTATION);
            final String group = current.getString(ATT_GROUP);
            constraint.add(orientation, group);
        }
        children.clear();
    }
    return constraint;
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader) Orientation(com.b3dgs.lionengine.game.Orientation)

Aggregations

Orientation (com.b3dgs.lionengine.game.Orientation)4 Xml (com.b3dgs.lionengine.Xml)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Xml (com.b3dgs.lionengine.io.Xml)1 Collection (java.util.Collection)1