use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Level method create.
public void create() {
resizingNeeded = false;
map = new int[LENGTH];
visited = new boolean[LENGTH];
Arrays.fill(visited, false);
mapped = new boolean[LENGTH];
Arrays.fill(mapped, false);
mobs = new HashSet<Mob>();
heaps = new SparseArray<Heap>();
blobs = new HashMap<Class<? extends Blob>, Blob>();
plants = new SparseArray<Plant>();
if (!Dungeon.bossLevel()) {
addItemToSpawn(Generator.random(Generator.Category.FOOD));
if (Dungeon.posNeeded()) {
addItemToSpawn(new PotionOfStrength());
Dungeon.potionOfStrength++;
}
if (Dungeon.souNeeded()) {
addItemToSpawn(new ScrollOfUpgrade());
Dungeon.scrollsOfUpgrade++;
}
if (Dungeon.soeNeeded()) {
addItemToSpawn(new ScrollOfEnchantment());
Dungeon.scrollsOfEnchantment++;
}
if (Dungeon.depth > 1) {
switch(Random.Int(10)) {
case 0:
if (!Dungeon.bossLevel(Dungeon.depth + 1)) {
feeling = Feeling.CHASM;
}
break;
case 1:
feeling = Feeling.WATER;
break;
case 2:
feeling = Feeling.GRASS;
break;
}
}
}
boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
do {
Arrays.fill(map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
pitRoomNeeded = pitNeeded;
weakFloorCreated = false;
} while (!build());
decorate();
buildFlagMaps();
cleanWalls();
createMobs();
createItems();
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Level method drop.
public Heap drop(Item item, int cell) {
if (Dungeon.isChallenged(Challenges.NO_FOOD) && item instanceof Food) {
item = new Gold(item.price());
} else if (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) {
item = new Gold(item.price());
} else if (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing) {
item = new Gold(item.price());
} else if (Dungeon.isChallenged(Challenges.NO_HERBALISM) && item instanceof SeedPouch) {
item = new Gold(item.price());
} else if (Dungeon.isChallenged(Challenges.NO_SCROLLS) && (item instanceof Scroll || item instanceof ScrollHolder)) {
if (item instanceof ScrollOfUpgrade) {
// These scrolls still can be found
} else {
item = new Gold(item.price());
}
}
if ((map[cell] == Terrain.ALCHEMY) && !(item instanceof Plant.Seed)) {
int n;
do {
n = cell + NEIGHBOURS8[Random.Int(8)];
} while (map[n] != Terrain.EMPTY_SP);
cell = n;
}
Heap heap = heaps.get(cell);
if (heap == null) {
heap = new Heap();
heap.pos = cell;
if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
Dungeon.dropToChasm(item);
GameScene.discard(heap);
} else {
heaps.put(cell, heap);
GameScene.add(heap);
}
} else if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
int n;
do {
n = cell + Level.NEIGHBOURS8[Random.Int(8)];
} while (!Level.passable[n] && !Level.avoid[n]);
return drop(item, n);
}
heap.drop(item);
if (Dungeon.level != null) {
press(cell, null);
}
return heap;
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class ScrollOfChallenge method doRead.
@Override
protected void doRead() {
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
mob.beckon(curUser.pos);
if (Dungeon.visible[mob.pos]) {
Buff.affect(mob, Rage.class, Level.distance(curUser.pos, mob.pos));
}
}
for (Heap heap : Dungeon.level.heaps.values()) {
if (heap.type == Heap.Type.MIMIC) {
Mimic m = Mimic.spawnAt(heap.pos, heap.items);
if (m != null) {
m.beckon(curUser.pos);
heap.destroy();
}
}
}
GLog.w("The scroll emits a challenging roar that echoes throughout the dungeon!");
setKnown();
curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.3f, 3);
Sample.INSTANCE.play(Assets.SND_CHALLENGE);
Invisibility.dispel();
readAnimation();
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class RatKingPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.EMPTY_SP);
Room.Door entrance = room.entrance();
entrance.set(Room.Door.Type.HIDDEN);
int door = entrance.x + entrance.y * Level.WIDTH;
for (int i = room.left + 1; i < room.right; i++) {
addChest(level, (room.top + 1) * Level.WIDTH + i, door);
addChest(level, (room.bottom - 1) * Level.WIDTH + i, door);
}
for (int i = room.top + 2; i < room.bottom - 1; i++) {
addChest(level, i * Level.WIDTH + room.left + 1, door);
addChest(level, i * Level.WIDTH + room.right - 1, door);
}
while (true) {
Heap chest = level.heaps.get(room.random());
if (chest != null) {
chest.type = Heap.Type.MIMIC;
break;
}
}
RatKing king = new RatKing();
king.pos = room.random(1);
level.mobs.add(king);
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class ScrollOfWipeOut method doRead.
private void doRead() {
GameScene.flash(0xFF6644);
Invisibility.dispel();
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
if (!Bestiary.isBoss(mob)) {
Sample.INSTANCE.play(Assets.SND_CURSED, 0.3f, 0.3f, Random.Float(0.6f, 0.9f));
mob.die(this);
}
}
for (Heap heap : Dungeon.level.heaps.values()) {
switch(heap.type) {
case FOR_SALE:
heap.type = Type.HEAP;
if (Dungeon.visible[heap.pos]) {
CellEmitter.center(heap.pos).burst(Speck.factory(Speck.COIN), 2);
}
break;
case MIMIC:
heap.type = Type.HEAP;
heap.sprite.link();
Sample.INSTANCE.play(Assets.SND_CURSED, 0.3f, 0.3f, Random.Float(0.6f, 0.9f));
break;
default:
}
}
curUser.spend(TIME_TO_READ);
curUser.busy();
((HeroSprite) curUser.sprite).read();
}
Aggregations