Search in sources :

Example 1 with WndResurrect

use of com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Hero method die.

@Override
public void die(Object cause) {
    curAction = null;
    Ankh ankh = null;
    // look for ankhs in player inventory, prioritize ones which are blessed.
    for (Item item : belongings) {
        if (item instanceof Ankh) {
            if (ankh == null || ((Ankh) item).isBlessed()) {
                ankh = (Ankh) item;
            }
        }
    }
    if (ankh != null && ankh.isBlessed()) {
        this.HP = HT / 4;
        // ensures that you'll get to act first in almost any case, to prevent reviving and then instantly dieing again.
        Buff.detach(this, Paralysis.class);
        spend(-cooldown());
        new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f);
        CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
        ankh.detach(belongings.backpack);
        Sample.INSTANCE.play(Assets.SND_TELEPORT);
        GLog.w(Messages.get(this, "revive"));
        Statistics.ankhsUsed++;
        return;
    }
    Actor.fixTime();
    super.die(cause);
    if (ankh == null) {
        reallyDie(cause);
    } else {
        Dungeon.deleteGame(GamesInProgress.curSlot, false);
        GameScene.show(new WndResurrect(ankh, cause));
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) WndTradeItem(com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem) WndResurrect(com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Ankh(com.shatteredpixel.shatteredpixeldungeon.items.Ankh)

Aggregations

Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 WndResurrect (com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect)1 WndTradeItem (com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem)1