Esempio n. 1
0
  @Override
  public void die(Object cause) {

    curAction = null;

    DewVial.autoDrink(this);
    if (isAlive()) {
      new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f);
      return;
    }

    Actor.fixTime();
    super.die(cause);

    Ankh ankh = (Ankh) belongings.getItem(Ankh.class);
    if (ankh == null) {

      reallyDie(cause);

    } else {

      Dungeon.deleteGame(Dungeon.hero.heroClass, false);
      GameScene.show(new WndResurrect(ankh, cause));
    }
  }
Esempio n. 2
0
  @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();
  }
Esempio n. 3
0
 @Override
 public void spend(float time) {
   int hasteLevel = 0;
   for (Buff buff : buffs(RingOfHaste.Haste.class)) {
     hasteLevel += ((RingOfHaste.Haste) buff).level;
   }
   super.spend(hasteLevel == 0 ? time : (float) (time * Math.pow(1.1, -hasteLevel)));
 };
Esempio n. 4
0
  @Override
  public void onMotionComplete() {

    Dungeon.observe();
    search(false);

    super.onMotionComplete();
  }
Esempio n. 5
0
  @Override
  public void damage(int dmg, Object src) {
    restoreHealth = false;
    super.damage(dmg, src);

    if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
      Buff.affect(this, Fury.class);
    }
  }
Esempio n. 6
0
  @Override
  public void remove(Buff buff) {
    super.remove(buff);

    if (buff instanceof Light) {
      sprite.remove(CharSprite.State.ILLUMINATED);
    }

    BuffIndicator.refreshHero();
  }
Esempio n. 7
0
  @Override
  public void onAttackComplete() {

    AttackIndicator.target(enemy);

    attack(enemy);
    curAction = null;

    Invisibility.dispel();

    super.onAttackComplete();
  }
Esempio n. 8
0
  @Override
  protected void evolve() {
    super.evolve();

    int levelDamage = 5 + Dungeon.depth * 5;

    Char ch;
    for (int i = 0; i < LENGTH; i++) {
      if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) {

        int damage = (ch.HT + levelDamage) / 40;
        if (damage < 1) {
          damage = 1;
        }

        ch.damage(damage, this);
      }
    }

    Blob blob = Dungeon.level.blobs.get(ParalyticGas.class);
    if (blob != null) {

      int par[] = blob.cur;

      for (int i = 0; i < LENGTH; i++) {

        int t = cur[i];
        int p = par[i];

        if (p >= t) {
          volume -= t;
          cur[i] = 0;
        } else {
          blob.volume -= p;
          par[i] = 0;
        }
      }
    }
  }
Esempio n. 9
0
  @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);
    }
  }
Esempio n. 10
0
  @Override
  public void storeInBundle(Bundle bundle) {
    super.storeInBundle(bundle);

    heroClass.storeInBundle(bundle);
    subClass.storeInBundle(bundle);

    bundle.put(ATTACK, attackSkill);
    bundle.put(DEFENSE, defenseSkill);

    bundle.put(STRENGTH, STR);

    bundle.put(LEVEL, lvl);
    bundle.put(EXPERIENCE, exp);

    belongings.storeInBundle(bundle);
  }
Esempio n. 11
0
  private void actAttack(HeroAction.Attack action) {

    enemy = action.target;

    if (Level.adjacent(pos, enemy.pos) && enemy.isAlive() && !pacified) {

      spend(attackDelay());
      sprite.attack(enemy.pos);

    } else {

      if (Level.fieldOfView[enemy.pos] && getCloser(enemy.pos)) {

      } else {
        ready();
      }
    }
  }
Esempio n. 12
0
  @Override
  public void restoreFromBundle(Bundle bundle) {
    super.restoreFromBundle(bundle);

    heroClass = HeroClass.restoreInBundle(bundle);
    subClass = HeroSubClass.restoreInBundle(bundle);

    attackSkill = bundle.getInt(ATTACK);
    defenseSkill = bundle.getInt(DEFENSE);

    STR = bundle.getInt(STRENGTH);
    updateAwareness();

    lvl = bundle.getInt(LEVEL);
    exp = bundle.getInt(EXPERIENCE);

    belongings.restoreFromBundle(bundle);
  }
Esempio n. 13
0
  @Override
  public int defenseProc(Char enemy, int damage) {

    RingOfThorns.Thorns thorns = buff(RingOfThorns.Thorns.class);
    if (thorns != null) {
      int dmg = Random.IntRange(0, damage);
      if (dmg > 0) {
        enemy.damage(dmg, thorns);
      }
    }

    Earthroot.Armor armor = buff(Earthroot.Armor.class);
    if (armor != null) {
      damage = armor.absorb(damage);
    }

    if (belongings.armor != null) {
      damage = belongings.armor.proc(enemy, this, damage);
    }

    return damage;
  }
Esempio n. 14
0
  @Override
  public void add(Buff buff) {
    super.add(buff);

    if (sprite != null) {
      if (buff instanceof Burning) {
        GLog.w("You catch fire!");
        interrupt();
      } else if (buff instanceof Paralysis) {
        GLog.w("You are paralysed!");
        interrupt();
      } else if (buff instanceof Poison) {
        GLog.w("You are poisoned!");
        interrupt();
      } else if (buff instanceof Ooze) {
        GLog.w("Caustic ooze eats your flesh. Wash away it!");
      } else if (buff instanceof Roots) {
        GLog.w("You can't move!");
      } else if (buff instanceof Weakness) {
        GLog.w("You feel weakened!");
      } else if (buff instanceof Blindness) {
        GLog.w("You are blinded!");
      } else if (buff instanceof Fury) {
        GLog.w("You become furious!");
        sprite.showStatus(CharSprite.POSITIVE, "furious");
      } else if (buff instanceof Charm) {
        GLog.w("You are charmed!");
      } else if (buff instanceof Cripple) {
        GLog.w("You are crippled!");
      } else if (buff instanceof Bleeding) {
        GLog.w("You are bleeding!");
      } else if (buff instanceof Light) {
        sprite.add(CharSprite.State.ILLUMINATED);
      }
    }

    BuffIndicator.refreshHero();
  }
Esempio n. 15
0
  @Override
  public boolean act() {

    super.act();

    if (paralysed) {

      curAction = null;

      spendAndNext(TICK);
      return false;
    }

    checkVisibleMobs();
    AttackIndicator.updateState();

    if (curAction == null) {

      if (restoreHealth) {
        if (isStarving() || HP >= HT) {
          restoreHealth = false;
        } else {
          spend(TIME_TO_REST);
          next();
          return false;
        }
      }

      ready();

    } else {

      restoreHealth = false;

      ready = false;

      if (curAction instanceof HeroAction.Move) {

        actMove((HeroAction.Move) curAction);

      } else if (curAction instanceof HeroAction.Interact) {

        actInteract((HeroAction.Interact) curAction);

      } else if (curAction instanceof HeroAction.Buy) {

        actBuy((HeroAction.Buy) curAction);

      } else if (curAction instanceof HeroAction.PickUp) {

        actPickUp((HeroAction.PickUp) curAction);

      } else if (curAction instanceof HeroAction.OpenChest) {

        actOpenChest((HeroAction.OpenChest) curAction);

      } else if (curAction instanceof HeroAction.Unlock) {

        actUnlock((HeroAction.Unlock) curAction);

      } else if (curAction instanceof HeroAction.Descend) {

        actDescend((HeroAction.Descend) curAction);

      } else if (curAction instanceof HeroAction.Ascend) {

        actAscend((HeroAction.Ascend) curAction);

      } else if (curAction instanceof HeroAction.Attack) {

        actAttack((HeroAction.Attack) curAction);

      } else if (curAction instanceof HeroAction.Cook) {

        actCook((HeroAction.Cook) curAction);
      }
    }

    return false;
  }