Search in sources :

Example 1 with MapObject

use of de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject in project litiengine by gurkenlabs.

the class UndoManager method clone.

private static IMapObject clone(IMapObject mapObject) {
    MapObject clonedObject = new MapObject();
    clonedObject.setId(mapObject.getId());
    clonedObject.setName(mapObject.getName() != null ? mapObject.getName() : "");
    clonedObject.setType(mapObject.getType() != null ? mapObject.getType() : "");
    clonedObject.setX(mapObject.getX());
    clonedObject.setY(mapObject.getY());
    clonedObject.setWidth(mapObject.getWidth());
    clonedObject.setHeight(mapObject.getHeight());
    clonedObject.setCustomProperties(mapObject.getAllCustomProperties().stream().collect(Collectors.toList()));
    return clonedObject;
}
Also used : MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 2 with MapObject

use of de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject in project litiengine by gurkenlabs.

the class MapComponent method cut.

public void cut() {
    this.copiedBlueprint = new Blueprint("", true, this.getSelectedMapObjects().toArray(new MapObject[this.getSelectedMapObjects().size()]));
    UndoManager.instance().beginOperation();
    try {
        for (MapObject mapObject : this.getSelectedMapObjects()) {
            this.delete(mapObject);
            UndoManager.instance().mapObjectDeleted(mapObject);
        }
    } finally {
        UndoManager.instance().endOperation();
    }
}
Also used : Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 3 with MapObject

use of de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject in project litiengine by gurkenlabs.

the class MapComponent method paste.

public void paste(int x, int y) {
    if (this.copiedBlueprint == null) {
        return;
    }
    UndoManager.instance().beginOperation();
    try {
        this.setFocus(null, true);
        for (MapObject mapObject : this.copiedBlueprint.build(x, y)) {
            this.add(mapObject);
            this.setSelection(mapObject, false);
        }
        // clean up copied blueprints in case, we cut the objects and kept the IDs
        if (this.copiedBlueprint.keepIds()) {
            this.copiedBlueprint = null;
        }
    } finally {
        UndoManager.instance().endOperation();
    }
}
Also used : MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 4 with MapObject

use of de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject in project litiengine by gurkenlabs.

the class MapComponent method defineBlueprint.

public void defineBlueprint() {
    if (this.getFocusedMapObject() == null) {
        return;
    }
    Object name = JOptionPane.showInputDialog(Game.getScreenManager().getRenderComponent(), Resources.get("input_prompt_name"), Resources.get("input_prompt_name_title"), JOptionPane.PLAIN_MESSAGE, null, null, this.getFocusedMapObject().getName());
    if (name == null) {
        return;
    }
    Blueprint blueprint = new Blueprint(name.toString(), this.getSelectedMapObjects().toArray(new MapObject[this.getSelectedMapObjects().size()]));
    EditorScreen.instance().getGameFile().getBluePrints().add(blueprint);
    Program.getAssetTree().forceUpdate();
}
Also used : Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 5 with MapObject

use of de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject in project litiengine by gurkenlabs.

the class EmitterMapObjectLoader method createMapObject.

public static IMapObject createMapObject(EmitterData emitterData) {
    MapObject newMapObject = new MapObject();
    newMapObject.setType(MapObjectType.EMITTER.toString());
    // emitter
    newMapObject.setWidth(emitterData.getWidth());
    newMapObject.setHeight(emitterData.getHeight());
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.SPAWNRATE, Integer.toString(emitterData.getSpawnRate()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.SPAWNAMOUNT, Integer.toString(emitterData.getSpawnAmount()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.UPDATERATE, Integer.toString(emitterData.getUpdateRate()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.TIMETOLIVE, Integer.toString(emitterData.getEmitterTTL()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.MAXPARTICLES, Integer.toString(emitterData.getMaxParticles()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.PARTICLETYPE, emitterData.getParticleType().name());
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.COLORDEVIATION, Float.toString(emitterData.getColorDeviation()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.ALPHADEVIATION, Float.toString(emitterData.getAlphaDeviation()));
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.ORIGIN_ALIGN, emitterData.getOriginAlign().name());
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.ORIGIN_VALIGN, emitterData.getOriginValign().name());
    String commaSeperatedColors = ArrayUtilities.getCommaSeparatedString(emitterData.getColors());
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.COLORS, commaSeperatedColors);
    newMapObject.setCustomProperty(MapObjectProperty.Emitter.PARTICLETYPE, ArrayUtilities.getCommaSeparatedString(emitterData.getColorProbabilities()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINX, Float.toString(emitterData.getParticleX().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINY, Float.toString(emitterData.getParticleY().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINSTARTWIDTH, Float.toString(emitterData.getParticleWidth().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINSTARTHEIGHT, Float.toString(emitterData.getParticleHeight().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINDELTAX, Float.toString(emitterData.getDeltaX().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINDELTAY, Float.toString(emitterData.getDeltaY().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINGRAVITYX, Float.toString(emitterData.getGravityX().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINGRAVITYY, Float.toString(emitterData.getGravityY().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINDELTAWIDTH, Float.toString(emitterData.getDeltaWidth().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINDELTAHEIGHT, Float.toString(emitterData.getDeltaHeight().getMinValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXX, Float.toString(emitterData.getParticleX().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXY, Float.toString(emitterData.getParticleY().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXSTARTWIDTH, Float.toString(emitterData.getParticleWidth().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXSTARTHEIGHT, Float.toString(emitterData.getParticleHeight().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXDELTAX, Float.toString(emitterData.getDeltaX().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXDELTAY, Float.toString(emitterData.getDeltaY().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXGRAVITYX, Float.toString(emitterData.getGravityX().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXGRAVITYY, Float.toString(emitterData.getGravityY().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXDELTAWIDTH, Float.toString(emitterData.getDeltaWidth().getMaxValue()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXDELTAHEIGHT, Float.toString(emitterData.getDeltaHeight().getMaxValue()));
    // particle
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MINTTL, Integer.toString(emitterData.getParticleMinTTL()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.MAXTTL, Integer.toString(emitterData.getParticleMaxTTL()));
    newMapObject.setCustomProperty(MapObjectProperty.Particle.COLLISIONTYPE, emitterData.getCollisionType().toString());
    newMapObject.setCustomProperty(MapObjectProperty.Particle.TEXT, emitterData.getParticleText());
    newMapObject.setCustomProperty(MapObjectProperty.Particle.SPRITE, emitterData.getSpritesheet());
    newMapObject.setCustomProperty(MapObjectProperty.Particle.ANIMATESPRITE, Boolean.toString(emitterData.isAnimateSprite()));
    return newMapObject;
}
Also used : MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Aggregations

MapObject (de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject)10 IMapObject (de.gurkenlabs.litiengine.environment.tilemap.IMapObject)7 Blueprint (de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)3 SpriteSheetInfo (de.gurkenlabs.litiengine.SpriteSheetInfo)2 EmitterData (de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)2 Property (de.gurkenlabs.litiengine.environment.tilemap.xml.Property)1