use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Hero method actOpenChest.
private boolean actOpenChest(HeroAction.OpenChest action) {
int dst = action.dst;
if (Level.adjacent(pos, dst) || pos == dst) {
Heap heap = Dungeon.level.heaps.get(dst);
if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) {
theKey = null;
if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST) {
theKey = belongings.getKey(GoldenKey.class, Dungeon.depth);
if (theKey == null) {
GLog.w(TXT_LOCKED_CHEST);
ready();
return false;
}
}
switch(heap.type) {
case TOMB:
Sample.INSTANCE.play(Assets.SND_TOMB);
Camera.main.shake(1, 0.5f);
break;
case SKELETON:
break;
default:
Sample.INSTANCE.play(Assets.SND_UNLOCK);
}
spend(Key.TIME_TO_UNLOCK);
sprite.operate(dst);
} else {
ready();
}
return false;
} else if (getCloser(dst)) {
return true;
} else {
ready();
return false;
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Hero method actPickUp.
private boolean actPickUp(HeroAction.PickUp action) {
int dst = action.dst;
if (pos == dst) {
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
Item item = heap.pickUp();
if (item.doPickUp(this)) {
if (item instanceof Dewdrop) {
// Do nothing
} else {
boolean important = ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll) item).isKnown()) || ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion) item).isKnown());
if (important) {
GLog.p(TXT_YOU_NOW_HAVE, item.name());
} else {
GLog.i(TXT_YOU_NOW_HAVE, item.name());
}
}
if (!heap.isEmpty()) {
GLog.i(TXT_SOMETHING_ELSE);
}
curAction = null;
} else {
Dungeon.level.drop(item, pos).sprite.drop();
ready();
}
} else {
ready();
}
return false;
} else if (getCloser(dst)) {
return true;
} else {
ready();
return false;
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Hero method actBuy.
private boolean actBuy(HeroAction.Buy action) {
int dst = action.dst;
if (pos == dst || Level.adjacent(pos, dst)) {
ready();
Heap heap = Dungeon.level.heaps.get(dst);
if (heap != null && heap.type == Type.FOR_SALE && heap.size() == 1) {
GameScene.show(new WndTradeItem(heap, true));
}
return false;
} else if (getCloser(dst)) {
return true;
} else {
ready();
return false;
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Fire method burn.
private void burn(int pos) {
Char ch = Actor.findChar(pos);
if (ch != null) {
Buff.affect(ch, Burning.class).reignite(ch);
}
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
heap.burn();
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Level method restoreFromBundle.
@Override
public void restoreFromBundle(Bundle bundle) {
mobs = new HashSet<Mob>();
heaps = new SparseArray<Heap>();
blobs = new HashMap<Class<? extends Blob>, Blob>();
plants = new SparseArray<Plant>();
map = bundle.getIntArray(MAP);
visited = bundle.getBooleanArray(VISITED);
mapped = bundle.getBooleanArray(MAPPED);
entrance = bundle.getInt(ENTRANCE);
exit = bundle.getInt(EXIT);
weakFloorCreated = false;
adjustMapSize();
Collection<Bundlable> collection = bundle.getCollection(HEAPS);
for (Bundlable h : collection) {
Heap heap = (Heap) h;
if (resizingNeeded) {
heap.pos = adjustPos(heap.pos);
}
heaps.put(heap.pos, heap);
}
collection = bundle.getCollection(PLANTS);
for (Bundlable p : collection) {
Plant plant = (Plant) p;
if (resizingNeeded) {
plant.pos = adjustPos(plant.pos);
}
plants.put(plant.pos, plant);
}
collection = bundle.getCollection(MOBS);
for (Bundlable m : collection) {
Mob mob = (Mob) m;
if (mob != null) {
if (resizingNeeded) {
mob.pos = adjustPos(mob.pos);
}
mobs.add(mob);
}
}
collection = bundle.getCollection(BLOBS);
for (Bundlable b : collection) {
Blob blob = (Blob) b;
blobs.put(blob.getClass(), blob);
}
buildFlagMaps();
cleanWalls();
}
Aggregations