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);
}
}
}
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--;
}
}
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);
}
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);
}
}
}
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;
}
Aggregations