use of com.shatteredpixel.shatteredpixeldungeon.plants.Plant 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.plants.Plant in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Fire method burn.
private void burn(int pos) {
Char ch = Actor.findChar(pos);
if (ch != null && !ch.isImmune(this.getClass())) {
Buff.affect(ch, Burning.class).reignite(ch);
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
heap.burn();
}
Plant plant = Dungeon.level.plants.get(pos);
if (plant != null) {
plant.wither();
}
}
use of com.shatteredpixel.shatteredpixeldungeon.plants.Plant in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method press.
// a 'soft' press ignores hidden traps
// a 'hard' press triggers all things
// generally a 'hard' press should be forced is something is moving forcefully (e.g. thrown)
public void press(int cell, Char ch, boolean hard) {
if (ch != null && pit[cell] && !ch.flying) {
if (ch == Dungeon.hero) {
Chasm.heroFall(cell);
} else if (ch instanceof Mob) {
Chasm.mobFall((Mob) ch);
}
return;
}
Trap trap = null;
switch(map[cell]) {
case Terrain.SECRET_TRAP:
if (hard) {
trap = traps.get(cell);
GLog.i(Messages.get(Level.class, "hidden_trap", trap.name));
}
break;
case Terrain.TRAP:
trap = traps.get(cell);
break;
case Terrain.HIGH_GRASS:
HighGrass.trample(this, cell, ch);
break;
case Terrain.WELL:
WellWater.affectCell(cell);
break;
case Terrain.DOOR:
Door.enter(cell);
break;
}
if (trap != null) {
TimekeepersHourglass.timeFreeze timeFreeze = ch != null ? ch.buff(TimekeepersHourglass.timeFreeze.class) : null;
if (timeFreeze == null) {
if (ch == Dungeon.hero) {
Dungeon.hero.interrupt();
}
trap.trigger();
} else {
Sample.INSTANCE.play(Assets.SND_TRAP);
discover(cell);
timeFreeze.setDelayedPress(cell);
}
}
Plant plant = plants.get(cell);
if (plant != null) {
plant.trigger();
}
}
use of com.shatteredpixel.shatteredpixeldungeon.plants.Plant in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method restoreFromBundle.
@Override
public void restoreFromBundle(Bundle bundle) {
version = bundle.getInt(VERSION);
// saves from before 0.5.0b are not supported
if (version < ShatteredPixelDungeon.v0_5_0b) {
throw new RuntimeException("old save");
}
setSize(bundle.getInt(WIDTH), bundle.getInt(HEIGHT));
mobs = new HashSet<>();
heaps = new SparseArray<>();
blobs = new HashMap<>();
plants = new SparseArray<>();
traps = new SparseArray<>();
customTiles = new HashSet<>();
customWalls = new HashSet<>();
map = bundle.getIntArray(MAP);
visited = bundle.getBooleanArray(VISITED);
mapped = bundle.getBooleanArray(MAPPED);
entrance = bundle.getInt(ENTRANCE);
exit = bundle.getInt(EXIT);
locked = bundle.getBoolean(LOCKED);
// pre-0.6.1 saves
if (version <= ShatteredPixelDungeon.v0_6_0b) {
map = Terrain.convertTilesFrom0_6_0b(map);
}
Collection<Bundlable> collection = bundle.getCollection(HEAPS);
for (Bundlable h : collection) {
Heap heap = (Heap) h;
if (!heap.isEmpty())
heaps.put(heap.pos, heap);
}
collection = bundle.getCollection(PLANTS);
for (Bundlable p : collection) {
Plant plant = (Plant) p;
plants.put(plant.pos, plant);
}
collection = bundle.getCollection(TRAPS);
for (Bundlable p : collection) {
Trap trap = (Trap) p;
traps.put(trap.pos, trap);
}
collection = bundle.getCollection(CUSTOM_TILES);
for (Bundlable p : collection) {
CustomTiledVisual vis = (CustomTiledVisual) p;
customTiles.add(vis);
}
collection = bundle.getCollection(CUSTOM_WALLS);
for (Bundlable p : collection) {
CustomTiledVisual vis = (CustomTiledVisual) p;
customWalls.add(vis);
}
collection = bundle.getCollection(MOBS);
for (Bundlable m : collection) {
Mob mob = (Mob) m;
if (mob != null) {
mobs.add(mob);
}
}
collection = bundle.getCollection(BLOBS);
for (Bundlable b : collection) {
Blob blob = (Blob) b;
blobs.put(blob.getClass(), blob);
}
feeling = bundle.getEnum(FEELING, Feeling.class);
if (feeling == Feeling.DARK)
viewDistance = Math.round(viewDistance / 2f);
buildFlagMaps();
cleanWalls();
}
use of com.shatteredpixel.shatteredpixeldungeon.plants.Plant in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method plant.
public Plant plant(Plant.Seed seed, int pos) {
if (Dungeon.isChallenged(Challenges.NO_HERBALISM)) {
return null;
}
Plant plant = plants.get(pos);
if (plant != null) {
plant.wither();
}
if (map[pos] == Terrain.HIGH_GRASS || map[pos] == Terrain.EMPTY || map[pos] == Terrain.EMBERS || map[pos] == Terrain.EMPTY_DECO) {
set(pos, Terrain.GRASS, this);
GameScene.updateMap(pos);
}
plant = seed.couch(pos, this);
plants.put(pos, plant);
GameScene.plantSeed(pos);
return plant;
}
Aggregations