use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTransitionExtractorTest method testNullNeighbor.
/**
* Check the transition with <code>null</code> neighbors.
*/
@Test
void testNullNeighbor() {
final MapTile map = UtilMap.createMap(7);
map.setTile(4, 2, TILE_WATER);
map.setTile(3, 3, TILE_WATER);
assertEquals(new Transition(TransitionType.CENTER, WATER, WATER), get(map, 3, 3));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTransitionExtractorTest method testTransitionCenter.
/**
* Check the center transition.
*/
@Test
void testTransitionCenter() {
final MapTile map = UtilMap.createMap(7);
UtilMap.fill(map, TILE_WATER);
UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
final Transition transition = new Transition(TransitionType.CENTER, WATER, WATER);
for (int tx = 0; tx < map.getInTileWidth(); tx++) {
assertEquals(transition, get(map, tx, 0));
assertEquals(transition, get(map, tx, map.getInTileHeight() - 1));
}
for (int ty = 0; ty < map.getInTileHeight(); ty++) {
assertEquals(transition, get(map, 0, ty));
assertEquals(transition, get(map, map.getInTileWidth() - 1, ty));
}
assertNull(get(map, map.getInTileWidth() / 2, map.getInTileHeight() / 2));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTransitionExtractorTest method testCorners.
/**
* Check the corners transitions.
*/
@Test
void testCorners() {
final MapTile map = UtilMap.createMap(7);
UtilMap.fill(map, TILE_WATER);
UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
assertEquals(new Transition(TransitionType.UP_LEFT, WATER, GROUND), get(map, 2, 4));
assertEquals(new Transition(TransitionType.UP_RIGHT, WATER, GROUND), get(map, 4, 4));
assertEquals(new Transition(TransitionType.DOWN_LEFT, WATER, GROUND), get(map, 2, 2));
assertEquals(new Transition(TransitionType.DOWN_RIGHT, WATER, GROUND), get(map, 4, 2));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTransitionExtractorTest method testThreeGroups.
/**
* Check the three groups transition.
* <p>
* Problem here consists in having more than two groups to solve transition, which requires two different groups.
* </p>
*/
@Test
void testThreeGroups() {
final MapTile map = UtilMap.createMap(7);
UtilMap.fill(map, TILE_WATER);
map.setTile(1, 1, TILE_GROUND);
map.setTile(3, 3, TILE_TREE);
assertNull(get(map, 2, 2));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class TransitionsExtractorImpl method getTransitions.
@Override
public Map<Transition, Collection<Integer>> getTransitions(Collection<MapTile> maps) {
final Map<Transition, Collection<Integer>> transitions = new HashMap<>();
for (final MapTile map : maps) {
final Map<Transition, Collection<Integer>> currents = getTransitions(map);
for (final Entry<Transition, Collection<Integer>> entry : currents.entrySet()) {
final Transition transition = entry.getKey();
final Collection<Integer> tiles = entry.getValue();
if (transitions.containsKey(transition)) {
transitions.get(transition).addAll(tiles);
} else {
transitions.put(transition, tiles);
}
}
}
return transitions;
}
Aggregations