Search in sources :

Example 31 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.

the class Dungeon method init.

public static void init() {
    challenges = PixelDungeon.challenges();
    Actor.clear();
    PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT);
    Scroll.initLabels();
    Potion.initColors();
    Wand.initWoods();
    Ring.initGems();
    Statistics.reset();
    Journal.reset();
    depth = 0;
    gold = 0;
    droppedItems = new SparseArray<ArrayList<Item>>();
    potionOfStrength = 0;
    scrollsOfUpgrade = 0;
    scrollsOfEnchantment = 0;
    dewVial = true;
    chapters = new HashSet<Integer>();
    Ghost.Quest.reset();
    Wandmaker.Quest.reset();
    Blacksmith.Quest.reset();
    Imp.Quest.reset();
    Room.shuffleTypes();
    QuickSlot.primaryValue = null;
    QuickSlot.secondaryValue = null;
    hero = new Hero();
    hero.live();
    Badges.reset();
    StartScene.curClass.initHero(hero);
}
Also used : ArrayList(java.util.ArrayList) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 32 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.

the class Burning method act.

@Override
public boolean act() {
    if (target.isAlive()) {
        if (target instanceof Hero) {
            Buff.prolong(target, Light.class, TICK * 1.01f);
        }
        target.damage(Random.Int(1, 5), this);
        if (target instanceof Hero) {
            Item item = ((Hero) target).belongings.randomUnequipped();
            if (item instanceof Scroll) {
                item = item.detach(((Hero) target).belongings.backpack);
                GLog.w(TXT_BURNS_UP, item.toString());
                Heap.burnFX(target.pos);
            } else if (item instanceof MysteryMeat) {
                item = item.detach(((Hero) target).belongings.backpack);
                ChargrilledMeat steak = new ChargrilledMeat();
                if (!steak.collect(((Hero) target).belongings.backpack)) {
                    Dungeon.level.drop(steak, target.pos).sprite.drop();
                }
                GLog.w(TXT_BURNS_UP, item.toString());
                Heap.burnFX(target.pos);
            }
        } else if (target instanceof Thief && ((Thief) target).item instanceof Scroll) {
            ((Thief) target).item = null;
            target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
        }
    } else {
        detach();
    }
    if (Level.flamable[target.pos]) {
        GameScene.add(Blob.seed(target.pos, 4, Fire.class));
    }
    spend(TICK);
    left -= TICK;
    if (left <= 0 || Random.Float() > (2 + (float) target.HP / target.HT) / 3 || (Level.water[target.pos] && !target.flying)) {
        detach();
    }
    return true;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) ChargrilledMeat(com.watabou.pixeldungeon.items.food.ChargrilledMeat) Thief(com.watabou.pixeldungeon.actors.mobs.Thief) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) Fire(com.watabou.pixeldungeon.actors.blobs.Fire) Hero(com.watabou.pixeldungeon.actors.hero.Hero) MysteryMeat(com.watabou.pixeldungeon.items.food.MysteryMeat)

Example 33 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon by watabou.

the class Frost method attachTo.

@Override
public boolean attachTo(Char target) {
    if (super.attachTo(target)) {
        target.paralysed = true;
        Burning.detach(target, Burning.class);
        if (target instanceof Hero) {
            Hero hero = (Hero) target;
            Item item = hero.belongings.randomUnequipped();
            if (item instanceof MysteryMeat) {
                item = item.detach(hero.belongings.backpack);
                FrozenCarpaccio carpaccio = new FrozenCarpaccio();
                if (!carpaccio.collect(hero.belongings.backpack)) {
                    Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) FrozenCarpaccio(com.watabou.pixeldungeon.items.food.FrozenCarpaccio) Hero(com.watabou.pixeldungeon.actors.hero.Hero) MysteryMeat(com.watabou.pixeldungeon.items.food.MysteryMeat)

Example 34 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class AttackIndicator method checkEnemies.

private void checkEnemies() {
    Hero hero = Dungeon.hero;
    candidates.clear();
    int v = hero.visibleEnemies();
    for (int i = 0; i < v; i++) {
        Mob mob = hero.visibleEnemy(i);
        if (hero.canAttack(mob) && !mob.friendly(hero)) {
            candidates.add(mob);
        }
    }
    if (!candidates.contains(lastTarget)) {
        if (candidates.isEmpty()) {
            lastTarget = null;
        } else {
            lastTarget = Random.element(candidates);
            updateImage();
            flash();
        }
    } else {
        if (!bg.getVisible()) {
            flash();
        }
    }
    visible(lastTarget != null);
    enable(bg.getVisible());
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Example 35 with Hero

use of com.watabou.pixeldungeon.actors.hero.Hero in project pixel-dungeon-remix by NYRDS.

the class Fadeleaf method effect.

public void effect(int pos, Char ch) {
    if (ch instanceof Hero) {
        Hero hero = (Hero) ch;
        ScrollOfTeleportation.teleportHero(hero);
        hero.spendAndNext(1);
        hero.curAction = null;
    } else if (ch instanceof Mob && ch.isMovable()) {
        int newPos = Dungeon.level.randomRespawnCell();
        if (Dungeon.level.cellValid(newPos)) {
            ch.setPos(newPos);
            ch.getSprite().place(ch.getPos());
            ch.getSprite().setVisible(Dungeon.visible[pos]);
        }
    }
    if (Dungeon.visible[pos]) {
        CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    }
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Hero(com.watabou.pixeldungeon.actors.hero.Hero)

Aggregations

Hero (com.watabou.pixeldungeon.actors.hero.Hero)44 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)8 Item (com.watabou.pixeldungeon.items.Item)8 Char (com.watabou.pixeldungeon.actors.Char)6 Gold (com.watabou.pixeldungeon.items.Gold)5 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)4 BlackSkull (com.nyrds.pixeldungeon.items.necropolis.BlackSkull)2 Fire (com.watabou.pixeldungeon.actors.blobs.Fire)2 Barkskin (com.watabou.pixeldungeon.actors.buffs.Barkskin)2 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)2 Thief (com.watabou.pixeldungeon.actors.mobs.Thief)2 Dewdrop (com.watabou.pixeldungeon.items.Dewdrop)2 KindOfWeapon (com.watabou.pixeldungeon.items.KindOfWeapon)2 MysteryMeat (com.watabou.pixeldungeon.items.food.MysteryMeat)2 Herbalism (com.watabou.pixeldungeon.items.rings.RingOfHerbalism.Herbalism)2 RingOfSatiety (com.watabou.pixeldungeon.items.rings.RingOfSatiety)2 Knuckles (com.watabou.pixeldungeon.items.weapon.melee.Knuckles)2 Level (com.watabou.pixeldungeon.levels.Level)2 SuppressLint (android.annotation.SuppressLint)1 TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1