Search in sources :

Example 31 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class ExtractableModelTest method testExtract.

/**
 * Test the extraction.
 */
@Test
void testExtract() {
    services.add(new MapTileGame());
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeature(new TransformableModel(services, setup));
    final Extractable extractable = new ExtractableModel(services, setup);
    extractable.prepare(featurable);
    extractable.setResourcesQuantity(10);
    assertEquals(10, extractable.getResourceQuantity());
    extractable.extractResource(5);
    assertEquals(5, extractable.getResourceQuantity());
    extractable.getFeature(Identifiable.class).notifyDestroyed();
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Identifiable(com.b3dgs.lionengine.game.feature.Identifiable) Test(org.junit.jupiter.api.Test)

Example 32 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class UtilProducible method createProducible.

/**
 * Create producible.
 *
 * @param services The services.
 * @return The producible.
 */
public static Featurable createProducible(Services services) {
    final Media media = createProducibleMedia();
    final Setup setup = new Setup(media);
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeature(new TransformableModel(services, setup));
    featurable.addFeature(new ProducibleModel(services, setup));
    return featurable;
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Media(com.b3dgs.lionengine.Media) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 33 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class MapTileCollisionModelTest method createObject.

/**
 * Create object test.
 *
 * @return The object test.
 */
private Transformable createObject() {
    final Setup setup = new Setup(config);
    CollisionCategoryConfig.exports(setup.getRoot(), categoryY);
    CollisionCategoryConfig.exports(setup.getRoot(), categoryX);
    final FeaturableModel object = new FeaturableModel(services, setup);
    final Transformable transformable = object.addFeatureAndGet(new TransformableModel(services, setup));
    transformable.setSize(1, 1);
    final TileCollidable collidable = object.addFeatureAndGet(new TileCollidableModel(services, setup));
    collidable.setEnabled(true);
    return transformable;
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Aggregations

FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)33 Test (org.junit.jupiter.api.Test)20 Featurable (com.b3dgs.lionengine.game.feature.Featurable)18 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)18 Transformable (com.b3dgs.lionengine.game.feature.Transformable)16 Setup (com.b3dgs.lionengine.game.feature.Setup)14 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)7 Media (com.b3dgs.lionengine.Media)6 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)6 Services (com.b3dgs.lionengine.game.feature.Services)5 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)5 Medias (com.b3dgs.lionengine.Medias)4 Identifiable (com.b3dgs.lionengine.game.feature.Identifiable)4 Animation (com.b3dgs.lionengine.Animation)3 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)3 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)3 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)3 UtilTransformable (com.b3dgs.lionengine.game.feature.UtilTransformable)3 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)3