public static void paint(Level level, Room room) {

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

    Room.Door entrance = room.entrance();

    Point pot = null;
    if (entrance.x == room.left) {
      pot = new Point(room.right - 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
    } else if (entrance.x == room.right) {
      pot = new Point(room.left + 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
    } else if (entrance.y == room.top) {
      pot = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.bottom - 1);
    } else if (entrance.y == room.bottom) {
      pot = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.top + 1);
    }
    set(level, pot, Terrain.ALCHEMY);

    Alchemy alchemy = new Alchemy();
    alchemy.seed(pot.x + level.getWidth() * pot.y, 1);
    level.blobs.put(Alchemy.class, alchemy);

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

    entrance.set(Room.Door.Type.LOCKED);
    level.addItemToSpawn(new IronKey());
  }
Пример #2
0
  public static void paint(Level level, Room room) {

    Integer traps[] = {
      Terrain.TOXIC_TRAP,
      Terrain.TOXIC_TRAP,
      Terrain.TOXIC_TRAP,
      Terrain.PARALYTIC_TRAP,
      Terrain.PARALYTIC_TRAP,
      !Dungeon.bossLevel(Dungeon.depth + 1) ? Terrain.CHASM : Terrain.SUMMONING_TRAP
    };
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Random.element(traps));

    Room.Door door = room.entrance();
    door.set(Room.Door.Type.REGULAR);

    int lastRow =
        level.map[room.left + 1 + (room.top + 1) * Level.WIDTH] == Terrain.CHASM
            ? Terrain.CHASM
            : Terrain.EMPTY;

    int x = -1;
    int y = -1;
    if (door.x == room.left) {
      x = room.right - 1;
      y = room.top + room.height() / 2;
      fill(level, x, room.top + 1, 1, room.height() - 1, lastRow);
    } else if (door.x == room.right) {
      x = room.left + 1;
      y = room.top + room.height() / 2;
      fill(level, x, room.top + 1, 1, room.height() - 1, lastRow);
    } else if (door.y == room.top) {
      x = room.left + room.width() / 2;
      y = room.bottom - 1;
      fill(level, room.left + 1, y, room.width() - 1, 1, lastRow);
    } else if (door.y == room.bottom) {
      x = room.left + room.width() / 2;
      y = room.top + 1;
      fill(level, room.left + 1, y, room.width() - 1, 1, lastRow);
    }

    int pos = x + y * Level.WIDTH;
    if (Random.Int(3) == 0) {
      if (lastRow == Terrain.CHASM) {
        set(level, pos, Terrain.EMPTY);
      }
      level.drop(prize(level), pos).type = Heap.Type.CHEST;
    } else {
      set(level, pos, Terrain.PEDESTAL);
      level.drop(prize(level), pos);
    }

    level.addItemToSpawn(new PotionOfLevitation());
  }
  private static Item prize(Level level) {

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

    return Generator.random(Generator.Category.POTION);
  }