Search in sources :

Example 1 with WndOptions

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

the class GameScene method examineCell.

public static void examineCell(Integer cell) {
    if (cell == null || cell < 0 || cell > Dungeon.level.length() || (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell])) {
        return;
    }
    ArrayList<String> names = new ArrayList<>();
    final ArrayList<Object> objects = new ArrayList<>();
    if (cell == Dungeon.hero.pos) {
        objects.add(Dungeon.hero);
        names.add(Dungeon.hero.className().toUpperCase(Locale.ENGLISH));
    } else {
        if (Dungeon.level.heroFOV[cell]) {
            Mob mob = (Mob) Actor.findChar(cell);
            if (mob != null) {
                objects.add(mob);
                names.add(Messages.titleCase(mob.name));
            }
        }
    }
    Heap heap = Dungeon.level.heaps.get(cell);
    if (heap != null && heap.seen) {
        objects.add(heap);
        names.add(Messages.titleCase(heap.toString()));
    }
    Plant plant = Dungeon.level.plants.get(cell);
    if (plant != null) {
        objects.add(plant);
        names.add(Messages.titleCase(plant.plantName));
    }
    Trap trap = Dungeon.level.traps.get(cell);
    if (trap != null && trap.visible) {
        objects.add(trap);
        names.add(Messages.titleCase(trap.name));
    }
    if (objects.isEmpty()) {
        GameScene.show(new WndInfoCell(cell));
    } else if (objects.size() == 1) {
        examineObject(objects.get(0));
    } else {
        GameScene.show(new WndOptions(Messages.get(GameScene.class, "choose_examine"), Messages.get(GameScene.class, "multiple_examine"), names.toArray(new String[names.size()])) {

            @Override
            protected void onSelect(int index) {
                examineObject(objects.get(index));
            }
        });
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions) Mob(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob) WndInfoMob(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob) Plant(com.shatteredpixel.shatteredpixeldungeon.plants.Plant) WndInfoPlant(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant) ArrayList(java.util.ArrayList) Trap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap) WndInfoTrap(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoTrap) WndInfoCell(com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoCell) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap)

Example 2 with WndOptions

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

the class KindofMisc method doEquip.

@Override
public boolean doEquip(final Hero hero) {
    if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
        final KindofMisc m1 = hero.belongings.misc1;
        final KindofMisc m2 = hero.belongings.misc2;
        GameScene.show(new WndOptions(Messages.get(KindofMisc.class, "unequip_title"), Messages.get(KindofMisc.class, "unequip_message"), Messages.titleCase(m1.toString()), Messages.titleCase(m2.toString())) {

            @Override
            protected void onSelect(int index) {
                KindofMisc equipped = (index == 0 ? m1 : m2);
                // temporarily give 1 extra backpack spot to support swapping with a full inventory
                hero.belongings.backpack.size++;
                if (equipped.doUnequip(hero, true, false)) {
                    // fully re-execute rather than just call doEquip as we want to preserve quickslot
                    execute(hero, AC_EQUIP);
                }
                hero.belongings.backpack.size--;
            }
        });
        return false;
    } else {
        if (hero.belongings.misc1 == null) {
            hero.belongings.misc1 = this;
        } else {
            hero.belongings.misc2 = this;
        }
        detach(hero.belongings.backpack);
        activate(hero);
        cursedKnown = true;
        if (cursed) {
            equipCursed(hero);
            GLog.n(Messages.get(this, "equip_cursed", this));
        }
        hero.spendAndNext(TIME_TO_EQUIP);
        return true;
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions)

Example 3 with WndOptions

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

the class TimekeepersHourglass method execute.

@Override
public void execute(Hero hero, String action) {
    super.execute(hero, action);
    if (action.equals(AC_ACTIVATE)) {
        if (!isEquipped(hero))
            GLog.i(Messages.get(Artifact.class, "need_to_equip"));
        else if (activeBuff != null) {
            if (activeBuff instanceof timeStasis) {
            // do nothing
            } else {
                activeBuff.detach();
                GLog.i(Messages.get(this, "deactivate"));
            }
        } else if (charge <= 1)
            GLog.i(Messages.get(this, "no_charge"));
        else if (cursed)
            GLog.i(Messages.get(this, "cursed"));
        else
            GameScene.show(new WndOptions(Messages.get(this, "name"), Messages.get(this, "prompt"), Messages.get(this, "stasis"), Messages.get(this, "freeze")) {

                @Override
                protected void onSelect(int index) {
                    if (index == 0) {
                        GLog.i(Messages.get(TimekeepersHourglass.class, "onstasis"));
                        GameScene.flash(0xFFFFFF);
                        Sample.INSTANCE.play(Assets.SND_TELEPORT);
                        activeBuff = new timeStasis();
                        activeBuff.attachTo(Dungeon.hero);
                    } else if (index == 1) {
                        GLog.i(Messages.get(TimekeepersHourglass.class, "onfreeze"));
                        GameScene.flash(0xFFFFFF);
                        Sample.INSTANCE.play(Assets.SND_TELEPORT);
                        activeBuff = new timeFreeze();
                        activeBuff.attachTo(Dungeon.hero);
                        ((timeFreeze) activeBuff).processTime(0f);
                    }
                }
            });
    }
}
Also used : WndOptions(com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions)

Example 4 with WndOptions

use of com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions 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)

Aggregations

WndOptions (com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions)4 ArrayList (java.util.ArrayList)2 Fire (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire)1 Regrowth (com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Regrowth)1 Mimic (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic)1 Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)1 Plant (com.shatteredpixel.shatteredpixeldungeon.plants.Plant)1 WndInfoCell (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoCell)1 WndInfoMob (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob)1 WndInfoPlant (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoPlant)1 WndInfoTrap (com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoTrap)1 Callback (com.watabou.utils.Callback)1 IOException (java.io.IOException)1