use of com.shatteredpixel.shatteredpixeldungeon.items.Heap in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method onOperateComplete.
@Override
public void onOperateComplete() {
if (curAction instanceof HeroAction.Unlock) {
int doorCell = ((HeroAction.Unlock) curAction).dst;
int door = Dungeon.level.map[doorCell];
if (door == Terrain.LOCKED_DOOR) {
Notes.remove(new IronKey(Dungeon.depth));
Level.set(doorCell, Terrain.DOOR);
} else {
Notes.remove(new SkeletonKey(Dungeon.depth));
Level.set(doorCell, Terrain.UNLOCKED_EXIT);
}
GameScene.updateKeyDisplay();
Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
GameScene.updateMap(doorCell);
} else if (curAction instanceof HeroAction.OpenChest) {
Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst);
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
Sample.INSTANCE.play(Assets.SND_BONES);
} else if (heap.type == Type.LOCKED_CHEST) {
Notes.remove(new GoldenKey(Dungeon.depth));
} else if (heap.type == Type.CRYSTAL_CHEST) {
Notes.remove(new CrystalKey(Dungeon.depth));
}
GameScene.updateKeyDisplay();
heap.open(this);
}
curAction = null;
super.onOperateComplete();
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Heap in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WellWater method affect.
protected boolean affect(int pos) {
Heap heap;
if (pos == Dungeon.hero.pos && affectHero(Dungeon.hero)) {
cur[pos] = 0;
return true;
} else if ((heap = Dungeon.level.heaps.get(pos)) != null) {
Item oldItem = heap.peek();
Item newItem = affectItem(oldItem);
if (newItem != null) {
if (newItem == oldItem) {
} else if (oldItem.quantity() > 1) {
oldItem.quantity(oldItem.quantity() - 1);
heap.drop(newItem);
} else {
heap.replace(oldItem, newItem);
}
heap.sprite.link();
cur[pos] = 0;
return true;
} else {
int newPlace;
do {
newPlace = pos + PathFinder.NEIGHBOURS8[Random.Int(8)];
} while (!Dungeon.level.passable[newPlace] && !Dungeon.level.avoid[newPlace]);
Dungeon.level.drop(heap.pickUp(), newPlace).sprite.drop(pos);
return false;
}
} else {
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.Heap in project shattered-pixel-dungeon-gdx by 00-Evan.
the class LootIndicator method update.
@Override
public void update() {
if (Dungeon.hero.ready) {
Heap heap = Dungeon.level.heaps.get(Dungeon.hero.pos);
if (heap != null) {
Item item = heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST : heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST : heap.type == Heap.Type.CRYSTAL_CHEST ? ItemSlot.CRYSTAL_CHEST : heap.type == Heap.Type.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : heap.type == Heap.Type.REMAINS ? ItemSlot.REMAINS : heap.peek();
if (item != lastItem || item.quantity() != lastQuantity) {
lastItem = item;
lastQuantity = item.quantity();
slot.item(item);
flash();
}
visible = true;
} else {
lastItem = null;
visible = false;
}
}
slot.enable(visible && Dungeon.hero.ready);
super.update();
}
Aggregations