Search in sources :

Example 6 with EmitterData

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

the class AssetPanelItem method canAdd.

private boolean canAdd() {
    if (this.getOrigin() != null && this.getOrigin() instanceof SpriteSheetInfo) {
        SpriteSheetInfo info = (SpriteSheetInfo) this.getOrigin();
        String propName = PropPanel.getNameBySpriteName(info.getName());
        return propName != null && !propName.isEmpty();
    }
    return this.getOrigin() instanceof MapObject || this.getOrigin() instanceof EmitterData;
}
Also used : SpriteSheetInfo(de.gurkenlabs.litiengine.SpriteSheetInfo) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) EmitterData(de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)

Example 7 with EmitterData

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

the class EmitterMapObjectLoader method load.

@Override
public Collection<IEntity> load(IEnvironment environment, IMapObject mapObject) {
    if (MapObjectType.get(mapObject.getType()) != MapObjectType.EMITTER) {
        throw new IllegalArgumentException("Cannot load a mapobject of the type " + mapObject.getType() + " with a loader of the type " + EmitterMapObjectLoader.class);
    }
    EmitterData data = createEmitterData(mapObject);
    CustomEmitter emitter = new CustomEmitter(data);
    loadDefaultProperties(emitter, mapObject);
    Collection<IEntity> entities = super.load(environment, mapObject);
    entities.add(emitter);
    return entities;
}
Also used : IEntity(de.gurkenlabs.litiengine.entities.IEntity) CustomEmitter(de.gurkenlabs.litiengine.graphics.particles.xml.CustomEmitter) EmitterData(de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)

Example 8 with EmitterData

use of de.gurkenlabs.litiengine.graphics.particles.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.getCustomPropertyInt(MapObjectProperty.Emitter.SPAWNRATE));
    data.setSpawnAmount(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.SPAWNAMOUNT));
    data.setUpdateRate(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.UPDATERATE, Emitter.DEFAULT_UPDATERATE));
    data.setEmitterTTL(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.TIMETOLIVE));
    data.setMaxParticles(mapObject.getCustomPropertyInt(MapObjectProperty.Emitter.MAXPARTICLES));
    data.setParticleType(mapObject.getCustomPropertyEnum(MapObjectProperty.Emitter.PARTICLETYPE, ParticleType.class, ParticleType.RECTANGLE));
    data.setColorDeviation(mapObject.getCustomPropertyFloat(MapObjectProperty.Emitter.COLORDEVIATION));
    data.setAlphaDeviation(mapObject.getCustomPropertyFloat(MapObjectProperty.Emitter.ALPHADEVIATION));
    data.setOriginAlign(mapObject.getCustomPropertyEnum(MapObjectProperty.Emitter.ORIGIN_ALIGN, Align.class, Align.LEFT));
    data.setOriginValign(mapObject.getCustomPropertyEnum(MapObjectProperty.Emitter.ORIGIN_VALIGN, Valign.class, Valign.TOP));
    data.setColors(getColors(mapObject));
    data.setColorProbabilities(mapObject.getCustomProperty(MapObjectProperty.Emitter.COLORPROBABILITIES, ""));
    // particle
    data.setParticleX(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINX), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXX, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setParticleY(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINY), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXY, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setParticleWidth(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINSTARTWIDTH), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXSTARTWIDTH, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setParticleHeight(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINSTARTHEIGHT), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXSTARTHEIGHT, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setDeltaX(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINDELTAX), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXDELTAX, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setDeltaY(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINDELTAY), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXDELTAY, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setGravityX(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINGRAVITYX), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXGRAVITYX, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setGravityY(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINGRAVITYY), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXGRAVITYY, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setDeltaWidth(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINDELTAWIDTH), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXDELTAWIDTH, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setDeltaHeight(new ParticleParameter(mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MINDELTAHEIGHT), mapObject.getCustomPropertyFloat(MapObjectProperty.Particle.MAXDELTAHEIGHT, ParticleParameter.MAX_VALUE_UNDEFINED)));
    data.setParticleMinTTL(mapObject.getCustomPropertyInt(MapObjectProperty.Particle.MINTTL));
    data.setParticleMaxTTL(mapObject.getCustomPropertyInt(MapObjectProperty.Particle.MAXTTL));
    data.setCollisionType(mapObject.getCustomPropertyEnum(MapObjectProperty.Particle.COLLISIONTYPE, CollisionType.class, CollisionType.NONE));
    data.setParticleText(mapObject.getCustomProperty(MapObjectProperty.Particle.TEXT));
    data.setSpritesheet(mapObject.getCustomProperty(MapObjectProperty.Particle.SPRITE));
    data.setAnimateSprite(mapObject.getCustomPropertyBool(MapObjectProperty.Particle.ANIMATESPRITE));
    return data;
}
Also used : Align(de.gurkenlabs.litiengine.Align) CollisionType(de.gurkenlabs.litiengine.physics.CollisionType) Valign(de.gurkenlabs.litiengine.Valign) ParticleParameter(de.gurkenlabs.litiengine.graphics.particles.xml.ParticleParameter) ParticleType(de.gurkenlabs.litiengine.graphics.particles.xml.ParticleType) EmitterData(de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)

Aggregations

EmitterData (de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)8 SpriteSheetInfo (de.gurkenlabs.litiengine.SpriteSheetInfo)3 Blueprint (de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)3 MapObject (de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject)2 Align (de.gurkenlabs.litiengine.Align)1 Valign (de.gurkenlabs.litiengine.Valign)1 IEntity (de.gurkenlabs.litiengine.entities.IEntity)1 CustomEmitter (de.gurkenlabs.litiengine.graphics.particles.xml.CustomEmitter)1 ParticleParameter (de.gurkenlabs.litiengine.graphics.particles.xml.ParticleParameter)1 ParticleType (de.gurkenlabs.litiengine.graphics.particles.xml.ParticleType)1 CollisionType (de.gurkenlabs.litiengine.physics.CollisionType)1 Point (java.awt.Point)1 File (java.io.File)1