public static void reallyDie(Object cause) { int length = Level.LENGTH; int[] map = Dungeon.level.map; boolean[] visited = Dungeon.level.visited; boolean[] discoverable = 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) { Level.set(i, Terrain.discover(terr)); GameScene.updateMap(i); } } } Bones.leave(); Dungeon.observe(); Dungeon.hero.belongings.identify(); GameScene.gameOver(); if (cause instanceof Hero.Doom) { ((Hero.Doom) cause).onDeath(); } Dungeon.deleteGame(Dungeon.hero.heroClass, true); }
@Override public void onOperateComplete() { if (curAction instanceof HeroAction.Unlock) { if (theKey != null) { theKey.detach(belongings.backpack); theKey = null; } int doorCell = ((HeroAction.Unlock) curAction).dst; int door = Dungeon.level.map[doorCell]; Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT); GameScene.updateMap(doorCell); } else if (curAction instanceof HeroAction.OpenChest) { if (theKey != null) { theKey.detach(belongings.backpack); theKey = null; } Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst); if (heap.type == Type.SKELETON) { Sample.INSTANCE.play(Assets.SND_BONES); } heap.open(this); } curAction = null; super.onOperateComplete(); }
private void jump() { timeToJump = JUMP_DELAY; for (int i = 0; i < 4; i++) { int trapPos; do { trapPos = Random.Int(Level.LENGTH); } while (!Level.fieldOfView[trapPos] || !Level.passable[trapPos]); if (Dungeon.level.map[trapPos] == Terrain.INACTIVE_TRAP) { Level.set(trapPos, Terrain.POISON_TRAP); GameScene.updateMap(trapPos); ScrollOfMagicMapping.discover(trapPos); } } int newPos; do { newPos = Random.Int(Level.LENGTH); } while (!Level.fieldOfView[newPos] || !Level.passable[newPos] || (enemy != null && Level.adjacent(newPos, enemy.pos)) || Actor.findChar(newPos) != null); sprite.move(pos, newPos); move(newPos); if (Dungeon.visible[newPos]) { CellEmitter.get(newPos).burst(Speck.factory(Speck.WOOL), 6); Sample.INSTANCE.play(Assets.SND_PUFF); } spend(1 / speed()); }
public boolean search(boolean intentional) { boolean smthFound = false; int positive = 0; int negative = 0; for (Buff buff : buffs(RingOfDetection.Detection.class)) { int bonus = ((RingOfDetection.Detection) buff).level; if (bonus > positive) { positive = bonus; } else if (bonus < 0) { negative += bonus; } } int distance = 1 + positive + negative; float level = intentional ? (2 * awareness - awareness * awareness) : awareness; if (distance <= 0) { level /= 2 - distance; distance = 1; } int cx = pos % Level.WIDTH; int cy = pos / Level.WIDTH; int ax = cx - distance; if (ax < 0) { ax = 0; } int bx = cx + distance; if (bx >= Level.WIDTH) { bx = Level.WIDTH - 1; } int ay = cy - distance; if (ay < 0) { ay = 0; } int by = cy + distance; if (by >= Level.HEIGHT) { by = Level.HEIGHT - 1; } for (int y = ay; y <= by; y++) { for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) { if (Dungeon.visible[p]) { if (intentional) { sprite.parent.addToBack(new CheckedCell(p)); } if (Level.secret[p] && (intentional || Random.Float() < level)) { int oldValue = Dungeon.level.map[p]; GameScene.discoverTile(p, oldValue); Level.set(p, Terrain.discover(oldValue)); GameScene.updateMap(p); ScrollOfMagicMapping.discover(p); smthFound = true; } } } } if (intentional) { sprite.showStatus(CharSprite.DEFAULT, TXT_SEARCH); sprite.operate(pos); if (smthFound) { spendAndNext(Random.Float() < level ? TIME_TO_SEARCH : TIME_TO_SEARCH * 2); } else { spendAndNext(TIME_TO_SEARCH); } } if (smthFound) { GLog.w(TXT_NOTICED_SMTH); Sample.INSTANCE.play(Assets.SND_SECRET); interrupt(); } return smthFound; }