Search in sources :

Example 1 with ScrollOfUpgrade

use of com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade 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 ScrollOfUpgrade

use of com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade 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 ScrollOfUpgrade

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

the class Hero method actPickUp.

private boolean actPickUp(HeroAction.PickUp action) {
    int dst = action.dst;
    if (pos == dst) {
        Heap heap = Dungeon.level.heaps.get(pos);
        if (heap != null) {
            Item item = heap.pickUp();
            if (item.doPickUp(this)) {
                if (item instanceof Dewdrop) {
                // Do nothing
                } else {
                    boolean important = ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll) item).isKnown()) || ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion) item).isKnown());
                    if (important) {
                        GLog.p(TXT_YOU_NOW_HAVE, item.name());
                    } else {
                        GLog.i(TXT_YOU_NOW_HAVE, item.name());
                    }
                }
                if (!heap.isEmpty()) {
                    GLog.i(TXT_SOMETHING_ELSE);
                }
                curAction = null;
            } else {
                Dungeon.level.drop(item, pos).sprite.drop();
                ready();
            }
        } else {
            ready();
        }
        return false;
    } else if (getCloser(dst)) {
        return true;
    } else {
        ready();
        return false;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) WndTradeItem(com.watabou.pixeldungeon.windows.WndTradeItem) PotionOfMight(com.watabou.pixeldungeon.items.potions.PotionOfMight) ScrollOfEnchantment(com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment) PotionOfStrength(com.watabou.pixeldungeon.items.potions.PotionOfStrength) Dewdrop(com.watabou.pixeldungeon.items.Dewdrop) Heap(com.watabou.pixeldungeon.items.Heap) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)

Example 4 with ScrollOfUpgrade

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

the class RegularLevel method createItems.

@Override
protected void createItems() {
    int nItems = 3;
    while (Random.Float() < 0.4f) {
        nItems++;
    }
    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;
        }
        drop(Generator.random(), randomDropCell()).type = type;
    }
    for (Item item : itemsToSpawn) {
        int cell = randomDropCell();
        if (item instanceof ScrollOfUpgrade) {
            while (map[cell] == Terrain.FIRE_TRAP || map[cell] == Terrain.SECRET_FIRE_TRAP) {
                cell = randomDropCell();
            }
        }
        drop(item, cell).type = Heap.Type.HEAP;
    }
    Item item = Bones.get();
    if (item != null) {
        drop(item, randomDropCell()).type = Heap.Type.SKELETON;
    }
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Heap(com.watabou.pixeldungeon.items.Heap) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)

Aggregations

Heap (com.watabou.pixeldungeon.items.Heap)4 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)4 Item (com.watabou.pixeldungeon.items.Item)2 PotionOfStrength (com.watabou.pixeldungeon.items.potions.PotionOfStrength)2 ScrollOfEnchantment (com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment)2 Plant (com.watabou.pixeldungeon.plants.Plant)2 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)1 HeroClass (com.watabou.pixeldungeon.actors.hero.HeroClass)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Dewdrop (com.watabou.pixeldungeon.items.Dewdrop)1 Gold (com.watabou.pixeldungeon.items.Gold)1 Armor (com.watabou.pixeldungeon.items.armor.Armor)1 ScrollHolder (com.watabou.pixeldungeon.items.bags.ScrollHolder)1 SeedPouch (com.watabou.pixeldungeon.items.bags.SeedPouch)1 Food (com.watabou.pixeldungeon.items.food.Food)1 PotionOfHealing (com.watabou.pixeldungeon.items.potions.PotionOfHealing)1 PotionOfMight (com.watabou.pixeldungeon.items.potions.PotionOfMight)1 Scroll (com.watabou.pixeldungeon.items.scrolls.Scroll)1 WndTradeItem (com.watabou.pixeldungeon.windows.WndTradeItem)1