Search in sources :

Example 1 with Rotation

use of de.gurkenlabs.litiengine.entities.Rotation in project litiengine by gurkenlabs.

the class PropMapObjectLoader method load.

@Override
public Collection<IEntity> load(IEnvironment environment, IMapObject mapObject) {
    if (MapObjectType.get(mapObject.getType()) != MapObjectType.PROP) {
        throw new IllegalArgumentException("Cannot load a mapobject of the type " + mapObject.getType() + " with a loader of the type " + PropMapObjectLoader.class);
    }
    final Prop prop = this.createNewProp(mapObject, mapObject.getCustomProperty(MapObjectProperty.SPRITESHEETNAME));
    loadDefaultProperties(prop, mapObject);
    loadCollisionProperties(prop, mapObject);
    final Material material = mapObject.getCustomProperty(MapObjectProperty.PROP_MATERIAL) == null ? Material.UNDEFINED : Material.valueOf(mapObject.getCustomProperty(MapObjectProperty.PROP_MATERIAL));
    prop.setMaterial(material);
    prop.setObstacle(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_OBSTACLE));
    final Rotation rotation = mapObject.getCustomProperty(MapObjectProperty.PROP_ROTATION) == null ? Rotation.NONE : Rotation.valueOf(mapObject.getCustomProperty(MapObjectProperty.PROP_ROTATION));
    prop.setSpriteRotation(rotation);
    prop.setIndestructible(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_INDESTRUCTIBLE));
    AttributeModifier<Integer> mod = new AttributeModifier<>(Modification.SET, mapObject.getCustomPropertyInt(MapObjectProperty.HEALTH));
    prop.getAttributes().getHealth().modifyMaxBaseValue(mod);
    prop.getAttributes().getHealth().modifyBaseValue(mod);
    prop.setAddShadow(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_ADDSHADOW));
    prop.setFlipHorizontally(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_FLIPHORIZONTALLY));
    prop.setFlipVertically(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_FLIPVERTICALLY));
    prop.setScaling(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_SCALE));
    prop.setTeam(mapObject.getCustomPropertyInt(MapObjectProperty.TEAM));
    Collection<IEntity> entities = super.load(environment, mapObject);
    entities.add(prop);
    return entities;
}
Also used : Prop(de.gurkenlabs.litiengine.entities.Prop) IEntity(de.gurkenlabs.litiengine.entities.IEntity) Material(de.gurkenlabs.litiengine.entities.Material) AttributeModifier(de.gurkenlabs.litiengine.attributes.AttributeModifier) Rotation(de.gurkenlabs.litiengine.entities.Rotation)

Example 2 with Rotation

use of de.gurkenlabs.litiengine.entities.Rotation in project litiengine by gurkenlabs.

the class PropPanel method setControlValues.

@Override
protected void setControlValues(IMapObject mapObject) {
    if (mapObject.getCustomProperty(MapObjectProperty.SPRITESHEETNAME) != null) {
        for (int i = 0; i < this.comboBoxSpriteSheets.getModel().getSize(); i++) {
            JLabel label = this.comboBoxSpriteSheets.getModel().getElementAt(i);
            if (label != null && label.getText().equals(mapObject.getCustomProperty(MapObjectProperty.SPRITESHEETNAME))) {
                this.comboBoxSpriteSheets.setSelectedItem(label);
                break;
            }
        }
    }
    final Material material = mapObject.getCustomProperty(MapObjectProperty.PROP_MATERIAL) == null ? Material.UNDEFINED : Material.valueOf(mapObject.getCustomProperty(MapObjectProperty.PROP_MATERIAL));
    this.comboBoxMaterial.setSelectedItem(material);
    final Rotation rotation = mapObject.getCustomProperty(MapObjectProperty.PROP_ROTATION) == null ? Rotation.NONE : Rotation.valueOf(mapObject.getCustomProperty(MapObjectProperty.PROP_ROTATION));
    this.comboBoxRotation.setSelectedItem(rotation);
    this.spinnerHealth.setValue(mapObject.getCustomPropertyInt(MapObjectProperty.HEALTH));
    this.chckbxIndestructible.setSelected(!mapObject.getCustomPropertyBool(MapObjectProperty.PROP_INDESTRUCTIBLE));
    this.chckbxShadow.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_ADDSHADOW));
    this.chckbxIsObstacle.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_OBSTACLE));
    this.checkBoxHorizontalFlip.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_FLIPHORIZONTALLY));
    this.checkBoxVerticalFlip.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_FLIPVERTICALLY));
    this.checkBoxScale.setSelected(mapObject.getCustomPropertyBool(MapObjectProperty.PROP_SCALE));
}
Also used : JLabel(javax.swing.JLabel) Material(de.gurkenlabs.litiengine.entities.Material) Rotation(de.gurkenlabs.litiengine.entities.Rotation)

Aggregations

Material (de.gurkenlabs.litiengine.entities.Material)2 Rotation (de.gurkenlabs.litiengine.entities.Rotation)2 AttributeModifier (de.gurkenlabs.litiengine.attributes.AttributeModifier)1 IEntity (de.gurkenlabs.litiengine.entities.IEntity)1 Prop (de.gurkenlabs.litiengine.entities.Prop)1 JLabel (javax.swing.JLabel)1