@Override public void onComplete(Animation anim) { super.onComplete(anim); if (visible && emitter != null && anim == idle) { emitter.burst(Speck.factory(Speck.FORGE), 3); float volume = 0.2f / (Level.distance(ch.pos, Dungeon.hero.pos)); Sample.INSTANCE.play(Assets.SND_EVOKE, volume, volume, 0.8f); } }
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.CHEST || heap.type == Type.TOMB || heap.type == Type.SKELETON || heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST)) { 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; } }
@Override public void move(int step) { super.move(step); if (!flying) { if (Level.water[step]) { Sample.INSTANCE.play(Assets.SND_WATER, 1, 1, Random.Float(0.8f, 1.25f)); } else { Sample.INSTANCE.play(Assets.SND_STEP); } Dungeon.level.press(step, this); } }
@Override public boolean doPickUp(Hero hero) { DewVial vial = hero.belongings.getItem(DewVial.class); if (vial == null || vial.isFull()) { int value = 2 + (Dungeon.depth - 1) / 5; if (hero.heroClass == HeroClass.HUNTRESS) { value++; } int effect = Math.min(hero.HT - hero.HP, value * quantity); if (effect > 0) { hero.HP += effect; hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); hero.sprite.showStatus(CharSprite.POSITIVE, TXT_VALUE, effect); } } else if (vial != null) { vial.collectDew(this); } Sample.INSTANCE.play(Assets.SND_DEWDROP); hero.spendAndNext(TIME_TO_PICK_UP); return true; }
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()); }
private void actUnlock(HeroAction.Unlock action) { int doorCell = action.dst; if (Level.adjacent(pos, doorCell)) { theKey = null; int door = Dungeon.level.map[doorCell]; if (door == Terrain.LOCKED_DOOR) { theKey = belongings.getKey(IronKey.class, Dungeon.depth); } else if (door == Terrain.LOCKED_EXIT) { theKey = belongings.getKey(SkeletonKey.class, Dungeon.depth); } if (theKey != null) { spend(Key.TIME_TO_UNLOCK); sprite.operate(doorCell); Sample.INSTANCE.play(Assets.SND_UNLOCK); } else { GLog.w(TXT_LOCKED_DOOR); ready(); } } else if (getCloser(doorCell)) { } else { ready(); } }
@Override protected void doRead() { new Flare(5, 32).color(0xFF0000, true).show(curUser.sprite, 2f); Sample.INSTANCE.play(Assets.SND_READ); Invisibility.dispel(); int count = 0; Mob affected = null; for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) { if (Level.fieldOfView[mob.pos]) { Buff.affect(mob, Terror.class, Terror.DURATION).object = curUser.id(); count++; affected = mob; } } switch (count) { case 0: GLog.i("The scroll emits a brilliant flash of red light"); break; case 1: GLog.i( "The scroll emits a brilliant flash of red light and the " + affected.name + " flees!"); break; default: GLog.i("The scroll emits a brilliant flash of red light and the monsters flee!"); } setKnown(); readAnimation(); }
@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(); }
@Override protected void doRead() { GameScene.flash(0xFFFFFF); Sample.INSTANCE.play(Assets.SND_BLAST); Invisibility.dispel(); for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) { if (Level.fieldOfView[mob.pos]) { mob.damage(mob.HT, this); } } curUser.damage(Math.max(curUser.HT / 5, curUser.HP / 2), this); Buff.prolong(curUser, Paralysis.class, Random.Int(4, 6)); Buff.prolong(curUser, Blindness.class, Random.Int(6, 9)); Dungeon.observe(); setKnown(); curUser.spendAndNext(TIME_TO_READ); // no animation here, the flash interrupts it anyway. if (!curUser.isAlive()) { Dungeon.fail(Utils.format(ResultDescriptions.ITEM, name)); GLog.n("The Psionic Blast tears your mind apart..."); } }
@Override public void onSelect(Item item) { if (item != null && item instanceof Scroll && item.isIdentified()) { String scroll = convertName(item.getClass().getSimpleName()); Hero hero = Dungeon.hero; for (int i = 0; (i <= 1 && i < scrolls.size()); i++) { if (scrolls.get(i).equals(scroll)) { hero.sprite.operate(hero.pos); hero.busy(); hero.spend(2f); Sample.INSTANCE.play(Assets.SND_BURNING); hero.sprite.emitter().burst(ElmoParticle.FACTORY, 12); scrolls.remove(i); item.detach(hero.belongings.backpack); upgrade(); GLog.i("You infuse the scroll's energy into the book."); return; } } if (item != null) GLog.w("You are unable to add this scroll to the book."); } else if (item instanceof Scroll && !item.isIdentified()) GLog.w("You're not sure what type of scroll this is yet."); }
@Override protected void apply(Hero hero) { setKnown(); Buff.affect(hero, Invisibility.class, Invisibility.DURATION); GLog.i("You see your hands turn invisible!"); Sample.INSTANCE.play(Assets.SND_MELD); }
public void add(State state) { switch (state) { case BURNING: burning = emitter(); burning.pour(FlameParticle.FACTORY, 0.06f); if (getVisible()) { Sample.INSTANCE.play(Assets.SND_BURNING); } break; case LEVITATING: levitation = emitter(); levitation.pour(Speck.factory(Speck.JET), 0.02f); break; case INVISIBLE: PotionOfInvisibility.melt(ch); break; case PARALYSED: paused = true; break; case FROZEN: iceBlock = IceBlock.freeze(this); paused = true; break; case ILLUMINATED: GameScene.effect(halo = new TorchHalo(this)); break; } }
private void inscribeEffect() { getCurUser().getSprite().operate(getCurUser().getPos()); getCurUser().getSprite().centerEmitter().start(PurpleParticle.BURST, 0.05f, 10); Sample.INSTANCE.play(Assets.SND_BURNING); getCurUser().spend(TIME_TO_INSCRIBE); getCurUser().busy(); }
@Override public void die(Object cause) { super.die(cause); if (Dungeon.visible[pos]) { Sample.INSTANCE.play(Assets.SND_BONES); } }
public static void enter(int pos) { Level.set(pos, Terrain.OPEN_DOOR); GameScene.updateMap(pos); Dungeon.observe(); if (Dungeon.visible[pos]) { Sample.INSTANCE.play(Assets.SND_OPEN); } }
public Plant couch(int pos) { try { Sample.INSTANCE.play(Assets.SND_PLANT); Plant plant = plantClass.newInstance(); plant.pos = pos; return plant; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public boolean attachTo(Char target) { if (super.attachTo(target)) { Sample.INSTANCE.play(Assets.SND_MELD); Dungeon.observe(); return true; } else { return false; } }
@Override public void shatter(int cell) { if (Dungeon.visible[cell]) { setKnown(); splash(cell); Sample.INSTANCE.play(Assets.SND_SHATTER); } GameScene.add(Blob.seed(cell, 1000, ParalyticGas.class)); }
@Override protected void doRead() { Sample.INSTANCE.play(Assets.SND_READ); Invisibility.dispel(); teleportHero(curUser); setKnown(); curUser.spendAndNext(TIME_TO_READ); }
public void setDonationLevel(int level) { if (level < donated()) { return; } if (donated() == 0 && level != 0) { Sample.INSTANCE.play(Assets.SND_GOLD); Badges.validateSupporter(); } donated(level); }
@Override protected void doRead() { Sample.INSTANCE.play(Assets.SND_READ); Invisibility.dispel(); teleportHero(curUser); setKnown(); readAnimation(); }
@Override public void activate() { for (int i : Level.NEIGHBOURS9DIST2) { if (Level.insideMap(pos + i) && !Level.solid[pos + i]) { if (Level.pit[pos + i] || Level.water[pos + i]) GameScene.add(Blob.seed(pos + i, 1, Fire.class)); else GameScene.add(Blob.seed(pos + i, 5, Fire.class)); CellEmitter.get(pos + i).burst(FlameParticle.FACTORY, 5); } } Sample.INSTANCE.play(Assets.SND_BURNING); }
public static void appear(Char ch, int pos) { ch.sprite.interruptMotion(); ch.move(pos); ch.sprite.place(pos); if (ch.invisible == 0) { ch.sprite.alpha(0); ch.sprite.parent.add(new AlphaTweener(ch.sprite, 1, 0.4f)); } ch.sprite.emitter().start(Speck.factory(Speck.LIGHT), 0.2f, 3); Sample.INSTANCE.play(Assets.SND_TELEPORT); }
@Override public boolean doPickUp(Hero hero) { Dungeon.gold += quantity; Statistics.goldCollected += quantity; Badges.validateGoldCollected(); GameScene.pickUp(this); hero.sprite.showStatus(CharSprite.NEUTRAL, TXT_VALUE, quantity); hero.spendAndNext(TIME_TO_PICK_UP); Sample.INSTANCE.play(Assets.SND_GOLD, 1, 1, Random.Float(0.9f, 1.1f)); return true; }
@Override public void update() { super.update(); visible = (heap == null || Dungeon.visible[heap.pos]); if (dropInterval > 0 && (dropInterval -= Game.elapsed) <= 0) { speed.set(0); acc.set(0); place(heap.pos); if (visible) { boolean water = Level.water[heap.pos]; if (water) { GameScene.ripple(heap.pos); } else { int cell = Dungeon.level.map[heap.pos]; water = (cell == Terrain.WELL || cell == Terrain.ALCHEMY); } if (!(heap.peek() instanceof Gold)) { Sample.INSTANCE.play(water ? Assets.SND_WATER : Assets.SND_STEP, 0.8f, 0.8f, 1.2f); } } } if (visible && glowing != null) { if (glowUp && (phase += Game.elapsed) > glowing.period) { glowUp = false; phase = glowing.period; } else if (!glowUp && (phase -= Game.elapsed) < 0) { glowUp = true; phase = 0; } float value = phase / glowing.period * 0.6f; rm = gm = bm = 1 - value; ra = glowing.red * value; ga = glowing.green * value; ba = glowing.blue * value; } }
public void drop() { if (heap.isEmpty()) { return; } dropInterval = DROP_INTERVAL; speed.set(0, -100); acc.set(0, -speed.y / DROP_INTERVAL * 2); if (visible && heap != null && heap.peek() instanceof Gold) { CellEmitter.center(heap.pos).burst(Speck.factory(Speck.COIN), 5); Sample.INSTANCE.play(Assets.SND_GOLD, 1, 1, Random.Float(0.9f, 1.1f)); } }
@Override protected boolean affectHero(Hero hero) { Sample.INSTANCE.play(Assets.SND_DRINK); PotionOfHealing.heal(hero); hero.belongings.uncurseEquipped(); ((Hunger) hero.buff(Hunger.class)).satisfy(Hunger.STARVING); CellEmitter.get(pos).start(ShaftParticle.FACTORY, 0.2f, 3); Dungeon.hero.interrupt(); GLog.p(TXT_PROCCED); Journal.remove(Feature.WELL_OF_HEALTH); return true; }
private void summon() { nextPedestal = !nextPedestal; sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2); Sample.INSTANCE.play(Assets.SND_CHALLENGE); boolean[] passable = Level.passable.clone(); for (Char c : Actor.chars()) { passable[c.pos] = false; } int undeadsToSummon = maxArmySize() - Undead.count; PathFinder.buildDistanceMap(pos, passable, undeadsToSummon); PathFinder.distance[pos] = Integer.MAX_VALUE; int dist = 1; undeadLabel: for (int i = 0; i < undeadsToSummon; i++) { do { for (int j = 0; j < Level.LENGTH; j++) { if (PathFinder.distance[j] == dist) { Undead undead = new Undead(); undead.pos = j; GameScene.add(undead); ScrollOfTeleportation.appear(undead, j); new Flare(3, 32).color(0x000000, false).show(undead.sprite, 2f); PathFinder.distance[j] = Integer.MAX_VALUE; continue undeadLabel; } } dist++; } while (dist < undeadsToSummon); } yell("Arise, slaves!"); }
public static void heroFall(int pos) { jumpConfirmed = false; Sample.INSTANCE.play(Assets.SND_FALLING); if (Dungeon.hero.isAlive()) { Dungeon.hero.interrupt(); InterlevelScene.mode = InterlevelScene.Mode.FALL; if (Dungeon.level instanceof RegularLevel) { Room room = ((RegularLevel) Dungeon.level).room(pos); InterlevelScene.fallIntoPit = room != null && room.type == Room.Type.WEAK_FLOOR; } else { InterlevelScene.fallIntoPit = false; } Game.switchScene(InterlevelScene.class); } else { Dungeon.hero.sprite.visible = false; } }
public void earnExp(int exp) { this.exp += exp; boolean levelUp = false; while (this.exp >= maxExp()) { this.exp -= maxExp(); lvl++; HT += 5; HP += 5; attackSkill++; defenseSkill++; if (lvl < 10) { updateAwareness(); } levelUp = true; } if (levelUp) { GLog.p(TXT_NEW_LEVEL, lvl); sprite.showStatus(CharSprite.POSITIVE, TXT_LEVEL_UP); Sample.INSTANCE.play(Assets.SND_LEVELUP); Badges.validateLevelReached(); } if (subClass == HeroSubClass.WARLOCK) { int value = Math.min(HT - HP, 1 + (Dungeon.depth - 1) / 5); if (value > 0) { HP += value; sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); } ((Hunger) buff(Hunger.class)).satisfy(1); } }