Search in sources :

Example 26 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class RadarSensorSystem method processCollision.

@Override
public void processCollision(Fixture colliderA, Fixture colliderB, boolean collisionSignal) {
    if (colliderA.isSensor() && !colliderB.isSensor()) {
        Integer indexEntityA = (Integer) colliderA.getBody().getUserData();
        Integer indexEntityB = (Integer) colliderB.getBody().getUserData();
        String tagSensorA = (String) colliderA.getUserData();
        if (indexEntityA != null && indexEntityB != null && tagSensorA != null && tagSensorA.equals("RadarSensor")) {
            GameEntity entityB = Indexed.getInteractiveEntity(indexEntityB);
            if (entityB != null) {
                for (SensorEntity entity : sensorGroup.getEntities()) {
                    RadarSensor radar = entity.getRadarSensor();
                    if (entityB.getTags().values.contains(radar.targetTag)) {
                        if (collisionSignal) {
                            Indexed.addEntityInSensor(entity, entityB);
                        } else {
                            Indexed.removeEntityInSensor(entity, entityB);
                        }
                        radar.collisionSignal = collisionSignal;
                    }
                }
            }
        }
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) SensorEntity(ilargia.egdx.logicbricks.gen.sensor.SensorEntity) RadarSensor(ilargia.egdx.logicbricks.component.sensor.RadarSensor)

Example 27 with GameEntity

use of ilargia.egdx.logicbricks.gen.game.GameEntity in project Entitas-Java by Rubentxu.

the class PlatformExamples method createScene.

@Override
public void createScene(Engine engine, Entitas entitas) {
    AssetsManagerGDX assetsManager = engine.getManager(AssetsManagerGDX.class);
    assetsManager.loadTexture("assets/imagenes/fondos/fondo.jpg");
    assetsManager.loadTexture("assets/imagenes/fondos/nubes.png");
    assetsManager.loadTexture("assets/imagenes/fondos/arboles.png");
    assetsManager.finishLoading();
    // entitas.scene.createEntity()
    // .addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/fondo.jpg"))
    // , new Vector2(0.7f,0f),new Vector2(0, 1),new Vector2(0, 0));
    entitas.scene.createEntity().addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/nubes.png")), new Vector2(0.5f, 1.0f), new Vector2(0, 10), new Vector2(0, 0));
    entitas.scene.createEntity().addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/arboles.png")), new Vector2(0.9f, 0), new Vector2(0, -0.4f), new Vector2(0, 0));
    // entitas.scene.createEntity()
    // .addCPointLight(55, Color.GOLD, 45, new Vector2(10,4));
    // entitas.scene.createEntity()
    // .addCChainLight(25, Color.FOREST, 180, 145, new float[]{-5, 0, 0, 0, 0, 0,30,12});
    // entitas.scene.createEntity()
    // .addCDirectionalLight(84, Color.SKY, 270);
    entitas.scene.createEntity().addCConeLight(35, Color.GREEN, 40, new Vector2(16, 13), 250, 60);
    SceneManagerGDX sceneManager = engine.getManager(SceneManagerGDX.class);
    GameEntity ground = sceneManager.createEntity("Ground");
    ground.getRigidBody().body.setTransform(10, 1, 0);
    GameEntity mariano = sceneManager.createEntity("Mariano");
    mariano.getRigidBody().body.setTransform(10, 6, 0);
    GameEntity box1 = sceneManager.createEntity("Box");
    box1.addTags("Box");
    box1.getRigidBody().body.setTransform(20, 7, 0);
    GameEntity box2 = sceneManager.createEntity("Box");
    box2.addTags("Box2");
    box2.getRigidBody().body.setTransform(25, 7, 0);
    entitas.actuator.setDragActuator(ground.getCreationIndex(), false, 1000);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) AssetsManagerGDX(ilargia.egdx.impl.managers.AssetsManagerGDX) Vector2(com.badlogic.gdx.math.Vector2) SceneManagerGDX(ilargia.egdx.impl.managers.SceneManagerGDX)

Aggregations

GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)27 RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)9 SensorEntity (ilargia.egdx.logicbricks.gen.sensor.SensorEntity)8 Vector2 (com.badlogic.gdx.math.Vector2)6 Body (com.badlogic.gdx.physics.box2d.Body)5 TextureView (ilargia.egdx.logicbricks.component.game.TextureView)5 Transform (com.badlogic.gdx.physics.box2d.Transform)4 ActuatorEntity (ilargia.egdx.logicbricks.gen.actuator.ActuatorEntity)4 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)3 Vector3 (com.badlogic.gdx.math.Vector3)3 ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)3 FixtureDef (com.badlogic.gdx.physics.box2d.FixtureDef)2 PhysicsManagerGDX (ilargia.egdx.impl.managers.PhysicsManagerGDX)2 CameraActuator (ilargia.egdx.logicbricks.component.actuator.CameraActuator)2 RadialGravityActuator (ilargia.egdx.logicbricks.component.actuator.RadialGravityActuator)2 TextureActuator (ilargia.egdx.logicbricks.component.actuator.TextureActuator)2 VelocityActuator (ilargia.egdx.logicbricks.component.actuator.VelocityActuator)2 NearSensor (ilargia.egdx.logicbricks.component.sensor.NearSensor)2 RadarSensor (ilargia.egdx.logicbricks.component.sensor.RadarSensor)2 Bounds (ilargia.egdx.logicbricks.data.Bounds)2