Search in sources :

Example 1 with MapTileTransition

use of com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition 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 ref The tile ref to add.
 */
private static void checkTransitionGroups(Map<Circuit, Collection<TileRef>> circuits, Circuit circuit, MapTile map, TileRef ref) {
    final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
    final MapTileTransition mapTransition = map.getFeature(MapTileTransition.class);
    final String group = mapGroup.getGroup(ref);
    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(ref);
        }
    }
}
Also used : MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)

Example 2 with MapTileTransition

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

the class PrefMapRegion method apply.

/*
     * Preference
     */
@Override
public void apply(MapTile map) {
    final MapTileTransition mapTransition = map.getFeature(MapTileTransition.class);
    final int sx = area.getInTileX();
    final int sy = area.getInTileY();
    final int ex = UtilMath.clamp(area.getInTileWidth(), 0, map.getInTileWidth() - 1);
    final int ey = UtilMath.clamp(area.getInTileHeight(), 0, map.getInTileHeight() - 1);
    int remaining = count;
    while (remaining > 0) {
        final int tx = UtilRandom.getRandomInteger(sx, ex);
        final int ty = UtilRandom.getRandomInteger(sy, ey);
        final int size = UtilRandom.getRandomInteger(maxSize);
        final int halfBottom = (int) Math.floor(size / 2.0);
        final int halfTop = (int) Math.ceil(size / 2.0);
        for (int ox = -halfBottom; ox < halfTop; ox++) {
            for (int oy = -halfBottom; oy < halfTop; oy++) {
                final int ntx = UtilMath.clamp(tx + ox, sx, ex);
                final int nty = UtilMath.clamp(ty + oy, sy, ey);
                final Tile tile = new TileGame(number, ntx, nty, map.getTileWidth(), map.getTileHeight());
                map.setTile(tile.getInTileX(), tile.getInTileY(), number);
                mapTransition.resolve(tile);
            }
        }
        remaining--;
    }
}
Also used : MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) TileGame(com.b3dgs.lionengine.game.feature.tile.TileGame)

Example 3 with MapTileTransition

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

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

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

MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)5 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)4 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)2 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)2 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)2 MapTileTransitionModel (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel)2 Media (com.b3dgs.lionengine.Media)1 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)1 TileGame (com.b3dgs.lionengine.game.feature.tile.TileGame)1 MapTileCircuit (com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuit)1 MapTileCircuitModel (com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuitModel)1 HashSet (java.util.HashSet)1