Exemple #1
0
  public static void observe() {

    if (level == null) {
      return;
    }

    level.updateFieldOfView(hero);
    System.arraycopy(Level.fieldOfView, 0, visible, 0, visible.length);

    BArray.or(level.visited, visible, level.visited);

    GameScene.afterObserve();
  }
Exemple #2
0
  public static int flee(Char ch, int cur, int from, boolean pass[], boolean[] visible) {

    if (ch.flying) {
      BArray.or(pass, Level.avoid, passable);
    } else {
      System.arraycopy(pass, 0, passable, 0, Level.LENGTH);
    }

    for (Actor actor : Actor.all()) {
      if (actor instanceof Char) {
        int pos = ((Char) actor).pos;
        if (visible[pos]) {
          passable[pos] = false;
        }
      }
    }
    passable[cur] = true;

    return PathFinder.getStepBack(cur, from, passable);
  }
Exemple #3
0
  public static int findPath(Char ch, int from, int to, boolean pass[], boolean[] visible) {

    if (Level.adjacent(from, to)) {
      return Actor.findChar(to) == null && (pass[to] || Level.avoid[to]) ? to : -1;
    }

    if (ch.flying || ch.buff(Amok.class) != null) {
      BArray.or(pass, Level.avoid, passable);
    } else {
      System.arraycopy(pass, 0, passable, 0, Level.LENGTH);
    }

    for (Actor actor : Actor.all()) {
      if (actor instanceof Char) {
        int pos = ((Char) actor).pos;
        if (visible[pos]) {
          passable[pos] = false;
        }
      }
    }

    return PathFinder.getStep(from, to, passable);
  }
  @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();
      }
    }
  }