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());
}
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;
}
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;
}
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());
}
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());
}
Aggregations