use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CryptRoom method prize.
private static Item prize(Level level) {
// 1 floor set higher than normal
Armor prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
if (Challenges.isItemBlocked(prize)) {
return new Gold().random();
}
// if it isn't already cursed, give it a free upgrade
if (!prize.cursed) {
prize.upgrade();
// curse the armor, unless it has a glyph
if (!prize.hasGoodGlyph()) {
prize.cursed = prize.cursedKnown = true;
prize.inscribe(Armor.Glyph.randomCurse());
}
}
return prize;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WndTradeItem method sell.
private void sell(Item item) {
Hero hero = Dungeon.hero;
if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
return;
}
item.detachAll(hero.belongings.backpack);
new Gold(item.price()).doPickUp(hero);
// selling items in the sell interface doesn't spend time
hero.spend(-hero.cooldown());
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Bones method pickItem.
private static Item pickItem(Hero hero) {
Item item = null;
if (Random.Int(3) != 0) {
switch(Random.Int(6)) {
case 0:
item = hero.belongings.weapon;
break;
case 1:
item = hero.belongings.armor;
break;
case 2:
item = hero.belongings.misc1;
break;
case 3:
item = hero.belongings.misc2;
break;
case 4:
case 5:
item = Dungeon.quickslot.randomNonePlaceholder();
break;
}
if (item == null || !item.bones) {
return pickItem(hero);
}
} else {
Iterator<Item> iterator = hero.belongings.backpack.iterator();
Item curItem;
ArrayList<Item> items = new ArrayList<Item>();
while (iterator.hasNext()) {
curItem = iterator.next();
if (curItem.bones)
items.add(curItem);
}
if (Random.Int(3) < items.size()) {
item = Random.element(items);
if (item.stackable) {
item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2));
}
} else {
if (Dungeon.gold > 100) {
item = new Gold(Random.NormalIntRange(50, Dungeon.gold / 2));
} else {
item = new Gold(50);
}
}
}
return item;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Mimic method spawnAt.
public static Mimic spawnAt(int pos, List<Item> items) {
if (Dungeon.level.pit[pos])
return null;
Char ch = Actor.findChar(pos);
if (ch != null) {
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
int cell = pos + n;
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
candidates.add(cell);
}
}
if (candidates.size() > 0) {
int newPos = Random.element(candidates);
Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
ch.pos = newPos;
Dungeon.level.press(newPos, ch);
} else {
return null;
}
}
Mimic m = new Mimic();
m.items = new ArrayList<>(items);
m.adjustStats(Dungeon.depth);
m.pos = pos;
m.state = m.HUNTING;
GameScene.add(m, 1);
m.sprite.turnTo(pos, Dungeon.hero.pos);
if (Dungeon.level.heroFOV[m.pos]) {
CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
Sample.INSTANCE.play(Assets.SND_MIMIC);
}
// generate an extra reward for killing the mimic
Item reward = null;
do {
switch(Random.Int(5)) {
case 0:
reward = new Gold().random();
break;
case 1:
reward = Generator.randomMissile();
break;
case 2:
reward = Generator.randomArmor();
break;
case 3:
reward = Generator.randomWeapon();
break;
case 4:
reward = Generator.random(Generator.Category.RING);
break;
}
} while (reward == null || Challenges.isItemBlocked(reward));
m.items.add(reward);
return m;
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Gold 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);
}
Aggregations