Search in sources :

Example 16 with MapTileGroupModel

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

the class CircuitsConfigTest method testExportsImports.

/**
 * Test exports imports.
 *
 * @throws IOException If error.
 */
@Test
void testExportsImports() throws IOException {
    final Media config = UtilMapTransition.createTransitions();
    final MapTile map = UtilMap.createMap(7);
    map.getFeature(MapTileTransition.class).loadTransitions(config);
    UtilMap.fill(map, UtilMap.TILE_GROUND);
    UtilMap.fill(map, UtilMap.TILE_ROAD, UtilMap.TILE_ROAD, 3);
    final MapTileGame map3 = new MapTileGame();
    map3.addFeature(new MapTileGroupModel());
    map3.create(1, 1, 3, 3);
    final CircuitsExtractor extractor = new CircuitsExtractorImpl();
    final Map<Circuit, Collection<Integer>> circuits = extractor.getCircuits(Arrays.asList(map, map3));
    final Media media = Medias.create("circuit.xml");
    CircuitsConfig.exports(media, circuits);
    final Map<Circuit, Collection<Integer>> imported = CircuitsConfig.imports(media);
    assertEquals(circuits, imported);
    assertTrue(media.getFile().delete());
    assertTrue(config.getFile().delete());
    final Media sheets = Medias.create("sheets.xml");
    TileSheetsConfig.exports(sheets, 1, 1, Arrays.asList("sheet.png"));
    final Media groups = Medias.create("groups.xml");
    TileGroupsConfig.exports(groups, Collections.emptyList());
    CircuitsConfig.exports(media, Arrays.asList(Medias.create("level.png")), sheets, groups);
    assertTrue(sheets.getFile().delete());
    assertTrue(groups.getFile().delete());
    assertTrue(media.getFile().delete());
}
Also used : MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) Collection(java.util.Collection) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 17 with MapTileGroupModel

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

the class TransitionsExtractorImpl method getTransitions.

/*
     * TransitionsExtractor
     */
@Override
public Map<Transition, Collection<Integer>> getTransitions(Collection<Media> levels, Media sheetsConfig, Media groupsConfig) {
    final Collection<MapTile> mapsSet = new HashSet<>(levels.size());
    for (final Media level : levels) {
        final MapTileGame map = new MapTileGame();
        map.create(level, sheetsConfig);
        final MapTileGroup mapGroup = new MapTileGroupModel();
        mapGroup.loadGroups(groupsConfig);
        map.addFeature(mapGroup);
        mapsSet.add(map);
    }
    return getTransitions(mapsSet);
}
Also used : MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) HashSet(java.util.HashSet)

Example 18 with MapTileGroupModel

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

the class CircuitsExtractorImpl method getCircuits.

/*
     * CircuitsExtractor
     */
@Override
public Map<Circuit, Collection<Integer>> getCircuits(Collection<Media> levels, Media sheetsConfig, Media groupsConfig) {
    final Collection<MapTile> mapsSet = new HashSet<>(levels.size());
    for (final Media level : levels) {
        final MapTileGame map = new MapTileGame();
        map.create(level, sheetsConfig);
        final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
        final MapTileTransition mapTransition = map.addFeatureAndGet(new MapTileTransitionModel());
        mapGroup.loadGroups(groupsConfig);
        mapTransition.loadTransitions(levels, sheetsConfig, groupsConfig);
        mapsSet.add(map);
    }
    return getCircuits(mapsSet);
}
Also used : MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition) Media(com.b3dgs.lionengine.Media) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTileTransitionModel(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) HashSet(java.util.HashSet)

Example 19 with MapTileGroupModel

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

the class MapGeneratorImpl method generateMap.

/*
     * MapGenerator
     */
@Override
public MapTile generateMap(GeneratorParameter parameters, Collection<Media> levels, Media sheetsConfig, Media groupsConfig) {
    final MapTileGame map = new MapTileGame();
    map.loadSheets(sheetsConfig);
    final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
    final MapTileTransition mapTransition = map.addFeatureAndGet(new MapTileTransitionModel());
    final MapTileCircuit mapCircuit = map.addFeatureAndGet(new MapTileCircuitModel());
    mapGroup.loadGroups(groupsConfig);
    mapTransition.loadTransitions(levels, sheetsConfig, groupsConfig);
    mapCircuit.loadCircuits(levels, sheetsConfig, groupsConfig);
    parameters.apply(map);
    return map;
}
Also used : MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition) MapTileCircuit(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuit) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTileTransitionModel(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel) MapTileCircuitModel(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuitModel)

Aggregations

MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)19 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)11 Media (com.b3dgs.lionengine.Media)9 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)7 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)4 MapTileTransitionModel (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel)4 Collection (java.util.Collection)4 Camera (com.b3dgs.lionengine.game.feature.Camera)3 MapTileCircuitModel (com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuitModel)3 MapTileViewerModel (com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 Factory (com.b3dgs.lionengine.game.feature.Factory)2 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 Transformable (com.b3dgs.lionengine.game.feature.Transformable)2 MapTilePathModel (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePathModel)2 Pathfindable (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable)2 HashSet (java.util.HashSet)2