Search in sources :

Example 1 with MAP_MOVING_LAYER

use of eidolons.libgdx.screens.map.layers.MapMoveLayers.MAP_MOVING_LAYER in project Eidolons by IDemiurge.

the class MapMoveLayers method act.

@Override
public void act(float delta) {
    if (MacroGame.getGame() == null)
        return;
    // spawn();
    for (MAP_MOVING_LAYER sub : MAP_MOVING_LAYER.values()) {
        MapMaster.addToFloatMap(timerMap, sub, delta);
        for (DAY_TIME day_time : sub.times) {
            if (time != day_time) {
                continue;
            }
            if (triggerMap.get(sub) == null || timerMap.get(sub) > triggerMap.get(sub)) {
                spawn(sub);
                float willSpawnOn = RandomWizard.getRandomFloatBetween(sub.delay, 2 * sub.delay);
                willSpawnOn = applyLayerDelayMods(sub, day_time, willSpawnOn);
                triggerMap.put(sub, willSpawnOn);
                timerMap.put(sub, 0f);
            }
        }
    }
    for (Actor actor : getChildren()) {
        if (!(actor instanceof MapMoveLayer))
            continue;
        MapMoveLayer sub = (MapMoveLayer) actor;
        MAP_MOVING_LAYER type = sub.getType();
        // if (Math.abs(sub.getSpeed() )> 0) {
        // }
        float x = sub.getContent().getX() + sub.getSpeed() * delta * getModX(type.direction);
        float y = sub.getContent().getY() + sub.getSpeed() * delta * getModY(type.direction);
        sub.getContent().setPosition(x, y);
        float distance = new Vector2(sub.getContent().getX(), sub.getContent().getY()).dst(new Vector2(sub.getOriginalX(), sub.getOriginalY()));
        float maxDistance = sub.getMaxDistance();
        if (x > getWidth() || x < -sub.getWidth() && (y > getHeight() + sub.getHeight() || y < 0))
            remove(sub);
        else // center to edge? direction? better check sumis <> maxWidth or 0
        if (distance > maxDistance) {
            remove(sub);
        }
        if (type.rotation != 0) {
            sub.setOrigin(Align.center);
            sub.setRotation(sub.getRotation() + (type.rotation * delta) * sub.rotationMod);
        }
    // ++ shakiness
    // checkRemove or reset
    }
    super.act(delta);
}
Also used : MAP_MOVING_LAYER(eidolons.libgdx.screens.map.layers.MapMoveLayers.MAP_MOVING_LAYER) Vector2(com.badlogic.gdx.math.Vector2) DAY_TIME(main.content.enums.macro.MACRO_CONTENT_CONSTS.DAY_TIME) Actor(com.badlogic.gdx.scenes.scene2d.Actor) EmitterActor(eidolons.libgdx.anims.particles.EmitterActor)

Aggregations

Vector2 (com.badlogic.gdx.math.Vector2)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 EmitterActor (eidolons.libgdx.anims.particles.EmitterActor)1 MAP_MOVING_LAYER (eidolons.libgdx.screens.map.layers.MapMoveLayers.MAP_MOVING_LAYER)1 DAY_TIME (main.content.enums.macro.MACRO_CONTENT_CONSTS.DAY_TIME)1