use of de.gurkenlabs.litiengine.physics.Collision in project litiengine by gurkenlabs.
the class MapObjectSerializerTests method testSerialization.
@Test
void testSerialization() {
Prop p = new Prop("something");
// general entity fields
p.setName("testname");
p.setX(10);
p.setY(10.5);
p.setMapId(123);
p.addTag("test");
p.addTag("test2");
// combat fields
p.setIndestructible(true);
p.setTeam(2);
// collision fields
p.setCollisionBoxAlign(Align.CENTER_LEFT);
p.setCollisionBoxValign(Valign.MIDDLE_DOWN);
p.setCollision(true);
p.setCollisionBoxHeight(5);
p.setCollisionBoxWidth(5);
// prop fields
p.setMaterial(Material.CERAMIC);
p.setCollisionType(Collision.STATIC);
p.setAddShadow(true);
p.setSpriteRotation(Rotation.ROTATE_270);
p.setFlipHorizontally(true);
p.setFlipVertically(true);
p.setScaling(true);
IMapObject mapObject = MapObjectSerializer.serialize(p);
assertEquals("testname", mapObject.getName());
assertEquals(10, mapObject.getX());
assertEquals(10.5, mapObject.getY());
assertEquals(123, mapObject.getId());
assertEquals("test,test2", mapObject.getStringValue(MapObjectProperty.TAGS));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.COMBAT_INDESTRUCTIBLE));
assertEquals(2, mapObject.getIntValue(MapObjectProperty.COMBAT_TEAM));
assertEquals(Align.CENTER_LEFT, mapObject.getEnumValue(MapObjectProperty.COLLISION_ALIGN, Align.class));
assertEquals(Valign.MIDDLE_DOWN, mapObject.getEnumValue(MapObjectProperty.COLLISION_VALIGN, Valign.class));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.COLLISION));
assertEquals(5, mapObject.getFloatValue(MapObjectProperty.COLLISIONBOX_WIDTH));
assertEquals(5, mapObject.getFloatValue(MapObjectProperty.COLLISIONBOX_HEIGHT));
assertEquals(Material.CERAMIC, Material.get(mapObject.getStringValue(MapObjectProperty.PROP_MATERIAL)));
assertEquals(Collision.STATIC, mapObject.getEnumValue(MapObjectProperty.COLLISION_TYPE, Collision.class));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.PROP_ADDSHADOW));
assertEquals(Rotation.ROTATE_270, mapObject.getEnumValue(MapObjectProperty.PROP_ROTATION, Rotation.class));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.PROP_FLIPHORIZONTALLY));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.PROP_FLIPVERTICALLY));
assertEquals(true, mapObject.getBoolValue(MapObjectProperty.SCALE_SPRITE));
}
Aggregations