Search in sources :

Example 1 with Services

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

the class AttackerModelTest method testListenerAutoAdd.

/**
 * Test the auto add listener.
 */
@Test
public void testListenerAutoAdd() {
    final ObjectAttackerSelf object = new ObjectAttackerSelf();
    UtilAttackable.prepare(object);
    final Attacker attacker = UtilAttackable.createAttacker(object, new Services());
    attacker.checkListener(object);
    attacker.attack(target);
    attacker.update(1.0);
    Assert.assertTrue(object.flag.get());
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) Test(org.junit.Test)

Example 2 with Services

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

the class UtilExtractable method createExtractable.

/**
 * Create extractable.
 *
 * @return The extractable.
 */
public static Extractable createExtractable() {
    final Services services = new Services();
    services.add(new MapTileGame());
    final Featurable featurable = new FeaturableModel();
    featurable.addFeature(new IdentifiableModel());
    featurable.addFeature(new TransformableModel());
    final Extractable extractable = new ExtractableModel(services);
    extractable.setResourcesQuantity(10);
    extractable.setResourcesType(ResourceType.WOOD);
    extractable.prepare(featurable);
    return extractable;
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) IdentifiableModel(com.b3dgs.lionengine.game.feature.IdentifiableModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 3 with Services

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

the class UtilAssignable method createServices.

/**
 * Create the services.
 *
 * @param clicked The click flag.
 * @param clickNumber The click number recorded.
 * @return The services.
 */
public static Services createServices(AtomicBoolean clicked, AtomicReference<Integer> clickNumber) {
    final Services services = new Services();
    final Camera camera = services.create(Camera.class);
    camera.setView(0, 0, 32, 32, 32);
    services.add(new ContextMock());
    final Cursor cursor = services.add(new Cursor(services) {

        @Override
        public boolean isPushedOnce(Integer click) {
            clickNumber.set(click);
            return clicked.get();
        }
    });
    cursor.setArea(0, 0, 64, 64);
    cursor.setLocation(0, 1);
    return services;
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) Camera(com.b3dgs.lionengine.game.feature.Camera) ContextMock(com.b3dgs.lionengine.ContextMock) Cursor(com.b3dgs.lionengine.game.Cursor)

Example 4 with Services

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

the class CollidableConfigTest method testEmptyAccepted.

/**
 * Test with empty accepted.
 */
@Test
void testEmptyAccepted() {
    final Media media = Medias.create("Object.xml");
    final Xml root = new Xml("test");
    root.save(media);
    final Services services = new Services();
    services.add(new ViewerMock());
    final Collidable collidable = new CollidableModel(services, new Setup(media));
    collidable.setGroup(Integer.valueOf(1));
    CollidableConfig.exports(root, collidable);
    root.save(media);
    final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
    assertEquals(Integer.valueOf(1), config.getGroup());
    assertTrue(config.getAccepted().isEmpty());
    assertTrue(media.getFile().delete());
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) ViewerMock(com.b3dgs.lionengine.ViewerMock) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Setup(com.b3dgs.lionengine.game.feature.Setup) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 5 with Services

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

the class CollidableConfigTest method testExport.

/**
 * Test export.
 */
@Test
void testExport() {
    final Media media = Medias.create("Object.xml");
    final Xml root = new Xml("test");
    root.save(media);
    final Services services = new Services();
    services.add(new ViewerMock());
    final Collidable collidable = new CollidableModel(services, new Setup(media));
    collidable.setGroup(Integer.valueOf(1));
    collidable.addAccept(Integer.valueOf(2));
    collidable.addAccept(Integer.valueOf(3));
    CollidableConfig.exports(root, collidable);
    root.save(media);
    final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
    assertEquals(Integer.valueOf(1), config.getGroup());
    assertIterableEquals(Arrays.asList(Integer.valueOf(2), Integer.valueOf(3)), config.getAccepted());
    assertTrue(media.getFile().delete());
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) ViewerMock(com.b3dgs.lionengine.ViewerMock) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Setup(com.b3dgs.lionengine.game.feature.Setup) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Aggregations

Services (com.b3dgs.lionengine.game.feature.Services)19 Media (com.b3dgs.lionengine.Media)10 Setup (com.b3dgs.lionengine.game.feature.Setup)10 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)9 Test (org.junit.jupiter.api.Test)9 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)8 Medias (com.b3dgs.lionengine.Medias)7 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)6 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)6 Featurable (com.b3dgs.lionengine.game.feature.Featurable)6 Transformable (com.b3dgs.lionengine.game.feature.Transformable)6 Camera (com.b3dgs.lionengine.game.feature.Camera)5 AfterAll (org.junit.jupiter.api.AfterAll)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Handler (com.b3dgs.lionengine.game.feature.Handler)4 MirrorableModel (com.b3dgs.lionengine.game.feature.MirrorableModel)4 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)4 UtilAssert.assertFalse (com.b3dgs.lionengine.UtilAssert.assertFalse)3 Xml (com.b3dgs.lionengine.Xml)3