Search in sources :

Example 1 with CrystalKey

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

the class Hero method actOpenChest.

private boolean actOpenChest(HeroAction.OpenChest action) {
    int dst = action.dst;
    if (Dungeon.level.adjacent(pos, dst) || pos == dst) {
        Heap heap = Dungeon.level.heaps.get(dst);
        if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) {
            if ((heap.type == Type.LOCKED_CHEST && Notes.keyCount(new GoldenKey(Dungeon.depth)) < 1) || (heap.type == Type.CRYSTAL_CHEST && Notes.keyCount(new CrystalKey(Dungeon.depth)) < 1)) {
                GLog.w(Messages.get(this, "locked_chest"));
                ready();
                return false;
            }
            switch(heap.type) {
                case TOMB:
                    Sample.INSTANCE.play(Assets.SND_TOMB);
                    Camera.main.shake(1, 0.5f);
                    break;
                case SKELETON:
                case REMAINS:
                    break;
                default:
                    Sample.INSTANCE.play(Assets.SND_UNLOCK);
            }
            spend(Key.TIME_TO_UNLOCK);
            sprite.operate(dst);
        } else {
            ready();
        }
        return false;
    } else if (getCloser(dst)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : CrystalKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey) GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 2 with CrystalKey

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

the class VaultRoom method paint.

public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY_SP);
    Painter.fill(level, this, 2, Terrain.EMPTY);
    int cx = (left + right) / 2;
    int cy = (top + bottom) / 2;
    int c = cx + cy * level.width();
    Random.shuffle(prizeClasses);
    Item i1, i2;
    i1 = prize(level);
    i2 = prize(level);
    level.drop(i1, c).type = Heap.Type.CRYSTAL_CHEST;
    level.drop(i2, c + PathFinder.NEIGHBOURS8[Random.Int(8)]).type = Heap.Type.CRYSTAL_CHEST;
    level.addItemToSpawn(new CrystalKey(Dungeon.depth));
    entrance().set(Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey(Dungeon.depth));
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) CrystalKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)

Example 3 with CrystalKey

use of com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey 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)

Aggregations

CrystalKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey)3 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)2 GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)2 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)2 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 SkeletonKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)1