Search in sources :

Example 1 with WndInfoCell

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

Aggregations

Mob (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)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 WndOptions (com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions)1 ArrayList (java.util.ArrayList)1