use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method reallyDie.
public static void reallyDie(Object cause) {
int length = Dungeon.level.length();
int[] map = Dungeon.level.map;
boolean[] visited = Dungeon.level.visited;
boolean[] discoverable = Dungeon.level.discoverable;
for (int i = 0; i < length; i++) {
int terr = map[i];
if (discoverable[i]) {
visited[i] = true;
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
Dungeon.level.discover(i);
}
}
}
Bones.leave();
Dungeon.observe();
GameScene.updateFog();
Dungeon.hero.belongings.identify();
int pos = Dungeon.hero.pos;
ArrayList<Integer> passable = new ArrayList<Integer>();
for (Integer ofs : PathFinder.NEIGHBOURS8) {
int cell = pos + ofs;
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Dungeon.level.heaps.get(cell) == null) {
passable.add(cell);
}
}
Collections.shuffle(passable);
ArrayList<Item> items = new ArrayList<Item>(Dungeon.hero.belongings.backpack.items);
for (Integer cell : passable) {
if (items.isEmpty()) {
break;
}
Item item = Random.element(items);
Dungeon.level.drop(item, cell).sprite.drop(pos);
items.remove(item);
}
GameScene.gameOver();
if (cause instanceof Hero.Doom) {
((Hero.Doom) cause).onDeath();
}
Dungeon.deleteGame(GamesInProgress.curSlot, true);
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method findPrizeItem.
public Item findPrizeItem(Class<? extends Item> match) {
if (itemsToSpawn.size() == 0)
return null;
if (match == null) {
Item item = Random.element(itemsToSpawn);
itemsToSpawn.remove(item);
return item;
}
for (Item item : itemsToSpawn) {
if (match.isInstance(item)) {
itemsToSpawn.remove(item);
return item;
}
}
return null;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class PrisonBossLevel method progress.
public void progress() {
switch(state) {
// moving to the beginning of the fight
case START:
seal();
set(5 + 25 * 32, Terrain.LOCKED_DOOR);
GameScene.updateMap(5 + 25 * 32);
for (Mob m : mobs) {
// bring the first ally with you
if (m.alignment == Char.Alignment.ALLY) {
// they should immediately walk out of the door
m.pos = 5 + 25 * 32;
m.sprite.place(m.pos);
break;
}
}
tengu.state = tengu.HUNTING;
// in the middle of the fight room
tengu.pos = 5 + 28 * 32;
GameScene.add(tengu);
tengu.notice();
state = State.FIGHT_START;
break;
// halfway through, move to the maze
case FIGHT_START:
changeMap(MAP_MAZE);
// clear the entrance
clearEntities((Room) new Room().set(0, 5, 8, 32));
Actor.remove(tengu);
mobs.remove(tengu);
TargetHealthIndicator.instance.target(null);
tengu.sprite.kill();
Room maze = new MazeRoom();
maze.set(10, 1, 31, 29);
maze.connected.put(null, new Room.Door(10, 2));
maze.connected.put(maze, new Room.Door(20, 29));
maze.paint(this);
buildFlagMaps();
cleanWalls();
GameScene.resetMap();
GameScene.flash(0xFFFFFF);
Sample.INSTANCE.play(Assets.SND_BLAST);
state = State.MAZE;
break;
// maze beaten, moving to the arena
case MAZE:
Dungeon.hero.interrupt();
Dungeon.hero.pos += 9 + 3 * 32;
Dungeon.hero.sprite.interruptMotion();
Dungeon.hero.sprite.place(Dungeon.hero.pos);
changeMap(MAP_ARENA);
// clear all but the area right around the teleport spot
clearEntities((Room) new Room().set(0, 0, 10, 4));
// if any allies are left over, move them along the same way as the hero
for (Mob m : mobs) {
if (m.alignment == Char.Alignment.ALLY) {
m.pos += 9 + 3 * 32;
m.sprite().place(m.pos);
}
}
tengu.state = tengu.HUNTING;
do {
tengu.pos = Random.Int(length());
} while (solid[tengu.pos] || distance(tengu.pos, Dungeon.hero.pos) < 8);
GameScene.add(tengu);
tengu.notice();
GameScene.flash(0xFFFFFF);
Sample.INSTANCE.play(Assets.SND_BLAST);
state = State.FIGHT_ARENA;
break;
// arena ended, fight over.
case FIGHT_ARENA:
unseal();
CustomTiledVisual vis = new exitVisual();
vis.pos(11, 8);
customTiles.add(vis);
((GameScene) ShatteredPixelDungeon.scene()).addCustomTile(vis);
vis = new exitVisualWalls();
vis.pos(11, 8);
customWalls.add(vis);
((GameScene) ShatteredPixelDungeon.scene()).addCustomWall(vis);
Dungeon.hero.interrupt();
Dungeon.hero.pos = 5 + 27 * 32;
Dungeon.hero.sprite.interruptMotion();
Dungeon.hero.sprite.place(Dungeon.hero.pos);
tengu.pos = 5 + 28 * 32;
tengu.sprite.place(5 + 28 * 32);
// remove all mobs, but preserve allies
ArrayList<Mob> allies = new ArrayList<>();
for (Mob m : mobs.toArray(new Mob[0])) {
if (m.alignment == Char.Alignment.ALLY) {
allies.add(m);
mobs.remove(m);
}
}
clearEntities(null);
changeMap(MAP_END);
for (Mob m : allies) {
do {
m.pos = Random.IntRange(3, 7) + Random.IntRange(26, 30) * 32;
} while (findMob(m.pos) != null);
m.sprite().place(m.pos);
mobs.add(m);
}
tengu.die(Dungeon.hero);
for (Item item : storedItems) drop(item, randomPrisonCell());
GameScene.flash(0xFFFFFF);
Sample.INSTANCE.play(Assets.SND_BLAST);
state = State.WON;
break;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RegularLevel method createItems.
@Override
protected void createItems() {
// drops 3/4/5 items 60%/30%/10% of the time
int nItems = 3 + Random.chances(new float[] { 6, 3, 1 });
for (int i = 0; i < nItems; i++) {
Heap.Type type = null;
switch(Random.Int(20)) {
case 0:
type = Heap.Type.SKELETON;
break;
case 1:
case 2:
case 3:
case 4:
type = Heap.Type.CHEST;
break;
case 5:
type = Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST;
break;
default:
type = Heap.Type.HEAP;
}
int cell = randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
Item toDrop = Generator.random();
if (toDrop == null)
continue;
if ((toDrop instanceof Artifact && Random.Int(2) == 0) || (toDrop.isUpgradable() && Random.Int(4 - toDrop.level()) == 0)) {
Heap dropped = drop(toDrop, cell);
if (heaps.get(cell) == dropped) {
dropped.type = Heap.Type.LOCKED_CHEST;
addItemToSpawn(new GoldenKey(Dungeon.depth));
}
} else {
drop(toDrop, cell).type = type;
}
}
for (Item item : itemsToSpawn) {
int cell = randomDropCell();
drop(item, cell).type = Heap.Type.HEAP;
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
}
Item item = Bones.get();
if (item != null) {
int cell = randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
drop(item, cell).type = Heap.Type.REMAINS;
}
// guide pages
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages();
ArrayList<String> missingPages = new ArrayList<>();
for (String page : allPages) {
if (!Document.ADVENTURERS_GUIDE.hasPage(page)) {
missingPages.add(page);
}
}
// these are dropped specially
missingPages.remove(Document.GUIDE_INTRO_PAGE);
missingPages.remove(Document.GUIDE_SEARCH_PAGE);
int foundPages = allPages.size() - (missingPages.size() + 2);
// chance to find a page scales with pages missing and depth
if (missingPages.size() > 0 && Random.Float() < (Dungeon.depth / (float) (foundPages + 1))) {
GuidePage p = new GuidePage();
p.page(missingPages.get(0));
int cell = randomDropCell();
if (map[cell] == Terrain.HIGH_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
drop(p, cell);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Item in project shattered-pixel-dungeon-gdx by 00-Evan.
the class MassGraveRoom method paint.
public void paint(Level level) {
Door entrance = entrance();
entrance.set(Door.Type.BARRICADE);
level.addItemToSpawn(new PotionOfLiquidFlame());
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY_SP);
Bones b = new Bones();
b.setRect(left + 1, top, width() - 2, height() - 1);
level.customTiles.add(b);
// 50% 1 skeleton, 50% 2 skeletons
for (int i = 0; i <= Random.Int(2); i++) {
Skeleton skele = new Skeleton();
int pos;
do {
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.findMob(pos) != null);
skele.pos = pos;
level.mobs.add(skele);
}
ArrayList<Item> items = new ArrayList<>();
// 100% corpse dust, 2x100% 1 coin, 2x30% coins, 1x60% random item, 1x30% armor
items.add(new CorpseDust());
items.add(new Gold(1));
items.add(new Gold(1));
if (Random.Float() <= 0.3f)
items.add(new Gold());
if (Random.Float() <= 0.3f)
items.add(new Gold());
if (Random.Float() <= 0.6f)
items.add(Generator.random());
if (Random.Float() <= 0.3f)
items.add(Generator.randomArmor());
for (Item item : items) {
int pos;
do {
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
Heap h = level.drop(item, pos);
h.type = Heap.Type.SKELETON;
}
}
Aggregations