@Override
  public void onComplete(Animation anim) {
    super.onComplete(anim);

    if (visible && emitter != null && anim == idle) {
      emitter.burst(Speck.factory(Speck.FORGE), 3);
      float volume = 0.2f / (Level.distance(ch.pos, Dungeon.hero.pos));
      Sample.INSTANCE.play(Assets.SND_EVOKE, volume, volume, 0.8f);
    }
  }
  private static Item prize(Level level) {

    Item prize = level.itemToSpanAsPrize();
    if (prize instanceof Scroll) {
      return prize;
    } else if (prize != null) {
      level.addItemToSpawn(prize);
    }

    return Generator.random(Generator.Category.SCROLL);
  }
  public static void paint(Level level, Room room) {

    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Terrain.EMPTY);

    Room.Door entrance = room.entrance();
    Point a = null;
    Point b = null;

    if (entrance.x == room.left) {
      a = new Point(room.left + 1, entrance.y - 1);
      b = new Point(room.left + 1, entrance.y + 1);
      fill(level, room.right - 1, room.top + 1, 1, room.height() - 1, Terrain.BOOKSHELF);
    } else if (entrance.x == room.right) {
      a = new Point(room.right - 1, entrance.y - 1);
      b = new Point(room.right - 1, entrance.y + 1);
      fill(level, room.left + 1, room.top + 1, 1, room.height() - 1, Terrain.BOOKSHELF);
    } else if (entrance.y == room.top) {
      a = new Point(entrance.x + 1, room.top + 1);
      b = new Point(entrance.x - 1, room.top + 1);
      fill(level, room.left + 1, room.bottom - 1, room.width() - 1, 1, Terrain.BOOKSHELF);
    } else if (entrance.y == room.bottom) {
      a = new Point(entrance.x + 1, room.bottom - 1);
      b = new Point(entrance.x - 1, room.bottom - 1);
      fill(level, room.left + 1, room.top + 1, room.width() - 1, 1, Terrain.BOOKSHELF);
    }
    if (a != null && level.map[a.x + a.y * Level.WIDTH] == Terrain.EMPTY) {
      set(level, a, Terrain.STATUE);
    }
    if (b != null && level.map[b.x + b.y * Level.WIDTH] == Terrain.EMPTY) {
      set(level, b, Terrain.STATUE);
    }

    int n = Random.IntRange(2, 3);
    for (int i = 0; i < n; i++) {
      int pos;
      do {
        pos = room.random();
      } while (level.map[pos] != Terrain.EMPTY || level.heaps.get(pos) != null);
      level.drop(prize(level), pos);
    }

    entrance.set(Room.Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey());
  }
Example #4
0
  @Override
  public void attack(int cell) {
    if (!Level.adjacent(cell, ch.pos)) {

      cellToAttack = cell;
      turnTo(ch.pos, cell);
      play(zap);

    } else {

      super.attack(cell);
    }
  }