use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class LibraryRoom method paint.
public void paint(Level level) {
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY_SP);
Door entrance = entrance();
Painter.fill(level, left + 1, top + 1, width() - 2, 1, Terrain.BOOKSHELF);
Painter.drawInside(level, this, entrance, 1, Terrain.EMPTY_SP);
int n = Random.IntRange(2, 3);
for (int i = 0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
Item item;
if (i == 0)
item = Random.Int(2) == 0 ? new ScrollOfIdentify() : new ScrollOfRemoveCurse();
else
item = prize(level);
level.drop(item, pos);
}
entrance.set(Door.Type.LOCKED);
level.addItemToSpawn(new IronKey(Dungeon.depth));
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class ShopRoom method ChooseBag.
protected static Bag ChooseBag(Belongings pack) {
// 0=pouch, 1=holder, 2=bandolier, 3=holster
int[] bagItems = new int[4];
// count up items in the main bag
for (Item item : pack.backpack.items) {
if (item instanceof Plant.Seed || item instanceof Runestone)
bagItems[0]++;
if (item instanceof Scroll)
bagItems[1]++;
if (item instanceof Potion)
bagItems[2]++;
if (item instanceof Wand || item instanceof MissileWeapon)
bagItems[3]++;
}
// disqualify bags that have already been dropped
if (Dungeon.LimitedDrops.VELVET_POUCH.dropped())
bagItems[0] = -1;
if (Dungeon.LimitedDrops.SCROLL_HOLDER.dropped())
bagItems[1] = -1;
if (Dungeon.LimitedDrops.POTION_BANDOLIER.dropped())
bagItems[2] = -1;
if (Dungeon.LimitedDrops.MAGICAL_HOLSTER.dropped())
bagItems[3] = -1;
// find the best bag to drop. This does give a preference to later bags, if counts are equal
int bestBagIdx = 0;
for (int i = 1; i <= 3; i++) {
if (bagItems[bestBagIdx] <= bagItems[i]) {
bestBagIdx = i;
}
}
// drop it, or return nothing if no bag works
if (bagItems[bestBagIdx] == -1)
return null;
switch(bestBagIdx) {
case 0:
default:
Dungeon.LimitedDrops.VELVET_POUCH.drop();
return new VelvetPouch();
case 1:
Dungeon.LimitedDrops.SCROLL_HOLDER.drop();
return new ScrollHolder();
case 2:
Dungeon.LimitedDrops.POTION_BANDOLIER.drop();
return new PotionBandolier();
case 3:
Dungeon.LimitedDrops.MAGICAL_HOLSTER.drop();
return new MagicalHolster();
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class SecretHoardRoom method paint.
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY);
Class<? extends Trap> trapClass;
if (Random.Int(2) == 0) {
trapClass = RockfallTrap.class;
} else if (Dungeon.depth >= 10) {
trapClass = DisintegrationTrap.class;
} else {
trapClass = PoisonDartTrap.class;
}
int goldPos;
// half of the internal space of the room
int totalGold = ((width() - 2) * (height() - 2)) / 2;
// no matter how much gold it drops, roughly equals 8 gold stacks.
float goldRatio = 8 / (float) totalGold;
for (int i = 0; i < totalGold; i++) {
do {
goldPos = level.pointToCell(random());
} while (level.heaps.get(goldPos) != null);
Item gold = new Gold().random();
gold.quantity(Math.round(gold.quantity() * goldRatio));
level.drop(gold, goldPos);
}
for (Point p : getPoints()) {
if (Random.Int(2) == 0 && level.map[level.pointToCell(p)] == Terrain.EMPTY) {
try {
level.setTrap(trapClass.newInstance().reveal(), level.pointToCell(p));
Painter.set(level, p, Terrain.TRAP);
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
}
}
}
entrance().set(Door.Type.HIDDEN);
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class SecretMazeRoom method paint.
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY);
// true = space, false = wall
boolean[][] maze = Maze.generate(this);
boolean[] passable = new boolean[width() * height()];
Painter.fill(level, this, 1, Terrain.EMPTY);
for (int x = 0; x < maze.length; x++) {
for (int y = 0; y < maze[0].length; y++) {
if (maze[x][y] == Maze.FILLED) {
Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL);
}
passable[x + width() * y] = maze[x][y] == Maze.EMPTY;
}
}
PathFinder.setMapSize(width(), height());
Point entrance = entrance();
int entrancePos = (entrance.x - left) + width() * (entrance.y - top);
PathFinder.buildDistanceMap(entrancePos, passable);
int bestDist = 0;
Point bestDistP = new Point();
for (int i = 0; i < PathFinder.distance.length; i++) {
if (PathFinder.distance[i] != Integer.MAX_VALUE && PathFinder.distance[i] > bestDist) {
bestDist = PathFinder.distance[i];
bestDistP.x = (i % width()) + left;
bestDistP.y = (i / width()) + top;
}
}
Item prize;
// 1 floor set higher in probability, never cursed
do {
if (Random.Int(2) == 0) {
prize = Generator.randomWeapon((Dungeon.depth / 5) + 1);
} else {
prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
}
} while (prize.cursed || Challenges.isItemBlocked(prize));
// 33% chance for an extra update.
if (Random.Int(3) == 0) {
prize.upgrade();
}
level.drop(prize, level.pointToCell(bestDistP)).type = Heap.Type.CHEST;
PathFinder.setMapSize(level.width(), level.height());
entrance().set(Door.Type.HIDDEN);
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class SuspiciousChestRoom method paint.
@Override
public void paint(Level level) {
super.paint(level);
Item i = level.findPrizeItem();
if (i == null) {
i = new Gold().random();
}
int center = level.pointToCell(center());
Painter.set(level, center, Terrain.PEDESTAL);
if (Random.Int(3) == 0) {
level.drop(i, center).type = Heap.Type.MIMIC;
} else {
level.drop(i, center).type = Heap.Type.CHEST;
}
}
Aggregations