Search in sources :

Example 6 with MapTileGroup

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup 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 7 with MapTileGroup

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup 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 8 with MapTileGroup

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

the class CircuitsExtractorImpl method checkTransitionGroups.

/**
 * Check transitions groups, and create compatible circuit on the fly.
 *
 * @param circuits The circuits collection.
 * @param circuit The circuit found.
 * @param map The map reference.
 * @param number The tile number to add.
 */
private static void checkTransitionGroups(Map<Circuit, Collection<Integer>> circuits, Circuit circuit, MapTile map, Integer number) {
    final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
    final MapTileTransition mapTransition = map.getFeature(MapTileTransition.class);
    final String group = mapGroup.getGroup(number);
    for (final String groupTransition : mapGroup.getGroups()) {
        if (mapTransition.getTransitives(group, groupTransition).size() == 1) {
            final Circuit transitiveCircuit = new Circuit(circuit.getType(), group, groupTransition);
            getTiles(circuits, transitiveCircuit).add(number);
        }
    }
}
Also used : MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)

Example 9 with MapTileGroup

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup 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)

Example 10 with MapTileGroup

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

the class Scene method load.

@Override
public void load() {
    map.create(Medias.create("forest.png"));
    final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
    final MapTilePath mapPath = map.addFeatureAndGet(new MapTilePathModel());
    camera.setView(VIEW_X, VIEW_Y, getWidth() - VIEW_X, getHeight() - VIEW_Y, getHeight());
    camera.setLimits(map);
    camera.setLocation(160, 96);
    map.addFeature(new MapTileViewerModel(services));
    handler.add(map);
    mapGroup.loadGroups(Medias.create("groups.xml"));
    mapPath.loadPathfinding(Medias.create("pathfinding.xml"));
    cursor.addImage(0, Medias.create("cursor.png"));
    cursor.addImage(1, Medias.create("cursor_order.png"));
    cursor.load();
    cursor.setGrid(map.getTileWidth(), map.getTileHeight());
    cursor.setSync(mouse);
    cursor.setViewer(camera);
    final Factory factory = services.create(Factory.class);
    final Media media = Medias.create("Hud.xml");
    final Hud hud = factory.create(media);
    handler.add(hud);
    final Selector selector = services.get(Selector.class);
    selector.addFeatureAndGet(new LayerableModel(4));
    selector.setClickableArea(camera);
    selector.setSelectionColor(ColorRgba.GREEN);
    selector.setClickSelection(MouseAwt.LEFT);
    final Featurable peon = factory.create(Medias.create("Peon.xml"));
    peon.getFeature(Pathfindable.class).setLocation(20, 10);
    handler.add(peon);
    transformable = peon.getFeature(Transformable.class);
    tick.start();
}
Also used : Media(com.b3dgs.lionengine.Media) Factory(com.b3dgs.lionengine.game.feature.Factory) Transformable(com.b3dgs.lionengine.game.feature.Transformable) LayerableModel(com.b3dgs.lionengine.game.feature.LayerableModel) MapTilePath(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePath) MapTilePathModel(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePathModel) Pathfindable(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable) MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) Hud(com.b3dgs.lionengine.game.feature.collidable.selector.Hud) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTileViewerModel(com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Selector(com.b3dgs.lionengine.game.feature.collidable.selector.Selector)

Aggregations

MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)13 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)8 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)6 Media (com.b3dgs.lionengine.Media)4 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)4 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)4 MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)4 Test (org.junit.jupiter.api.Test)3 Factory (com.b3dgs.lionengine.game.feature.Factory)2 Transformable (com.b3dgs.lionengine.game.feature.Transformable)2 MapTileTransitionModel (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel)2 MapTileViewerModel (com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel)2 HashSet (java.util.HashSet)2 Viewer (com.b3dgs.lionengine.Viewer)1 Camera (com.b3dgs.lionengine.game.feature.Camera)1 CameraTracker (com.b3dgs.lionengine.game.feature.CameraTracker)1 Featurable (com.b3dgs.lionengine.game.feature.Featurable)1 LayerableModel (com.b3dgs.lionengine.game.feature.LayerableModel)1 Hud (com.b3dgs.lionengine.game.feature.collidable.selector.Hud)1 Selector (com.b3dgs.lionengine.game.feature.collidable.selector.Selector)1