Search in sources :

Example 1 with GoldenKey

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

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

the class RegularLevel method createItems.

@Override
protected void createItems() {
    // drops 3/4/5 items 60%/30%/10% of the time
    int nItems = 3 + Random.chances(new float[] { 6, 3, 1 });
    for (int i = 0; i < nItems; i++) {
        Heap.Type type = null;
        switch(Random.Int(20)) {
            case 0:
                type = Heap.Type.SKELETON;
                break;
            case 1:
            case 2:
            case 3:
            case 4:
                type = Heap.Type.CHEST;
                break;
            case 5:
                type = Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST;
                break;
            default:
                type = Heap.Type.HEAP;
        }
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        Item toDrop = Generator.random();
        if (toDrop == null)
            continue;
        if ((toDrop instanceof Artifact && Random.Int(2) == 0) || (toDrop.isUpgradable() && Random.Int(4 - toDrop.level()) == 0)) {
            Heap dropped = drop(toDrop, cell);
            if (heaps.get(cell) == dropped) {
                dropped.type = Heap.Type.LOCKED_CHEST;
                addItemToSpawn(new GoldenKey(Dungeon.depth));
            }
        } else {
            drop(toDrop, cell).type = type;
        }
    }
    for (Item item : itemsToSpawn) {
        int cell = randomDropCell();
        drop(item, cell).type = Heap.Type.HEAP;
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
    }
    Item item = Bones.get();
    if (item != null) {
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        drop(item, cell).type = Heap.Type.REMAINS;
    }
    // guide pages
    Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages();
    ArrayList<String> missingPages = new ArrayList<>();
    for (String page : allPages) {
        if (!Document.ADVENTURERS_GUIDE.hasPage(page)) {
            missingPages.add(page);
        }
    }
    // these are dropped specially
    missingPages.remove(Document.GUIDE_INTRO_PAGE);
    missingPages.remove(Document.GUIDE_SEARCH_PAGE);
    int foundPages = allPages.size() - (missingPages.size() + 2);
    // chance to find a page scales with pages missing and depth
    if (missingPages.size() > 0 && Random.Float() < (Dungeon.depth / (float) (foundPages + 1))) {
        GuidePage p = new GuidePage();
        p.page(missingPages.get(0));
        int cell = randomDropCell();
        if (map[cell] == Terrain.HIGH_GRASS) {
            map[cell] = Terrain.GRASS;
            losBlocking[cell] = false;
        }
        drop(p, cell);
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) GuidePage(com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage) ArrayList(java.util.ArrayList) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) Artifact(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact)

Example 3 with GoldenKey

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

the class SecretChestChasmRoom method paint.

@Override
public void paint(Level level) {
    super.paint(level);
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.CHASM);
    Point p = new Point(left + 1, top + 1);
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
    p.x = right - 1;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
    p.y = bottom - 1;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
    p.x = left + 1;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
    p = new Point(left + 3, top + 3);
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(Generator.random(), level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
    p.x = right - 3;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(Generator.random(), level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
    p.y = bottom - 3;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(Generator.random(), level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
    p.x = left + 3;
    Painter.set(level, p, Terrain.EMPTY_SP);
    level.drop(Generator.random(), level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
    level.addItemToSpawn(new PotionOfLevitation());
    entrance().set(Door.Type.HIDDEN);
}
Also used : GoldenKey(com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey) PotionOfLevitation(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation) Point(com.watabou.utils.Point)

Example 4 with GoldenKey

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

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

GoldenKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey)5 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)3 CrystalKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.CrystalKey)2 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)2 SkeletonKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey)2 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 Artifact (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact)1 GuidePage (com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage)1 PotionOfLevitation (com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation)1 Point (com.watabou.utils.Point)1 ArrayList (java.util.ArrayList)1