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 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;
   }
 }
  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);
  }
Exemple #4
0
  @Override
  public int attackProc(Char enemy, int damage) {

    int reg = Math.min(damage, HT - HP);

    if (reg > 0) {
      HP += reg;
      sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
    }

    return damage;
  }
  @Override
  protected void onItemSelected(Item item) {

    Weapon weapon = (Weapon) item;

    ScrollOfRemoveCurse.uncurse(Dungeon.hero, weapon);
    weapon.upgrade(true);

    GLog.p(TXT_LOOKS_BETTER, weapon.name());

    Badges.validateItemLevelAquired(weapon);

    curUser.sprite.emitter().start(Speck.factory(Speck.UP), 0.2f, 3);
  }
  @Override
  protected void onItemSelected(Item item) {

    ScrollOfRemoveCurse.uncurse(Dungeon.hero, item);

    if (item instanceof Weapon) {

      ((Weapon) item).enchant();

    } else {

      ((Armor) item).inscribe();
    }

    item.fix();

    curUser.sprite.emitter().start(Speck.factory(Speck.LIGHT), 0.1f, 5);
    Enchanting.show(curUser, item);
    GLog.w(TXT_GLOWS, item.name());
  }
  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(10);
    }
  }
  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 void shatter(int cell) {

    PathFinder.buildDistanceMap(cell, BArray.not(Level.losBlocking, null), DISTANCE);

    boolean procd = false;

    Blob[] blobs = {
      Dungeon.level.blobs.get(ToxicGas.class), Dungeon.level.blobs.get(ParalyticGas.class)
    };

    for (int j = 0; j < blobs.length; j++) {

      Blob blob = blobs[j];
      if (blob == null) {
        continue;
      }

      for (int i = 0; i < Level.LENGTH; i++) {
        if (PathFinder.distance[i] < Integer.MAX_VALUE) {

          int value = blob.cur[i];
          if (value > 0) {

            blob.cur[i] = 0;
            blob.volume -= value;
            procd = true;

            if (Dungeon.visible[i]) {
              CellEmitter.get(i).burst(Speck.factory(Speck.DISCOVER), 1);
            }
          }
        }
      }
    }

    boolean heroAffected = PathFinder.distance[Dungeon.hero.pos] < Integer.MAX_VALUE;

    if (procd) {

      if (Dungeon.visible[cell]) {
        splash(cell);
        Sample.INSTANCE.play(Assets.SND_SHATTER);
      }

      setKnown();

      if (heroAffected) {
        GLog.p(TXT_FRESHNESS);
      }

    } else {

      super.shatter(cell);

      if (heroAffected) {
        GLog.i(TXT_FRESHNESS);
        setKnown();
      }
    }
  }