@Test public void testVisibility() { reset(); ModelEntity entity = new ModelEntity(); Visibility visibility = new Visibility(); visibility.setCondition("(eq $" + variableDef + " i1)"); entity.getComponents().add(visibility); entitiesLoader.toEngineEntity(entity); IntMap<Entity> entityIntMap = gameLoop.getEntitiesFor(Family.getFamilyFor(VisibilityComponent.class)); EngineEntity engineEntity = (EngineEntity) entityIntMap.entries().next().value; assertTrue(engineEntity.getGroup().isVisible()); gameLoop.update(1); assertFalse(engineEntity.getGroup().isVisible()); variablesManager.setVarToExpression(variableDef, "i1"); gameLoop.update(1); assertTrue(engineEntity.getGroup().isVisible()); variablesManager.setVarToExpression(variableDef, "i0"); gameLoop.update(1); assertFalse(engineEntity.getGroup().isVisible()); }
private EngineEntity createModelEntityWithKeyboardInteraction( int keycode, boolean shift, boolean control, boolean alt, String condition) { ModelEntity modelEntity = new ModelEntity(); Behavior behavior = new Behavior(); key.setKeycode(keycode); key.setShift(shift); key.setCtrl(control); key.setAlt(alt); behavior.setEvent(key); behavior.getEffects().add(new MockEffect(this)); modelEntity.getComponents().add(behavior); return addEntity(modelEntity); }
@Override protected void doBuild() { ModelEntity scene = singleSceneGame(null, 800, 600).getLastScene(); ModelEntity rectangle = new ModelEntity(); rectangle.getComponents().add(rectangle(400, 300)); scene.getChildren().add(rectangle); Shader shader = new Shader(); shader.setUri("gradient.fragment"); shader.getUniforms().add(param("point1", "f0,f0")); shader.getUniforms().add(param("point2", "f1,f1")); shader.getUniforms().add(param("color1", "f1,f1,f1,f1")); shader.getUniforms().add(param("color2", "f0,f0,f0,f1")); rectangle.getComponents().add(shader); rectangle = new ModelEntity(); rectangle.getComponents().add(rectangle(400, 300)); rectangle.setX(400); shader = new Shader(); shader.setUri("gradient.fragment"); shader.getUniforms().add(param("point1", "f0,f0")); shader.getUniforms().add(param("point2", "f1,f1")); shader.getUniforms().add(param("color1", "f1,f1,f1,f1")); shader.getUniforms().add(param("color2", "f0,f0,f0,f1")); rectangle.getComponents().add(shader); scene.getChildren().add(rectangle); rectangle = new ModelEntity(); rectangle.getComponents().add(rectangle(400, 300)); rectangle.setY(300); shader = new Shader(); shader.setUri("gradient.fragment"); shader.getUniforms().add(param("point1", "f0.25,f0.25")); shader.getUniforms().add(param("point2", "f0.75,f0.75")); shader.getUniforms().add(param("color1", "f1,f0,f0,f1")); shader.getUniforms().add(param("color2", "f0,f1,f0,f1")); rectangle.getComponents().add(shader); scene.getChildren().add(rectangle); rectangle = new ModelEntity(); rectangle.getComponents().add(rectangle(400, 300)); rectangle.setX(400); rectangle.setY(300); shader = new Shader(); shader.setUri("gradient.fragment"); shader.getUniforms().add(param("point1", "f0,f0")); shader.getUniforms().add(param("point2", "f0,f1")); shader.getUniforms().add(param("color1", "f0,f1,f1,f1")); shader.getUniforms().add(param("color2", "f1,f0,f1,f1")); rectangle.getComponents().add(shader); scene.getChildren().add(rectangle); }