Search in sources :

Example 6 with TileRef

use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.

the class TransitionsConfig method exportTiles.

/**
 * Export all tiles for the transition.
 *
 * @param nodeTransition The transition node (must not be <code>null</code>).
 * @param tilesRef The transition tiles ref (must not be <code>null</code>).
 */
private static void exportTiles(Xml nodeTransition, Collection<TileRef> tilesRef) {
    for (final TileRef tileRef : tilesRef) {
        final Xml nodeTileRef = TileConfig.exports(tileRef);
        nodeTransition.add(nodeTileRef);
    }
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 7 with TileRef

use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.

the class TransitionsExtractorImpl method checkTransition.

/**
 * Check the tile transition and add it to transitions collection if valid.
 *
 * @param transitions The transitions collection.
 * @param extractor The transition extractor.
 * @param tile The tile to check.
 */
private static void checkTransition(Map<Transition, Collection<TileRef>> transitions, MapTransitionExtractor extractor, Tile tile) {
    final Transition transition = extractor.getTransition(tile);
    if (transition != null) {
        getTiles(transitions, transition).add(new TileRef(tile));
        final Transition symetric = new Transition(transition.getType().getSymetric(), transition.getOut(), transition.getIn());
        getTiles(transitions, symetric).add(new TileRef(tile));
    }
}
Also used : TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 8 with TileRef

use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.

the class TransitionsExtractorTest method has.

/**
 * Check the transition with tile.
 *
 * @param transitions The transitions found.
 * @param type The transition type.
 * @param in The group in.
 * @param out The group out.
 * @param number The tile number.
 */
private void has(Map<Transition, Collection<TileRef>> transitions, TransitionType type, String in, String out, int number) {
    final Transition transition = new Transition(type, in, out);
    final TileRef tile = new TileRef(SHEET, number);
    Assert.assertTrue(transitions.get(transition).contains(tile));
}
Also used : TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 9 with TileRef

use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.

the class CircuitsExtractorImpl method checkCircuit.

/**
 * Check the tile circuit and add it to circuits collection if valid.
 *
 * @param circuits The circuits collection.
 * @param extractor The circuit extractor.
 * @param map The map reference.
 * @param tile The tile to check.
 */
private static void checkCircuit(Map<Circuit, Collection<TileRef>> circuits, MapCircuitExtractor extractor, MapTile map, Tile tile) {
    final Circuit circuit = extractor.getCircuit(tile);
    if (circuit != null) {
        final TileRef ref = new TileRef(tile);
        getTiles(circuits, circuit).add(ref);
        checkTransitionGroups(circuits, circuit, map, ref);
    }
}
Also used : TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 10 with TileRef

use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.

the class MapTileGroupModel method loadGroups.

/*
     * MapTileGroup
     */
@Override
public void loadGroups(Media groupsConfig) {
    this.groupsConfig = groupsConfig;
    groupTiles.clear();
    tilesGroup.clear();
    groupTypes.clear();
    for (final TileGroup group : TileGroupsConfig.imports(groupsConfig)) {
        final String name = group.getName();
        groupTiles.put(name, group.getTiles());
        groupTypes.put(name, group.getType());
        for (final TileRef tile : group.getTiles()) {
            tilesGroup.put(tile, name);
        }
    }
}
Also used : TileGroup(com.b3dgs.lionengine.game.feature.tile.TileGroup) TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Aggregations

TileRef (com.b3dgs.lionengine.game.feature.tile.TileRef)13 Xml (com.b3dgs.lionengine.io.Xml)5 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 TileGroup (com.b3dgs.lionengine.game.feature.tile.TileGroup)1 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)1 SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1