Search in sources :

Example 51 with Item

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

the class TeleportationTrap method activate.

@Override
public void activate() {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    Char ch = Actor.findChar(pos);
    if (ch instanceof Hero) {
        ScrollOfTeleportation.teleportHero((Hero) ch);
    } else if (ch != null) {
        int count = 10;
        int pos;
        do {
            pos = Dungeon.level.randomRespawnCell();
            if (count-- <= 0) {
                break;
            }
        } while (pos == -1);
        if (pos == -1 || Dungeon.bossLevel()) {
            GLog.w(Messages.get(ScrollOfTeleportation.class, "no_tele"));
        } else {
            ch.pos = pos;
            if (ch instanceof Mob && ((Mob) ch).state == ((Mob) ch).HUNTING) {
                ((Mob) ch).state = ((Mob) ch).WANDERING;
            }
            ch.sprite.place(ch.pos);
            ch.sprite.visible = Dungeon.level.heroFOV[pos];
        }
    }
    Heap heap = Dungeon.level.heaps.get(pos);
    if (heap != null) {
        int cell = Dungeon.level.randomRespawnCell();
        Item item = heap.pickUp();
        if (cell != -1) {
            Dungeon.level.drop(item, cell);
        }
    }
}
Also used : Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 52 with Item

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

the class StudyRoom method paint.

@Override
public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.BOOKSHELF);
    Painter.fill(level, this, 2, Terrain.EMPTY_SP);
    for (Door door : connected.values()) {
        Painter.drawInside(level, this, door, 2, Terrain.EMPTY_SP);
        door.set(Door.Type.REGULAR);
    }
    // TODO add support for giant size as well
    if (sizeCat == SizeCategory.LARGE) {
        int pillarW = (width() - 7) / 2;
        int pillarH = (height() - 7) / 2;
        Painter.fill(level, left + 3, top + 3, pillarW, 1, Terrain.BOOKSHELF);
        Painter.fill(level, left + 3, top + 3, 1, pillarH, Terrain.BOOKSHELF);
        Painter.fill(level, left + 3, bottom - 2 - 1, pillarW, 1, Terrain.BOOKSHELF);
        Painter.fill(level, left + 3, bottom - 2 - pillarH, 1, pillarH, Terrain.BOOKSHELF);
        Painter.fill(level, right - 2 - pillarW, top + 3, pillarW, 1, Terrain.BOOKSHELF);
        Painter.fill(level, right - 2 - 1, top + 3, 1, pillarH, Terrain.BOOKSHELF);
        Painter.fill(level, right - 2 - pillarW, bottom - 2 - 1, pillarW, 1, Terrain.BOOKSHELF);
        Painter.fill(level, right - 2 - 1, bottom - 2 - pillarH, 1, pillarH, Terrain.BOOKSHELF);
    }
    Point center = center();
    Painter.set(level, center, Terrain.PEDESTAL);
    Item prize = (Random.Int(2) == 0) ? level.findPrizeItem() : null;
    if (prize != null) {
        level.drop(prize, (center.x + center.y * level.width()));
    } else {
        level.drop(Generator.random(Random.oneOf(Generator.Category.POTION, Generator.Category.SCROLL)), (center.x + center.y * level.width()));
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 53 with Item

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

the class CursedWand method veryRareEffect.

private static void veryRareEffect(final Wand wand, final Hero user, final Ballistica bolt) {
    switch(Random.Int(4)) {
        // great forest fire!
        case 0:
            for (int i = 0; i < Dungeon.level.length(); i++) {
                int c = Dungeon.level.map[i];
                if (c == Terrain.EMPTY || c == Terrain.EMBERS || c == Terrain.EMPTY_DECO || c == Terrain.GRASS || c == Terrain.HIGH_GRASS) {
                    GameScene.add(Blob.seed(i, 15, Regrowth.class));
                }
            }
            do {
                GameScene.add(Blob.seed(Dungeon.level.randomDestination(), 10, Fire.class));
            } while (Random.Int(5) != 0);
            new Flare(8, 32).color(0xFFFF66, true).show(user.sprite, 2f);
            Sample.INSTANCE.play(Assets.SND_TELEPORT);
            GLog.p(Messages.get(CursedWand.class, "grass"));
            GLog.w(Messages.get(CursedWand.class, "fire"));
            wand.wandUsed();
            break;
        // superpowered mimic
        case 1:
            cursedFX(user, bolt, new Callback() {

                public void call() {
                    Mimic mimic = Mimic.spawnAt(bolt.collisionPos, new ArrayList<Item>());
                    if (mimic != null) {
                        mimic.adjustStats(Dungeon.depth + 10);
                        mimic.HP = mimic.HT;
                        Item reward;
                        do {
                            reward = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.WAND));
                        } while (reward.level() < 1);
                        Sample.INSTANCE.play(Assets.SND_MIMIC, 1, 1, 0.5f);
                        mimic.items.clear();
                        mimic.items.add(reward);
                    } else {
                        GLog.i(Messages.get(CursedWand.class, "nothing"));
                    }
                    wand.wandUsed();
                }
            });
            break;
        // crashes the game, yes, really.
        case 2:
            try {
                Dungeon.saveAll();
                if (Messages.lang() != Languages.ENGLISH) {
                    // Don't bother doing this joke to none-english speakers, I doubt it would translate.
                    GLog.i(Messages.get(CursedWand.class, "nothing"));
                    wand.wandUsed();
                } else {
                    GameScene.show(new WndOptions("CURSED WAND ERROR", "this application will now self-destruct", "abort", "retry", "fail") {

                        @Override
                        protected void onSelect(int index) {
                            Game.instance.finish();
                        }

                        @Override
                        public void onBackPressed() {
                        // do nothing
                        }
                    });
                }
            } catch (IOException e) {
                ShatteredPixelDungeon.reportException(e);
                // oookay maybe don't kill the game if the save failed.
                GLog.i(Messages.get(CursedWand.class, "nothing"));
                wand.wandUsed();
            }
            break;
        // random transmogrification
        case 3:
            wand.wandUsed();
            wand.detach(user.belongings.backpack);
            Item result;
            do {
                result = Generator.random(Random.oneOf(Generator.Category.WEAPON, Generator.Category.ARMOR, Generator.Category.RING, Generator.Category.ARTIFACT));
            } while (result.cursed);
            if (result.isUpgradable())
                result.upgrade();
            result.cursed = result.cursedKnown = true;
            GLog.w(Messages.get(CursedWand.class, "transmogrify"));
            Dungeon.level.drop(result, user.pos).sprite.drop();
            wand.wandUsed();
            break;
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) Callback(com.watabou.utils.Callback) Mimic(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic) Fire(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire) ArrayList(java.util.ArrayList) Regrowth(com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth) IOException(java.io.IOException)

Example 54 with Item

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

the class MissileWeapon method split.

@Override
public Item split(int amount) {
    Item split = super.split(amount);
    // have it reduce the durability of the main stack. Cleaner to the player this way
    if (split != null) {
        MissileWeapon m = (MissileWeapon) split;
        m.durability = MAX_DURABILITY;
        m.parent = this;
    }
    return split;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item)

Example 55 with Item

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

the class HallsBossLevel method createItems.

@Override
protected void createItems() {
    Item item = Bones.get();
    if (item != null) {
        int pos;
        do {
            pos = Random.IntRange(ROOM_LEFT, ROOM_RIGHT) + Random.IntRange(ROOM_TOP + 1, ROOM_BOTTOM) * width();
        } while (pos == entrance);
        drop(item, pos).type = Heap.Type.REMAINS;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item)

Aggregations

Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)67 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)14 ArrayList (java.util.ArrayList)14 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)9 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)7 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)7 Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)7 Point (com.watabou.utils.Point)7 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)6 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)5 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)4 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)4 WndTradeItem (com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem)4 Dewdrop (com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop)3 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)3 Potion (com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion)3 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)2 Belongings (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings)2 Thief (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief)2 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)2