Exemplo n.º 1
0
  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();
    }
  }
Exemplo n.º 2
0
  @Override
  public void onDeath() {

    Badges.validateDeathFromGas();

    Dungeon.fail(Utils.format(ResultDescriptions.GAS, Dungeon.depth));
    GLog.n("You died from a toxic gas..");
  }
Exemplo n.º 3
0
  private void actPickUp(HeroAction.PickUp action) {
    int dst = action.dst;
    if (pos == dst) {

      Heap heap = Dungeon.level.heaps.get(pos);
      if (heap != null) {
        Item item = heap.pickUp();
        if (item.doPickUp(this)) {

          if (item instanceof Dewdrop) {

          } else {

            if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade) item).isKnown())
                || (item instanceof PotionOfStrength && ((PotionOfStrength) item).isKnown())) {
              GLog.p(TXT_YOU_NOW_HAVE, item.name());
            } else {
              GLog.i(TXT_YOU_NOW_HAVE, item.name());
            }
          }

          if (!heap.isEmpty()) {
            GLog.i(TXT_SOMETHING_ELSE);
          }
          curAction = null;
        } else {
          Dungeon.level.drop(item, pos).sprite.drop();
          ready();
        }
      } else {
        ready();
      }

    } else if (getCloser(dst)) {

    } else {
      ready();
    }
  }
Exemplo n.º 4
0
  private void 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;
          }
        }

        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();
      }

    } else if (getCloser(dst)) {

    } else {
      ready();
    }
  }
Exemplo n.º 5
0
  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);
    }
  }
Exemplo n.º 6
0
  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;
  }
Exemplo n.º 7
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();
  }