Search in sources :

Example 1 with Hunger

use of com.watabou.pixeldungeon.actors.buffs.Hunger in project pixel-dungeon by watabou.

the class Hero method actDescend.

private boolean actDescend(HeroAction.Descend action) {
    int stairs = action.dst;
    if (pos == stairs && pos == Dungeon.level.exit) {
        curAction = null;
        Hunger hunger = buff(Hunger.class);
        if (hunger != null && !hunger.isStarving()) {
            hunger.satisfy(-Hunger.STARVING / 10);
        }
        InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
        Game.switchScene(InterlevelScene.class);
        return false;
    } else if (getCloser(stairs)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Hunger(com.watabou.pixeldungeon.actors.buffs.Hunger)

Example 2 with Hunger

use of com.watabou.pixeldungeon.actors.buffs.Hunger in project pixel-dungeon by watabou.

the class Metabolism method proc.

@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {
    int level = Math.max(0, armor.effectiveLevel());
    if (Random.Int(level / 2 + 5) >= 4) {
        int healing = Math.min(defender.HT - defender.HP, Random.Int(1, defender.HT / 5));
        if (healing > 0) {
            Hunger hunger = defender.buff(Hunger.class);
            if (hunger != null && !hunger.isStarving()) {
                hunger.satisfy(-Hunger.STARVING / 10);
                BuffIndicator.refreshHero();
                defender.HP += healing;
                defender.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
                defender.sprite.showStatus(CharSprite.POSITIVE, Integer.toString(healing));
            }
        }
    }
    return damage;
}
Also used : Hunger(com.watabou.pixeldungeon.actors.buffs.Hunger)

Example 3 with Hunger

use of com.watabou.pixeldungeon.actors.buffs.Hunger in project pixel-dungeon by watabou.

the class Pickaxe method execute.

@Override
public void execute(final Hero hero, String action) {
    if (action == AC_MINE) {
        if (Dungeon.depth < 11 || Dungeon.depth > 15) {
            GLog.w(TXT_NO_VEIN);
            return;
        }
        for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
            final int pos = hero.pos + Level.NEIGHBOURS8[i];
            if (Dungeon.level.map[pos] == Terrain.WALL_DECO) {
                hero.spend(TIME_TO_MINE);
                hero.busy();
                hero.sprite.attack(pos, new Callback() {

                    @Override
                    public void call() {
                        CellEmitter.center(pos).burst(Speck.factory(Speck.STAR), 7);
                        Sample.INSTANCE.play(Assets.SND_EVOKE);
                        Level.set(pos, Terrain.WALL);
                        GameScene.updateMap(pos);
                        DarkGold gold = new DarkGold();
                        if (gold.doPickUp(Dungeon.hero)) {
                            GLog.i(Hero.TXT_YOU_NOW_HAVE, gold.name());
                        } else {
                            Dungeon.level.drop(gold, hero.pos).sprite.drop();
                        }
                        Hunger hunger = hero.buff(Hunger.class);
                        if (hunger != null && !hunger.isStarving()) {
                            hunger.satisfy(-Hunger.STARVING / 10);
                            BuffIndicator.refreshHero();
                        }
                        hero.onOperateComplete();
                    }
                });
                return;
            }
        }
        GLog.w(TXT_NO_VEIN);
    } else {
        super.execute(hero, action);
    }
}
Also used : Hunger(com.watabou.pixeldungeon.actors.buffs.Hunger) Callback(com.watabou.utils.Callback)

Example 4 with Hunger

use of com.watabou.pixeldungeon.actors.buffs.Hunger in project pixel-dungeon by watabou.

the class Hero method actAscend.

private boolean actAscend(HeroAction.Ascend action) {
    int stairs = action.dst;
    if (pos == stairs && pos == Dungeon.level.entrance) {
        if (Dungeon.depth == 1) {
            if (belongings.getItem(Amulet.class) == null) {
                GameScene.show(new WndMessage(TXT_LEAVE));
                ready();
            } else {
                Dungeon.win(ResultDescriptions.WIN);
                Dungeon.deleteGame(Dungeon.hero.heroClass, true);
                Game.switchScene(SurfaceScene.class);
            }
        } else {
            curAction = null;
            Hunger hunger = buff(Hunger.class);
            if (hunger != null && !hunger.isStarving()) {
                hunger.satisfy(-Hunger.STARVING / 10);
            }
            InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
            Game.switchScene(InterlevelScene.class);
        }
        return false;
    } else if (getCloser(stairs)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Hunger(com.watabou.pixeldungeon.actors.buffs.Hunger) Amulet(com.watabou.pixeldungeon.items.Amulet) WndMessage(com.watabou.pixeldungeon.windows.WndMessage)

Aggregations

Hunger (com.watabou.pixeldungeon.actors.buffs.Hunger)4 Amulet (com.watabou.pixeldungeon.items.Amulet)1 WndMessage (com.watabou.pixeldungeon.windows.WndMessage)1 Callback (com.watabou.utils.Callback)1