Search in sources :

Example 1 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class Level method create.

public void create() {
    resizingNeeded = false;
    map = new int[LENGTH];
    visited = new boolean[LENGTH];
    Arrays.fill(visited, false);
    mapped = new boolean[LENGTH];
    Arrays.fill(mapped, false);
    mobs = new HashSet<Mob>();
    heaps = new SparseArray<Heap>();
    blobs = new HashMap<Class<? extends Blob>, Blob>();
    plants = new SparseArray<Plant>();
    if (!Dungeon.bossLevel()) {
        addItemToSpawn(Generator.random(Generator.Category.FOOD));
        if (Dungeon.posNeeded()) {
            addItemToSpawn(new PotionOfStrength());
            Dungeon.potionOfStrength++;
        }
        if (Dungeon.souNeeded()) {
            addItemToSpawn(new ScrollOfUpgrade());
            Dungeon.scrollsOfUpgrade++;
        }
        if (Dungeon.soeNeeded()) {
            addItemToSpawn(new ScrollOfEnchantment());
            Dungeon.scrollsOfEnchantment++;
        }
        if (Dungeon.depth > 1) {
            switch(Random.Int(10)) {
                case 0:
                    if (!Dungeon.bossLevel(Dungeon.depth + 1)) {
                        feeling = Feeling.CHASM;
                    }
                    break;
                case 1:
                    feeling = Feeling.WATER;
                    break;
                case 2:
                    feeling = Feeling.GRASS;
                    break;
            }
        }
    }
    boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
    do {
        Arrays.fill(map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
        pitRoomNeeded = pitNeeded;
        weakFloorCreated = false;
    } while (!build());
    decorate();
    buildFlagMaps();
    cleanWalls();
    createMobs();
    createItems();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) ScrollOfEnchantment(com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment) PotionOfStrength(com.watabou.pixeldungeon.items.potions.PotionOfStrength) Heap(com.watabou.pixeldungeon.items.Heap) Plant(com.watabou.pixeldungeon.plants.Plant) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 2 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class Level method drop.

public Heap drop(Item item, int cell) {
    if (Dungeon.isChallenged(Challenges.NO_FOOD) && item instanceof Food) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HERBALISM) && item instanceof SeedPouch) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_SCROLLS) && (item instanceof Scroll || item instanceof ScrollHolder)) {
        if (item instanceof ScrollOfUpgrade) {
        // These scrolls still can be found
        } else {
            item = new Gold(item.price());
        }
    }
    if ((map[cell] == Terrain.ALCHEMY) && !(item instanceof Plant.Seed)) {
        int n;
        do {
            n = cell + NEIGHBOURS8[Random.Int(8)];
        } while (map[n] != Terrain.EMPTY_SP);
        cell = n;
    }
    Heap heap = heaps.get(cell);
    if (heap == null) {
        heap = new Heap();
        heap.pos = cell;
        if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
            Dungeon.dropToChasm(item);
            GameScene.discard(heap);
        } else {
            heaps.put(cell, heap);
            GameScene.add(heap);
        }
    } else if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
        int n;
        do {
            n = cell + Level.NEIGHBOURS8[Random.Int(8)];
        } while (!Level.passable[n] && !Level.avoid[n]);
        return drop(item, n);
    }
    heap.drop(item);
    if (Dungeon.level != null) {
        press(cell, null);
    }
    return heap;
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Plant(com.watabou.pixeldungeon.plants.Plant) Armor(com.watabou.pixeldungeon.items.armor.Armor) SeedPouch(com.watabou.pixeldungeon.items.bags.SeedPouch) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) PotionOfHealing(com.watabou.pixeldungeon.items.potions.PotionOfHealing) ScrollHolder(com.watabou.pixeldungeon.items.bags.ScrollHolder) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade) Heap(com.watabou.pixeldungeon.items.Heap) Food(com.watabou.pixeldungeon.items.food.Food)

Example 3 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class ScrollOfChallenge method doRead.

@Override
protected void doRead() {
    for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
        mob.beckon(curUser.pos);
        if (Dungeon.visible[mob.pos]) {
            Buff.affect(mob, Rage.class, Level.distance(curUser.pos, mob.pos));
        }
    }
    for (Heap heap : Dungeon.level.heaps.values()) {
        if (heap.type == Heap.Type.MIMIC) {
            Mimic m = Mimic.spawnAt(heap.pos, heap.items);
            if (m != null) {
                m.beckon(curUser.pos);
                heap.destroy();
            }
        }
    }
    GLog.w("The scroll emits a challenging roar that echoes throughout the dungeon!");
    setKnown();
    curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
    Sample.INSTANCE.play(Assets.SND_CHALLENGE);
    Invisibility.dispel();
    readAnimation();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) Mimic(com.watabou.pixeldungeon.actors.mobs.Mimic) Heap(com.watabou.pixeldungeon.items.Heap)

Example 4 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class RatKingPainter method paint.

public static void paint(Level level, Room room) {
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Terrain.EMPTY_SP);
    Room.Door entrance = room.entrance();
    entrance.set(Room.Door.Type.HIDDEN);
    int door = entrance.x + entrance.y * Level.WIDTH;
    for (int i = room.left + 1; i < room.right; i++) {
        addChest(level, (room.top + 1) * Level.WIDTH + i, door);
        addChest(level, (room.bottom - 1) * Level.WIDTH + i, door);
    }
    for (int i = room.top + 2; i < room.bottom - 1; i++) {
        addChest(level, i * Level.WIDTH + room.left + 1, door);
        addChest(level, i * Level.WIDTH + room.right - 1, door);
    }
    while (true) {
        Heap chest = level.heaps.get(room.random());
        if (chest != null) {
            chest.type = Heap.Type.MIMIC;
            break;
        }
    }
    RatKing king = new RatKing();
    king.pos = room.random(1);
    level.mobs.add(king);
}
Also used : RatKing(com.watabou.pixeldungeon.actors.mobs.npcs.RatKing) Room(com.watabou.pixeldungeon.levels.Room) Heap(com.watabou.pixeldungeon.items.Heap)

Example 5 with Heap

use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.

the class ScrollOfWipeOut method doRead.

private void doRead() {
    GameScene.flash(0xFF6644);
    Invisibility.dispel();
    for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
        if (!Bestiary.isBoss(mob)) {
            Sample.INSTANCE.play(Assets.SND_CURSED, 0.3f, 0.3f, Random.Float(0.6f, 0.9f));
            mob.die(this);
        }
    }
    for (Heap heap : Dungeon.level.heaps.values()) {
        switch(heap.type) {
            case FOR_SALE:
                heap.type = Type.HEAP;
                if (Dungeon.visible[heap.pos]) {
                    CellEmitter.center(heap.pos).burst(Speck.factory(Speck.COIN), 2);
                }
                break;
            case MIMIC:
                heap.type = Type.HEAP;
                heap.sprite.link();
                Sample.INSTANCE.play(Assets.SND_CURSED, 0.3f, 0.3f, Random.Float(0.6f, 0.9f));
                break;
            default:
        }
    }
    curUser.spend(TIME_TO_READ);
    curUser.busy();
    ((HeroSprite) curUser.sprite).read();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) HeroSprite(com.watabou.pixeldungeon.sprites.HeroSprite) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

Heap (com.watabou.pixeldungeon.items.Heap)20 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)6 Char (com.watabou.pixeldungeon.actors.Char)4 Item (com.watabou.pixeldungeon.items.Item)3 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)3 Plant (com.watabou.pixeldungeon.plants.Plant)3 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)2 Buff (com.watabou.pixeldungeon.actors.buffs.Buff)2 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)2 PotionOfStrength (com.watabou.pixeldungeon.items.potions.PotionOfStrength)2 ScrollOfEnchantment (com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment)2 WndTradeItem (com.watabou.pixeldungeon.windows.WndTradeItem)2 Awareness (com.watabou.pixeldungeon.actors.buffs.Awareness)1 Blindness (com.watabou.pixeldungeon.actors.buffs.Blindness)1 Burning (com.watabou.pixeldungeon.actors.buffs.Burning)1 MindVision (com.watabou.pixeldungeon.actors.buffs.MindVision)1 Shadows (com.watabou.pixeldungeon.actors.buffs.Shadows)1 Mimic (com.watabou.pixeldungeon.actors.mobs.Mimic)1 NPC (com.watabou.pixeldungeon.actors.mobs.npcs.NPC)1 RatKing (com.watabou.pixeldungeon.actors.mobs.npcs.RatKing)1