use of de.gurkenlabs.litiengine.Direction in project litiengine by gurkenlabs.
the class CreatureAnimationController method getFallbackSpriteName.
private String getFallbackSpriteName(CreatureAnimationState state, Direction dir) {
String fallbackStateName = this.getSpriteName(state.getOpposite(), dir);
if (this.hasAnimation(fallbackStateName)) {
return fallbackStateName;
}
String baseName = this.getSpriteName(state);
if (this.hasAnimation(baseName)) {
return baseName;
}
// search for any animation for the specified state with dir information
for (Direction d : Direction.values()) {
final String name = this.getSpriteName(state, d);
if (this.hasAnimation(name)) {
return name;
}
}
for (Direction d : Direction.values()) {
final String name = this.getSpriteName(state.getOpposite(), d);
if (this.hasAnimation(name)) {
return name;
}
}
return this.getDefault() != null ? this.getDefault().getName() : null;
}
use of de.gurkenlabs.litiengine.Direction in project litiengine by gurkenlabs.
the class CreatureAnimationController method initializeAvailableAnimations.
private void initializeAvailableAnimations() {
for (Direction dir : Direction.values()) {
// initialize walking animations
Spritesheet walkSprite = Resources.spritesheets().get(this.getSpriteName(CreatureAnimationState.WALK, dir));
if (walkSprite != null) {
this.add(new Animation(walkSprite, true));
}
// initialize idle animations
Spritesheet idleSprite = Resources.spritesheets().get(this.getSpriteName(CreatureAnimationState.IDLE, dir));
if (idleSprite != null) {
this.add(new Animation(idleSprite, true));
}
}
Spritesheet deadSprite = Resources.spritesheets().get(this.getSpriteName(CreatureAnimationState.DEAD));
if (deadSprite != null) {
this.add(new Animation(deadSprite, true));
}
Spritesheet baseIdle = Resources.spritesheets().get(this.getSpriteName(CreatureAnimationState.IDLE));
if (baseIdle != null) {
this.add(new Animation(baseIdle, true));
}
Spritesheet baseWalk = Resources.spritesheets().get(this.getSpriteName(CreatureAnimationState.WALK));
if (baseWalk != null) {
this.add(new Animation(baseWalk, true));
}
}
use of de.gurkenlabs.litiengine.Direction in project litiengine by gurkenlabs.
the class SpawnpointMapObjectLoader method load.
@Override
public Collection<IEntity> load(Environment environment, IMapObject mapObject) {
Collection<IEntity> entities = new ArrayList<>();
if (!this.isMatchingType(mapObject)) {
return entities;
}
final Direction direction = mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION) != null ? Direction.valueOf(mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION)) : Direction.DOWN;
final String spawnType = mapObject.getStringValue(MapObjectProperty.SPAWN_INFO);
final Spawnpoint spawn = this.createSpawnpoint(mapObject, direction, spawnType);
loadDefaultProperties(spawn, mapObject);
entities.add(spawn);
return entities;
}
Aggregations