Search in sources :

Example 31 with Heap

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

the class Hero method onOperateComplete.

@Override
public void onOperateComplete() {
    if (curAction instanceof HeroAction.Unlock) {
        int doorCell = ((HeroAction.Unlock) curAction).dst;
        int door = Dungeon.level.map[doorCell];
        if (door == Terrain.LOCKED_DOOR) {
            Notes.remove(new IronKey(Dungeon.depth));
            Level.set(doorCell, Terrain.DOOR);
        } else {
            Notes.remove(new SkeletonKey(Dungeon.depth));
            Level.set(doorCell, Terrain.UNLOCKED_EXIT);
        }
        GameScene.updateKeyDisplay();
        Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
        GameScene.updateMap(doorCell);
    } else if (curAction instanceof HeroAction.OpenChest) {
        Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst);
        if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
            Sample.INSTANCE.play(Assets.SND_BONES);
        } else if (heap.type == Type.LOCKED_CHEST) {
            Notes.remove(new GoldenKey(Dungeon.depth));
        } else if (heap.type == Type.CRYSTAL_CHEST) {
            Notes.remove(new CrystalKey(Dungeon.depth));
        }
        GameScene.updateKeyDisplay();
        heap.open(this);
    }
    curAction = null;
    super.onOperateComplete();
}
Also used : CrystalKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey) GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) SkeletonKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)

Example 32 with Heap

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

the class WellWater method affect.

protected boolean affect(int pos) {
    Heap heap;
    if (pos == Dungeon.hero.pos && affectHero(Dungeon.hero)) {
        cur[pos] = 0;
        return true;
    } else if ((heap = Dungeon.level.heaps.get(pos)) != null) {
        Item oldItem = heap.peek();
        Item newItem = affectItem(oldItem);
        if (newItem != null) {
            if (newItem == oldItem) {
            } else if (oldItem.quantity() > 1) {
                oldItem.quantity(oldItem.quantity() - 1);
                heap.drop(newItem);
            } else {
                heap.replace(oldItem, newItem);
            }
            heap.sprite.link();
            cur[pos] = 0;
            return true;
        } else {
            int newPlace;
            do {
                newPlace = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
            } while (!Dungeon.level.passable[newPlace] && !Dungeon.level.avoid[newPlace]);
            Dungeon.level.drop(heap.pickUp(), newPlace).sprite.drop(pos);
            return false;
        }
    } else {
        return false;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 33 with Heap

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

the class LootIndicator method update.

@Override
public void update() {
    if (Dungeon.hero.ready) {
        Heap heap = Dungeon.level.heaps.get(Dungeon.hero.pos);
        if (heap != null) {
            Item item = heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST : heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST : heap.type == Heap.Type.CRYSTAL_CHEST ? ItemSlot.CRYSTAL_CHEST : heap.type == Heap.Type.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : heap.type == Heap.Type.REMAINS ? ItemSlot.REMAINS : heap.peek();
            if (item != lastItem || item.quantity() != lastQuantity) {
                lastItem = item;
                lastQuantity = item.quantity();
                slot.item(item);
                flash();
            }
            visible = true;
        } else {
            lastItem = null;
            visible = false;
        }
    }
    slot.enable(visible && Dungeon.hero.ready);
    super.update();
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) 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