Search in sources :

Example 1 with ConeLight

use of box2dLight.ConeLight in project Eidolons by IDemiurge.

the class LightMap method updateMap.

// public void updateMap(Map<DC_HeroObj, BaseView> units) {
public void updateMap() {
    new ConeLight(rayHandler, 3, GdxColorMaster.ENEMY_COLOR, 200, 350, 350, 200, 100);
    LogMaster.log(LogMaster.VISIBILITY_DEBUG, "UpdateMap method was called");
    valid = false;
    if (bodyMap != null) {
        bodyMap.clear();
    }
    if (fireLightProtMap != null) {
        for (Map.Entry<Integer, FireLightProt> entry : fireLightProtMap.entrySet()) {
            entry.getValue().dispose();
        }
        fireLightProtMap.clear();
    }
    Array<Body> bodies = new Array<>();
    world.getBodies(bodies);
    for (int i = 0; i < bodies.size; i++) {
        world.destroyBody(bodies.get(i));
    }
    fireLightProtMap = new HashMap<>();
    bodyMap = new HashMap<>();
    this.units = DC_Game.game.getBfObjects();
    for (int i = 0; i < units.size(); i++) {
        BodyDef bdef = new BodyDef();
        bdef.type = BodyDef.BodyType.KinematicBody;
        Body body = world.createBody(bdef);
        // ILLUMINATION
        lightParam = PARAMS.LIGHT_EMISSION;
        darkParam = PARAMS.CONCEALMENT;
        BattleFieldObject unit = units.get(i);
        int lightStrength = unit.getIntParam(lightParam) - unit.getIntParam(darkParam);
        if (lightStrength > 0) {
            // emitters.add(unit);
            body.setTransform(units.get(i).getX() * cellWidth + cellWidth / 2, this.rows * cellHeight - units.get(i).getY() * cellHeight + cellHeight / 2, 0);
            PolygonShape shape = new PolygonShape();
            shape.setAsBox(cellWidth / 2, cellHeight / 2);
            FixtureDef fdef = new FixtureDef();
            fdef.shape = shape;
            body.createFixture(fdef);
            FireLightProt fireLightProt = new FireLightProt(world, rayHandler, unit.getX() * cellWidth + cellWidth / 2, unit.getY() * cellHeight + cellHeight / 2, lightStrength * LIGHT_MULTIPLIER, 360, SECOND);
            fireLightProt.attachToBody(body);
            fireLightProtMap.put(i, fireLightProt);
            valid = true;
        } else {
            body.setTransform(units.get(i).getX() * cellWidth + cellWidth / 2, this.rows * cellHeight - units.get(i).getY() * cellHeight + cellHeight / 2, 0);
            PolygonShape shape = new PolygonShape();
            shape.setAsBox(cellWidth / 2, cellHeight / 2);
            FixtureDef fdef = new FixtureDef();
            fdef.shape = shape;
            body.createFixture(fdef);
        }
        bodyMap.put(units.get(i), body);
    }
}
Also used : ConeLight(box2dLight.ConeLight) Array(com.badlogic.gdx.utils.Array) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ConeLight

use of box2dLight.ConeLight in project Eidolons by IDemiurge.

the class TrueLight method bindEvents.

public void bindEvents() {
    GuiEventManager.bind(GuiEventType.ADD_LIGHT, p -> {
        Vector2 v = (Vector2) p.get();
        new ConeLight(rayHandler, 3, GdxColorMaster.ENEMY_COLOR, 200, v.x, v.y, 200, 100);
        new PointLight(rayHandler, 3, GdxColorMaster.ENEMY_COLOR, 200, v.x, v.y);
    });
}
Also used : ConeLight(box2dLight.ConeLight) Vector2(com.badlogic.gdx.math.Vector2) PointLight(box2dLight.PointLight)

Example 3 with ConeLight

use of box2dLight.ConeLight in project Eidolons by IDemiurge.

the class LightMap method init.

// 
private void init(DequeImpl<BattleFieldObject> units, World world, RayHandler rayHandler, float cellWidth, float cellHeight, int rows, int cols) {
    testA = 1600;
    testB = 900;
    this.units = units;
    this.cellWidth = cellWidth;
    this.cellHeight = cellHeight;
    if (rows > 0) {
        this.rows = rows - 1;
    } else {
        this.rows = 0;
    }
    if (cols > 0) {
        this.cols = cols - 1;
    } else {
        this.cols = 0;
    }
    LightMap.world = world;
    LightMap.rayHandler = rayHandler;
    LightMap.rayHandler.setBlur(true);
    LightMap.rayHandler.setBlurNum(15);
    ambientColor = new Color(0.2f, 0.1f, 0.3f, ambientAlpha);
    LightMap.rayHandler.setAmbientLight(ambientColor);
    LightMap.rayHandler.setAmbientLight(LightingManager.ambient_light);
    RayHandler.setGammaCorrection(true);
    debugRenderer = new Box2DDebugRenderer();
    mouseLight = new PointLight(rayHandler, 100, Color.RED, LightingManager.mouse_light_distance, 0, 0);
    LightingManager.setMouse_light(true);
    new ConeLight(rayHandler, 3, GdxColorMaster.ENEMY_COLOR, 200, 350, 350, 200, 100);
    updateMap();
// bindEvents();
}
Also used : ConeLight(box2dLight.ConeLight) Color(com.badlogic.gdx.graphics.Color) PointLight(box2dLight.PointLight)

Aggregations

ConeLight (box2dLight.ConeLight)3 PointLight (box2dLight.PointLight)2 Color (com.badlogic.gdx.graphics.Color)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Array (com.badlogic.gdx.utils.Array)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1