@Override public void execute(Hero hero, String action) { super.execute(hero, action); if (action.equals(Food.AC_EAT)) { ScrollOfTeleportation.teleportHero(hero); hero.spendAndNext(1); hero.curAction = null; Buff.affect(hero, Vertigo.class, Vertigo.DURATION * 2); } }
public static void saveAll() throws IOException { if (hero.isAlive()) { Actor.fixTime(); saveGame(gameFile(hero.heroClass)); saveLevel(); GamesInProgress.set(hero.heroClass, depth, hero.lvl); } else if (WndResurrect.instance != null) { WndResurrect.instance.hide(); Hero.reallyDie(WndResurrect.causeOfDeath); } }
@Override public boolean doEquip(Hero hero) { if (hero.belongings.ring1 != null && hero.belongings.ring2 != null) { GLog.w(Game.getVar(R.string.Ring_Info1)); return false; } else { if (hero.belongings.ring1 == null) { hero.belongings.ring1 = this; } else { hero.belongings.ring2 = this; } detach(hero.belongings.backpack); activate(hero); cursedKnown = true; if (cursed) { equipCursed(hero); GLog.n(String.format(Game.getVar(R.string.Ring_Info2), this)); } hero.spendAndNext(Artifact.TIME_TO_EQUIP); return true; } }
public static void preview(GamesInProgress.Info info, Bundle bundle) { info.depth = bundle.getInt(DEPTH); if (info.depth == -1) { info.depth = bundle.getInt("maxDepth"); // FIXME } Hero.preview(info, bundle.getBundle(HERO)); }
@Override public boolean doEquip(Hero hero) { detachAll(hero.belongings.backpack); if (hero.belongings.weapon == null || hero.belongings.weapon.doUnequip(hero, true)) { hero.belongings.weapon = this; activate(hero); QuickSlot.refresh(); cursedKnown = true; if (cursed) { equipCursed(hero); GLog.n(TXT_EQUIP_CURSED, name()); } hero.spendAndNext(TIME_TO_EQUIP); return true; } else { collect(hero.belongings.backpack); return false; } }
public static void heal(Hero hero) { hero.HP = hero.HT; Buff.detach(hero, Poison.class); Buff.detach(hero, Cripple.class); Buff.detach(hero, Weakness.class); Buff.detach(hero, Bleeding.class); hero.sprite.emitter().start(Speck.factory(Speck.HEALING), 0.4f, 4); }
@Override public float speedFactor(Hero hero) { int encumrance = STR - hero.STR(); if (this instanceof MissileWeapon && hero.heroClass == HeroClass.HUNTRESS) { encumrance -= 2; } return encumrance > 0 ? (float) (DLY * Math.pow(1.2, encumrance)) : DLY; }
public static void heroLand() { Hero hero = Dungeon.hero; hero.sprite.burst(hero.sprite.blood(), 10); Camera.main.shake(4, 0.2f); Buff.prolong(hero, Cripple.class, Cripple.DURATION); hero.damage( Random.IntRange(hero.HT / 3, hero.HT / 2), new Hero.Doom() { @Override public void onDeath() { Badges.validateDeathFromFalling(); Dungeon.fail(Utils.format(ResultDescriptions.FALL, Dungeon.depth)); GLog.n("You fell to death..."); } }); }
private void circleBack(int from, Hero owner) { ((MissileSprite) curUser.sprite.parent.recycle(MissileSprite.class)) .reset(from, curUser.pos, curItem, null); if (throwEquiped) { owner.belongings.weapon = this; owner.spend(-TIME_TO_EQUIP); } else if (!collect(curUser.belongings.backpack)) { Dungeon.level.drop(this, owner.pos).sprite.drop(); } }
@SuppressWarnings("deprecation") public static void switchLevel(final Level level, int pos) { nightMode = new Date().getHours() < 7; Dungeon.level = level; Actor.init(); Actor respawner = level.respawner(); if (respawner != null) { Actor.add(level.respawner()); } hero.pos = pos != -1 ? pos : level.exit; Light light = hero.buff(Light.class); hero.viewDistance = light == null ? level.viewDistance : Math.max(Light.DISTANCE, level.viewDistance); observe(); }
public void effect(int pos, Char ch) { if (ch instanceof Hero) { Hero hero = (Hero) ch; ScrollOfTeleportation.teleportHero(hero); hero.spendAndNext(1); hero.curAction = null; } else if (ch instanceof Mob) { int newPos = Dungeon.level.randomRespawnCell(); if (newPos != -1) { ch.setPos(newPos); ch.getSprite().place(ch.getPos()); ch.getSprite().setVisible(Dungeon.visible[pos]); } } if (Dungeon.visible[pos]) { CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); } }
@Override public int damageRoll(Hero hero) { int damage = super.damageRoll(hero); if (hero.usingRanged == (hero.heroClass == HeroClass.HUNTRESS)) { int exStr = hero.STR() - STR; if (exStr > 0) { damage += Random.IntRange(0, exStr); } } return damage; }
@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 execute(Hero hero, String action) { if (action.equals(AC_READ)) { if (hero.buff(Blindness.class) != null) { GLog.w(TXT_BLINDED); } else { curUser = hero; curItem = detach(hero.belongings.backpack); doRead(); } } else { super.execute(hero, action); } }
@Override public boolean doUnequip(Hero hero, boolean collect, boolean single) { if (super.doUnequip(hero, collect, single)) { if (hero.belongings.ring1 == this) { hero.belongings.ring1 = null; } else { hero.belongings.ring2 = null; } hero.remove(buff); buff = null; return true; } else { return false; } }
@Override public float acuracyFactor(Hero hero) { int encumbrance = STR - hero.STR(); if (this instanceof MissileWeapon) { switch (hero.heroClass) { case WARRIOR: encumbrance += 3; break; case HUNTRESS: encumbrance -= 2; break; default: } } return encumbrance > 0 ? (float) (ACU / Math.pow(1.5, encumbrance)) : ACU; }
public static void init() { challenges = PixelDungeon.challenges(); Actor.clear(); PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT); Scroll.initLabels(); Potion.initColors(); Wand.initWoods(); Ring.initGems(); Statistics.reset(); Journal.reset(); depth = 0; gold = 0; potionOfStrength = 0; scrollsOfUpgrade = 0; arcaneStyli = 0; dewVial = true; transmutation = Random.IntRange(6, 14); chapters = new HashSet<Integer>(); Ghost.Quest.reset(); WandMaker.Quest.reset(); Blacksmith.Quest.reset(); Imp.Quest.reset(); Room.shuffleTypes(); hero = new Hero(); hero.live(); Badges.reset(); StartScene.curClass.initHero(hero); }
@Override public void execute(Hero hero, String action) { if (action.equals(AC_PLANT)) { hero.spend(TIME_TO_PLANT); hero.busy(); ((Seed) detach(hero.belongings.backpack)).onThrow(hero.pos); hero.getSprite().operate(hero.pos); } else if (action.equals(Food.AC_EAT)) { detach(hero.belongings.backpack); hero.getSprite().operate(hero.pos); hero.busy(); SpellSprite.show(hero, SpellSprite.FOOD); Sample.INSTANCE.play(Assets.SND_EAT); hero.spend(Food.TIME_TO_EAT); } super.execute(hero, action); }
@Override protected void apply(Hero hero) { setKnown(); hero.earnExp(hero.maxExp() - hero.exp); }