use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Level method updateFieldOfView.
public boolean[] updateFieldOfView(Char c) {
int cx = c.pos % WIDTH;
int cy = c.pos / WIDTH;
boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.isAlive();
if (sighted) {
ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
} else {
Arrays.fill(fieldOfView, false);
}
int sense = 1;
if (c.isAlive()) {
for (Buff b : c.buffs(MindVision.class)) {
sense = Math.max(((MindVision) b).distance, sense);
}
}
if ((sighted && sense > 1) || !sighted) {
int ax = Math.max(0, cx - sense);
int bx = Math.min(cx + sense, WIDTH - 1);
int ay = Math.max(0, cy - sense);
int by = Math.min(cy + sense, HEIGHT - 1);
int len = bx - ax + 1;
int pos = ax + ay * WIDTH;
for (int y = ay; y <= by; y++, pos += WIDTH) {
Arrays.fill(fieldOfView, pos, pos + len, true);
}
for (int i = 0; i < LENGTH; i++) {
fieldOfView[i] &= discoverable[i];
}
}
if (c.isAlive()) {
if (c.buff(MindVision.class) != null) {
for (Mob mob : mobs) {
int p = mob.pos;
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
} else if (c == Dungeon.hero && ((Hero) c).heroClass == HeroClass.HUNTRESS) {
for (Mob mob : mobs) {
int p = mob.pos;
if (distance(c.pos, p) == 2) {
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
}
}
if (c.buff(Awareness.class) != null) {
for (Heap heap : heaps.values()) {
int p = heap.pos;
fieldOfView[p] = true;
fieldOfView[p + 1] = true;
fieldOfView[p - 1] = true;
fieldOfView[p + WIDTH + 1] = true;
fieldOfView[p + WIDTH - 1] = true;
fieldOfView[p - WIDTH + 1] = true;
fieldOfView[p - WIDTH - 1] = true;
fieldOfView[p + WIDTH] = true;
fieldOfView[p - WIDTH] = true;
}
}
}
return fieldOfView;
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
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 && heap.type != Heap.Type.HIDDEN) {
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.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : 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();
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class WandOfReach method onZap.
@Override
protected void onZap(int cell) {
int reach = Math.min(Ballistica.distance, power() + 4);
boolean mapUpdated = false;
for (int i = 1; i < reach; i++) {
int c = Ballistica.trace[i];
int before = Dungeon.level.map[c];
Char ch = Actor.findChar(c);
if (ch != null) {
Actor.addDelayed(new Swap(curUser, ch), -1);
break;
}
Heap heap = Dungeon.level.heaps.get(c);
if (heap != null) {
switch(heap.type) {
case HEAP:
transport(heap);
break;
case CHEST:
case MIMIC:
case TOMB:
case SKELETON:
heap.open(curUser);
break;
default:
}
break;
}
Dungeon.level.press(c, null);
if (before == Terrain.OPEN_DOOR) {
Level.set(c, Terrain.DOOR);
GameScene.updateMap(c);
} else if (Level.water[c]) {
GameScene.ripple(c);
}
mapUpdated = mapUpdated || Dungeon.level.map[c] != before;
}
if (mapUpdated) {
Dungeon.observe();
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class NPC method throwItem.
protected void throwItem() {
Heap heap = Dungeon.level.heaps.get(pos);
if (heap != null) {
int n;
do {
n = pos + Level.NEIGHBOURS8[Random.Int(8)];
} while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop(heap.pickUp(), n).sprite.drop(pos);
}
}
use of com.watabou.pixeldungeon.items.Heap in project pixel-dungeon by watabou.
the class Shopkeeper method flee.
protected void flee() {
for (Heap heap : Dungeon.level.heaps.values()) {
if (heap.type == Heap.Type.FOR_SALE) {
CellEmitter.get(heap.pos).burst(ElmoParticle.FACTORY, 4);
heap.destroy();
}
}
destroy();
sprite.killAndErase();
CellEmitter.get(pos).burst(ElmoParticle.FACTORY, 6);
}
Aggregations