use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup in project lionengine by b3dgs.
the class MapTileCircuitModelTest method testResolution.
/**
* Test the map circuit resolution.
*/
@Test
void testResolution() {
final MapTile map = createMap(TILE_GROUND);
final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
final MapTileCircuit mapCircuit = map.getFeature(MapTileCircuitModel.class);
map.setTile(5, 6, TILE_ROAD);
map.setTile(5, 4, TILE_ROAD);
map.setTile(5, 5, TILE_ROAD);
map.setTile(4, 5, TILE_ROAD);
map.setTile(6, 5, TILE_ROAD);
mapCircuit.resolve(map.getTile(5, 5));
assertEquals(ROAD, mapGroup.getGroup(map.getTile(5, 5)));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup in project lionengine by b3dgs.
the class MapTileTransitionModelTest method testResolution.
/**
* Test the map resolution.
*
* @param tileNumber The initial tile number.
* @param groupOrigin The initial group.
* @param tileNew The new tile number.
* @param groupNew The new tile group.
* @param transition The transition between initial tile and new tile.
*/
private static void testResolution(int tileNumber, String groupOrigin, int tileNew, String groupNew, String transition) {
final MapTile map = UtilMap.createMap(12);
UtilMap.fill(map, tileNumber);
map.getFeature(MapTileTransition.class).loadTransitions(config);
final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
final MapTileTransition mapTransition = map.getFeature(MapTileTransitionModel.class);
assertEquals(groupOrigin, mapGroup.getGroup(map.getTile(8, 8)));
map.setTile(8, 8, tileNew);
final Tile tile = map.getTile(8, 8);
assertEquals(groupNew, mapGroup.getGroup(map.getTile(8, 8)));
for (final Tile neighbor : map.getNeighbors(tile)) {
assertEquals(groupOrigin, mapGroup.getGroup(neighbor));
}
mapTransition.resolve(tile);
for (final Tile neighbor : map.getNeighbors(tile)) {
assertEquals(transition, mapGroup.getGroup(neighbor));
}
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup in project lionengine by b3dgs.
the class TransitiveGroupTest method testTransitives.
/**
* Test the transitive groups.
*/
@Test
void testTransitives() {
final MapTile map = UtilMap.createMap(30);
UtilMap.fill(map, TILE_WATER);
final Media config = UtilMapTransition.createTransitions();
final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
map.getFeature(MapTileTransition.class).loadTransitions(config);
final TransitiveGroup transitive = new TransitiveGroup(map);
transitive.load();
assertEquals(Arrays.asList(new GroupTransition(WATER, GROUND), new GroupTransition(GROUND, TREE)), transitive.getTransitives(WATER, TREE));
assertEquals(WATER, mapGroup.getGroup(map.getTile(15, 15)));
map.setTile(15, 15, TILE_TREE);
final Tile tile = map.getTile(15, 15);
transitive.checkTransitives(tile);
assertEquals(TREE, mapGroup.getGroup(map.getTile(15, 15)));
assertEquals(WATER, mapGroup.getGroup(map.getTile(14, 14)));
assertEquals(GROUND, mapGroup.getGroup(map.getTile(13, 13)));
assertTrue(transitive.getTransitives("a", "b").isEmpty());
assertTrue(transitive.getDirectTransitiveTiles(new Transition(TransitionType.CENTER, "a", "a")).isEmpty());
assertArrayEquals(Arrays.asList(Integer.valueOf(TILE_TRANSITION2)).toArray(), transitive.getDirectTransitiveTiles(new Transition(TransitionType.UP_LEFT, WATER, TREE)).toArray());
assertTrue(config.getFile().delete());
}
Aggregations