Search in sources :

Example 6 with Heap

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

the class CursingTrap method activate.

@Override
public void activate() {
    if (Dungeon.level.heroFOV[pos]) {
        CellEmitter.get(pos).burst(ShadowParticle.UP, 5);
        Sample.INSTANCE.play(Assets.SND_CURSED);
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        for (Item item : heap.items) {
            if (item.isUpgradable())
                curse(item);
        }
    }
    if (Dungeon.hero.pos == pos) {
        curse(Dungeon.hero);
    }
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 7 with Heap

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

the class DisintegrationTrap method activate.

@Override
public void activate() {
    Char target = Actor.findChar(pos);
    // find the closest char that can be aimed at
    if (target == null) {
        for (Char ch : Actor.chars()) {
            Ballistica bolt = new Ballistica(pos, ch.pos, Ballistica.PROJECTILE);
            if (bolt.collisionPos == ch.pos && (target == null || Dungeon.level.trueDistance(pos, ch.pos) < Dungeon.level.trueDistance(pos, target.pos))) {
                target = ch;
            }
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null)
        heap.explode();
    if (target != null) {
        if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[target.pos]) {
            Sample.INSTANCE.play(Assets.SND_RAY);
            ShatteredPixelDungeon.scene().add(new Beam.DeathRay(DungeonTilemap.tileCenterToWorld(pos), target.sprite.center()));
        }
        target.damage(Math.max(target.HT / 5, Random.Int(target.HP / 2, 2 * target.HP / 3)), this);
        if (target == Dungeon.hero) {
            Hero hero = (Hero) target;
            if (!hero.isAlive()) {
                Dungeon.fail(getClass());
                GLog.n(Messages.get(this, "ondeath"));
            } else {
                Item item = hero.belongings.randomUnequipped();
                Bag bag = hero.belongings.backpack;
                // bags do not protect against this trap
                if (item instanceof Bag) {
                    bag = (Bag) item;
                    item = Random.element(bag.items);
                }
                if (item == null || item.level() > 0 || item.unique)
                    return;
                if (!item.stackable) {
                    item.detachAll(bag);
                    GLog.w(Messages.get(this, "one", item.name()));
                } else {
                    int n = Random.NormalIntRange(1, (item.quantity() + 1) / 2);
                    for (int i = 1; i <= n; i++) item.detach(bag);
                    GLog.w(Messages.get(this, "some", item.name()));
                }
            }
        }
    }
}
Also used : Beam(com.shatteredpixel.shatteredpixeldungeon.effects.Beam) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Ballistica(com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Bag(com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 8 with Heap

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

the class WarpingTrap method activate.

@Override
public void activate() {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
        BArray.setFalse(Dungeon.level.visited);
        BArray.setFalse(Dungeon.level.mapped);
        GameScene.updateFog();
        Dungeon.observe();
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1 || Dungeon.bossLevel()) {
            GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
        } else {
            ch.pos = pos;
            if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            }
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[pos];
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        Item item = heap.pickUp();
        if (cell != -1) {
            Dungeon.level.drop(item, cell);
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 9 with Heap

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

the class Fire method burn.

private void burn(int pos) {
    Char ch = Actor.findChar(pos);
    if (ch != null && !ch.isImmune(this.getClass())) {
        Buff.affect(ch, Burning.class).reignite(ch);
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        heap.burn();
    }
    Plant plant = Dungeon.level.plants.get(pos);
    if (plant != null) {
        plant.wither();
    }
}
Also used : Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Burning(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning)

Example 10 with Heap

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

the class Freezing method evolve.

@Override
protected void evolve() {
    boolean[] water = Dungeon.level.water;
    int cell;
    Fire fire = (Fire) Dungeon.level.blobs.get(Fire.class);
    for (int i = area.left - 1; i <= area.right; i++) {
        for (int j = area.top - 1; j <= area.bottom; j++) {
            cell = i + j * Dungeon.level.width();
            if (cur[cell] > 0) {
                if (fire != null && fire.volume > 0 && fire.cur[cell] > 0) {
                    fire.clear(cell);
                    off[cell] = cur[cell] = 0;
                    continue;
                }
                Char ch = Actor.findChar(cell);
                if (ch != null && !ch.isImmune(this.getClass())) {
                    if (ch.buff(Frost.class) != null) {
                        Buff.affect(ch, Frost.class, 2f);
                    } else {
                        Buff.affect(ch, Chill.class, water[cell] ? 5f : 3f);
                        Chill chill = ch.buff(Chill.class);
                        if (chill != null && chill.cooldown() >= 10f) {
                            Buff.affect(ch, Frost.class, 5f);
                        }
                    }
                }
                Heap heap = Dungeon.level.heaps.get(cell);
                if (heap != null)
                    heap.freeze();
                off[cell] = cur[cell] - 1;
                volume += off[cell];
            } else {
                off[cell] = 0;
            }
        }
    }
}
Also used : Chill(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Frost(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Aggregations

Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)33 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)14 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)13 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)11 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)5 GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)4 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)4 ArrayList (java.util.ArrayList)4 CrystalKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey)3 Blob (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob)2 Awareness (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness)2 Chill (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill)2 Frost (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost)2 MindVision (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision)2 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)2 SkeletonKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)2 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)2 CustomTiledVisual (com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual)2 WndInfoMob (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob)2 WndInfoPlant (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant)2