Search in sources :

Example 11 with EmitterData

use of de.gurkenlabs.litiengine.graphics.emitters.xml.EmitterData in project litiengine by gurkenlabs.

the class AssetPanel method loadEmitters.

public void loadEmitters(List<EmitterData> emitters) {
    this.load(() -> {
        Collections.sort(emitters);
        for (EmitterData emitter : emitters) {
            AssetPanelItem panelItem = new AssetPanelItem(Icons.DOC_EMITTER, emitter.getName(), emitter);
            this.add(panelItem);
            panelItem.validate();
        }
    });
}
Also used : EmitterData(de.gurkenlabs.litiengine.graphics.emitters.xml.EmitterData)

Example 12 with EmitterData

use of de.gurkenlabs.litiengine.graphics.emitters.xml.EmitterData in project litiengine by gurkenlabs.

the class EmitterMapObjectLoader method createEmitterData.

public static EmitterData createEmitterData(IMapObject mapObject) {
    EmitterData data = new EmitterData();
    // emitter
    data.setWidth(mapObject.getWidth());
    data.setHeight(mapObject.getHeight());
    data.setSpawnRate(mapObject.getIntValue(MapObjectProperty.Emitter.SPAWNRATE, EmitterData.DEFAULT_SPAWNRATE));
    data.setSpawnAmount(mapObject.getIntValue(MapObjectProperty.Emitter.SPAWNAMOUNT, EmitterData.DEFAULT_SPAWNAMOUNT));
    data.setUpdateRate(mapObject.getIntValue(MapObjectProperty.Emitter.UPDATERATE, EmitterData.DEFAULT_UPDATERATE));
    data.setEmitterDuration(mapObject.getIntValue(MapObjectProperty.Emitter.DURATION, EmitterData.DEFAULT_DURATION));
    data.setMaxParticles(mapObject.getIntValue(MapObjectProperty.Emitter.MAXPARTICLES, EmitterData.DEFAULT_MAXPARTICLES));
    data.setParticleType(mapObject.getEnumValue(MapObjectProperty.Emitter.PARTICLETYPE, ParticleType.class, EmitterData.DEFAULT_PARTICLE_TYPE));
    data.setColorVariance(mapObject.getFloatValue(MapObjectProperty.Emitter.COLORVARIANCE, EmitterData.DEFAULT_COLOR_VARIANCE));
    data.setAlphaVariance(mapObject.getFloatValue(MapObjectProperty.Emitter.ALPHAVARIANCE, EmitterData.DEFAULT_ALPHA_VARIANCE));
    data.setOriginAlign(mapObject.getEnumValue(MapObjectProperty.Emitter.ORIGIN_ALIGN, Align.class, EmitterData.DEFAULT_ORIGIN_ALIGN));
    data.setOriginValign(mapObject.getEnumValue(MapObjectProperty.Emitter.ORIGIN_VALIGN, Valign.class, EmitterData.DEFAULT_ORIGIN_VALIGN));
    data.setColors(mapObject.getCommaSeparatedStringValues(MapObjectProperty.Emitter.COLORS, ColorHelper.encode(EmitterData.DEFAULT_COLOR)));
    // particle
    data.setParticleOffsetX(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.OFFSET_X_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.OFFSET_X_MAX)));
    data.setParticleOffsetY(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.OFFSET_Y_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.OFFSET_Y_MAX)));
    data.setParticleWidth(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.STARTWIDTH_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.STARTWIDTH_MAX)));
    data.setParticleHeight(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.STARTHEIGHT_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.STARTHEIGHT_MAX)));
    data.setVelocityX(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.VELOCITY_X_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.VELOCITY_X_MAX)));
    data.setVelocityY(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.VELOCITY_Y_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.VELOCITY_Y_MAX)));
    data.setAccelerationX(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.ACCELERATION_X_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.ACCELERATION_X_MAX)));
    data.setAccelerationY(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.ACCELERATION_Y_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.ACCELERATION_Y_MAX)));
    data.setDeltaWidth(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.DELTAWIDTH_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.DELTAWIDTH_MAX)));
    data.setDeltaHeight(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.DELTAHEIGHT_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.DELTAHEIGHT_MAX)));
    data.setAngle(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.ANGLE_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.ANGLE_MAX)));
    data.setDeltaRotation(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.DELTA_ANGLE_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.DELTA_ANGLE_MAX)));
    data.setParticleTTL(new ParticleParameter(mapObject.getFloatValue(MapObjectProperty.Particle.TTL_MIN), mapObject.getFloatValue(MapObjectProperty.Particle.TTL_MAX)));
    data.setCollisionType(mapObject.getEnumValue(MapObjectProperty.COLLISION_TYPE, Collision.class, EmitterData.DEFAULT_COLLISION));
    data.setRequiredQuality(mapObject.getEnumValue(MapObjectProperty.REQUIRED_QUALITY, Quality.class, EmitterData.DEFAULT_REQUIRED_QUALITY));
    data.setTexts(mapObject.getCommaSeparatedStringValues(MapObjectProperty.Particle.TEXTS, EmitterData.DEFAULT_TEXT));
    data.setSpritesheet(mapObject.getStringValue(MapObjectProperty.SPRITESHEETNAME));
    data.setAnimateSprite(mapObject.getBoolValue(MapObjectProperty.Particle.ANIMATESPRITE));
    data.setLoopSprite(mapObject.getBoolValue(MapObjectProperty.Particle.LOOPSPRITE));
    data.setFade(mapObject.getBoolValue(MapObjectProperty.Particle.FADE));
    data.setFadeOnCollision(mapObject.getBoolValue(MapObjectProperty.Particle.FADEONCOLLISION));
    data.setOutlineOnly(mapObject.getBoolValue(MapObjectProperty.Particle.OUTLINEONLY));
    data.setAntiAliasing(mapObject.getBoolValue(MapObjectProperty.Particle.ANTIALIASING));
    return data;
}
Also used : Align(de.gurkenlabs.litiengine.Align) Valign(de.gurkenlabs.litiengine.Valign) ParticleParameter(de.gurkenlabs.litiengine.graphics.emitters.xml.ParticleParameter) Quality(de.gurkenlabs.litiengine.configuration.Quality) Collision(de.gurkenlabs.litiengine.physics.Collision) ParticleType(de.gurkenlabs.litiengine.graphics.emitters.particles.ParticleType) EmitterData(de.gurkenlabs.litiengine.graphics.emitters.xml.EmitterData)

Aggregations

EmitterData (de.gurkenlabs.litiengine.graphics.emitters.xml.EmitterData)12 IMapObject (de.gurkenlabs.litiengine.environment.tilemap.IMapObject)4 Blueprint (de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)4 MapObject (de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject)4 SpritesheetResource (de.gurkenlabs.litiengine.resources.SpritesheetResource)3 Emitter (de.gurkenlabs.litiengine.graphics.emitters.Emitter)2 Align (de.gurkenlabs.litiengine.Align)1 Valign (de.gurkenlabs.litiengine.Valign)1 Quality (de.gurkenlabs.litiengine.configuration.Quality)1 IEntity (de.gurkenlabs.litiengine.entities.IEntity)1 Tileset (de.gurkenlabs.litiengine.environment.tilemap.xml.Tileset)1 Spritesheet (de.gurkenlabs.litiengine.graphics.Spritesheet)1 ParticleType (de.gurkenlabs.litiengine.graphics.emitters.particles.ParticleType)1 ParticleParameter (de.gurkenlabs.litiengine.graphics.emitters.xml.ParticleParameter)1 Collision (de.gurkenlabs.litiengine.physics.Collision)1 SoundResource (de.gurkenlabs.litiengine.resources.SoundResource)1 Sound (de.gurkenlabs.litiengine.sound.Sound)1 JAXBException (jakarta.xml.bind.JAXBException)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1