Search in sources :

Example 11 with IronKey

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

the class Belongings method restoreFromBundle.

public void restoreFromBundle(Bundle bundle) {
    // moving keys to Notes, for pre-0.6.1 saves
    if (bundle.contains("ironKeys")) {
        int[] ironKeys = bundle.getIntArray("ironKeys");
        for (int i = 0; i < ironKeys.length; i++) {
            if (ironKeys[i] > 0) {
                Notes.add((Key) new IronKey(i).quantity(ironKeys[i]));
            }
        }
    }
    if (bundle.contains("specialKeys")) {
        int[] specialKeys = bundle.getIntArray("specialKeys");
        for (int i = 0; i < specialKeys.length; i++) {
            if (specialKeys[i] > 0) {
                if (i % 5 == 0) {
                    Notes.add((Key) new SkeletonKey(i).quantity(specialKeys[i]));
                } else {
                    Notes.add((Key) new GoldenKey(i).quantity(specialKeys[i]));
                }
            }
        }
    }
    backpack.clear();
    backpack.restoreFromBundle(bundle);
    weapon = (KindOfWeapon) bundle.get(WEAPON);
    if (weapon != null) {
        weapon.activate(owner);
    }
    armor = (Armor) bundle.get(ARMOR);
    if (armor != null) {
        armor.activate(owner);
    }
    misc1 = (KindofMisc) bundle.get(MISC1);
    if (misc1 != null) {
        misc1.activate(owner);
    }
    misc2 = (KindofMisc) bundle.get(MISC2);
    if (misc2 != null) {
        misc2.activate(owner);
    }
}
Also used : GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) SkeletonKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)

Example 12 with IronKey

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

the class Hero method actUnlock.

private boolean actUnlock(HeroAction.Unlock action) {
    int doorCell = action.dst;
    if (Dungeon.level.adjacent(pos, doorCell)) {
        boolean hasKey = false;
        int door = Dungeon.level.map[doorCell];
        if (door == Terrain.LOCKED_DOOR && Notes.keyCount(new IronKey(Dungeon.depth)) > 0) {
            hasKey = true;
        } else if (door == Terrain.LOCKED_EXIT && Notes.keyCount(new SkeletonKey(Dungeon.depth)) > 0) {
            hasKey = true;
        }
        if (hasKey) {
            spend(Key.TIME_TO_UNLOCK);
            sprite.operate(doorCell);
            Sample.INSTANCE.play(Assets.SND_UNLOCK);
        } else {
            GLog.w(Messages.get(this, "locked_door"));
            ready();
        }
        return false;
    } else if (getCloser(doorCell)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : IronKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey) SkeletonKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)

Example 13 with IronKey

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

IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)13 Point (com.watabou.utils.Point)5 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)4 SkeletonKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)3 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)2 CrystalKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey)2 GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)2 Alchemy (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy)1 RotHeart (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.RotHeart)1 RotLasher (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.RotLasher)1 Statue (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue)1 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)1 ScrollOfIdentify (com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify)1 ScrollOfRemoveCurse (com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse)1