Search in sources :

Example 21 with MapTile

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

the class ExtractableModelTest method testConfigWithNode.

/**
 * Test the extraction config with node.
 */
@Test
void testConfigWithNode() {
    final MapTile map = new MapTileGame();
    map.create(16, 16, 4, 4);
    services.add(map);
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeatureAndGet(new TransformableModel(services, setup)).teleport(16, 32);
    final Media media = UtilExtractable.createMedia();
    final Extractable extractable = new ExtractableModel(services, new Setup(media));
    extractable.prepare(featurable);
    assertEquals(10, extractable.getResourceQuantity());
    assertEquals("gold", extractable.getResourceType());
    assertEquals(1, extractable.getInTileX());
    assertEquals(2, extractable.getInTileY());
    assertEquals(1, extractable.getInTileWidth());
    assertEquals(2, extractable.getInTileHeight());
    extractable.getFeature(Identifiable.class).notifyDestroyed();
    assertTrue(media.getFile().delete());
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Identifiable(com.b3dgs.lionengine.game.feature.Identifiable) Test(org.junit.jupiter.api.Test)

Example 22 with MapTile

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

the class TransitionsConfigTest method testExportsImports.

/**
 * Test exports and imports.
 *
 * @throws IOException If error.
 */
@Test
void testExportsImports() throws IOException {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, UtilMap.TILE_WATER);
    UtilMap.fill(map, UtilMap.TILE_WATER, UtilMap.TILE_TRANSITION, 3);
    final MapTile map2 = UtilMap.createMap(7);
    UtilMap.fill(map, UtilMap.TILE_WATER);
    UtilMap.fill(map, UtilMap.TILE_GROUND, UtilMap.TILE_TRANSITION, 3);
    final MapTileGame map3 = new MapTileGame();
    map3.addFeature(new MapTileGroupModel());
    map3.create(1, 1, 3, 3);
    final TransitionsExtractor extractor = new TransitionsExtractorImpl();
    final Map<Transition, Collection<Integer>> transitions = extractor.getTransitions(Arrays.asList(map, map2, map3));
    final Media media = Medias.create("transition.xml");
    TransitionsConfig.exports(media, transitions);
    assertEquals(transitions, TransitionsConfig.imports(media));
    assertTrue(media.getFile().delete());
}
Also used : MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) Collection(java.util.Collection) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 23 with MapTile

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

the class MapTransitionExtractorTest method testDiagonal.

/**
 * Check the diagonal transitions.
 */
@Test
void testDiagonal() {
    final MapTile map = UtilMap.createMap(9);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 5);
    assertEquals(new Transition(TransitionType.UP_RIGHT_DOWN_LEFT, WATER, GROUND), get(map, 4, 4));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 24 with MapTile

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

the class MapTransitionExtractorTest method testCornersInverted.

/**
 * Check the corners inverted transitions.
 */
@Test
void testCornersInverted() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_GROUND);
    UtilMap.fill(map, TILE_WATER, TILE_TRANSITION, 3);
    assertEquals(new Transition(TransitionType.CORNER_UP_LEFT, WATER, GROUND), get(map, 2, 4));
    assertEquals(new Transition(TransitionType.CORNER_UP_RIGHT, WATER, GROUND), get(map, 4, 4));
    assertEquals(new Transition(TransitionType.CORNER_DOWN_LEFT, WATER, GROUND), get(map, 2, 2));
    assertEquals(new Transition(TransitionType.CORNER_DOWN_RIGHT, WATER, GROUND), get(map, 4, 2));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 25 with MapTile

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

the class MapTransitionExtractorTest method testHorizontals.

/**
 * Check the horizontal transitions.
 */
@Test
void testHorizontals() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
    assertEquals(new Transition(TransitionType.RIGHT, WATER, GROUND), get(map, 2, 3));
    assertEquals(new Transition(TransitionType.LEFT, WATER, GROUND), get(map, 4, 3));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Aggregations

MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)58 Test (org.junit.jupiter.api.Test)34 Media (com.b3dgs.lionengine.Media)15 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)11 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)10 Collection (java.util.Collection)9 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)8 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)7 MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)3 Setup (com.b3dgs.lionengine.game.feature.Setup)3 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)3 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 Transformable (com.b3dgs.lionengine.game.feature.Transformable)2 UtilTransformable (com.b3dgs.lionengine.game.feature.UtilTransformable)2 FileReading (com.b3dgs.lionengine.io.FileReading)2 FileWriting (com.b3dgs.lionengine.io.FileWriting)2 HashSet (java.util.HashSet)2