Search in sources :

Example 11 with TileRef

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

the class MapTileTransitionModel method loadTransitions.

@Override
public void loadTransitions(Map<Transition, Collection<TileRef>> transitions) {
    this.transitions.clear();
    this.transitions.putAll(transitions);
    tiles.clear();
    for (final Entry<Transition, Collection<TileRef>> entry : this.transitions.entrySet()) {
        final Transition transition = entry.getKey();
        for (final TileRef tileRef : entry.getValue()) {
            if (!tiles.containsKey(tileRef)) {
                tiles.put(tileRef, new HashSet<Transition>());
            }
            tiles.get(tileRef).add(transition);
        }
        groupLinks.add(new GroupTransition(transition.getIn(), transition.getOut()));
        groupLinks.add(new GroupTransition(transition.getOut(), transition.getIn()));
    }
    transitiveGroup = new TransitiveGroup(map);
    transitiveGroup.load();
}
Also used : Collection(java.util.Collection) TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 12 with TileRef

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

the class CircuitsConfig method exportTiles.

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

Example 13 with TileRef

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

the class MapTileGroupModelTest method testCustom.

/**
 * Test the map tile with custom group.
 */
@Test
public void testCustom() {
    mapGroup.changeGroup(tile, "water");
    Assert.assertEquals(new TileRef(tile), mapGroup.getGroup("water").iterator().next());
    Assert.assertEquals("water", mapGroup.getGroup(tile));
    Assert.assertEquals("water", mapGroup.getGroup(new TileRef(0, 0)));
    Assert.assertEquals("water", mapGroup.getGroup(Integer.valueOf(0), 0));
    Assert.assertTrue(mapGroup.getGroups().containsAll(Arrays.asList("water")));
    mapGroup.changeGroup(tile, "tree");
    Assert.assertEquals(new TileRef(tile), mapGroup.getGroup("tree").iterator().next());
    Assert.assertEquals("tree", mapGroup.getGroup(tile));
    Assert.assertEquals("tree", mapGroup.getGroup(new TileRef(0, 0)));
    Assert.assertEquals("tree", mapGroup.getGroup(Integer.valueOf(0), 0));
    Assert.assertTrue(mapGroup.getGroups().containsAll(Arrays.asList("water", "tree")));
    mapGroup.changeGroup(tile, null);
    Assert.assertFalse(mapGroup.getGroup(MapTileGroupModel.NO_GROUP_NAME).iterator().hasNext());
    Assert.assertEquals(MapTileGroupModel.NO_GROUP_NAME, mapGroup.getGroup(tile));
    Assert.assertEquals(MapTileGroupModel.NO_GROUP_NAME, mapGroup.getGroup(new TileRef(0, 0)));
    Assert.assertEquals(MapTileGroupModel.NO_GROUP_NAME, mapGroup.getGroup(Integer.valueOf(0), 0));
}
Also used : TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef) Test(org.junit.Test)

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