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));
}
});
}
}
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;
}
}
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);
}
}
});
}
}
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;
}
}
Aggregations