Search in sources :

Example 1 with MobSpriteDef

use of com.watabou.pixeldungeon.sprites.MobSpriteDef in project pixel-dungeon-remix by NYRDS.

the class Mob method sprite.

public CharSprite sprite() {
    try {
        {
            String descName = "spritesDesc/" + getMobClassName() + ".json";
            if (ModdingMode.isResourceExist(descName) || ModdingMode.isAssetExist(descName)) {
                return new MobSpriteDef(descName, getKind());
            }
        }
        if (spriteClass instanceof Class) {
            CharSprite sprite = (CharSprite) ((Class<?>) spriteClass).newInstance();
            sprite.selectKind(getKind());
            return sprite;
        }
        if (spriteClass instanceof String) {
            return new MobSpriteDef((String) spriteClass, getKind());
        }
        throw new TrackedRuntimeException(String.format("sprite creation failed - mob class %s", getMobClassName()));
    } catch (Exception e) {
        throw new TrackedRuntimeException(e);
    }
}
Also used : TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) HeroSubClass(com.watabou.pixeldungeon.actors.hero.HeroSubClass) CharSprite(com.watabou.pixeldungeon.sprites.CharSprite) MobSpriteDef(com.watabou.pixeldungeon.sprites.MobSpriteDef) JSONException(org.json.JSONException) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException)

Aggregations

TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)1 HeroSubClass (com.watabou.pixeldungeon.actors.hero.HeroSubClass)1 CharSprite (com.watabou.pixeldungeon.sprites.CharSprite)1 MobSpriteDef (com.watabou.pixeldungeon.sprites.MobSpriteDef)1 JSONException (org.json.JSONException)1