use of com.b3dgs.lionengine.game.feature.tile.TileGroup in project lionengine by b3dgs.
the class UtilMap method setGroups.
/**
* Set the map tile groups.
*
* @param map The map reference.
*/
public static void setGroups(MapTile map) {
final Collection<TileGroup> groups = new ArrayList<>();
groups.add(new TileGroup(WATER, TileGroupType.PLAIN, Arrays.asList(new TileRef(SHEET, TILE_WATER))));
groups.add(new TileGroup(GROUND, TileGroupType.PLAIN, Arrays.asList(new TileRef(SHEET, TILE_GROUND))));
groups.add(new TileGroup(TREE, TileGroupType.PLAIN, Arrays.asList(new TileRef(SHEET, TILE_TREE))));
groups.add(new TileGroup(ROAD, TileGroupType.CIRCUIT, Arrays.asList(new TileRef(SHEET, TILE_ROAD))));
groups.add(new TileGroup(TRANSITION, TileGroupType.TRANSITION, Arrays.asList(new TileRef(SHEET, TILE_TRANSITION))));
groups.add(new TileGroup(TRANSITION2, TileGroupType.TRANSITION, Arrays.asList(new TileRef(SHEET, TILE_TRANSITION2))));
final Media config = Medias.create("groups.xml");
TileGroupsConfig.exports(config, groups);
final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
mapGroup.loadGroups(config);
Assert.assertTrue(config.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.tile.TileGroup 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);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.TileGroup in project lionengine by b3dgs.
the class MapTileGroupModelTest method testLoadMedia.
/**
* Test the map tile with loaded media.
*/
@Test
public void testLoadMedia() {
final Media configGroups = Medias.create("groups.xml");
final Collection<TileGroup> groups = new ArrayList<>();
groups.add(new TileGroup("water", TileGroupType.PLAIN, Arrays.asList(new TileRef(0, 0))));
TileGroupsConfig.exports(configGroups, groups);
mapGroup.loadGroups(configGroups);
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")));
Assert.assertEquals(TileGroupType.PLAIN, mapGroup.getType("water"));
Assert.assertEquals(TileGroupType.PLAIN, mapGroup.getType(tile));
}