コード例 #1
0
  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 statue = null;
    if (entrance.x == room.left) {
      statue = new Point(room.right - 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
    } else if (entrance.x == room.right) {
      statue = new Point(room.left + 1, Random.Int(2) == 0 ? room.top + 1 : room.bottom - 1);
    } else if (entrance.y == room.top) {
      statue = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.bottom - 1);
    } else if (entrance.y == room.bottom) {
      statue = new Point(Random.Int(2) == 0 ? room.left + 1 : room.right - 1, room.top + 1);
    }
    if (statue != null) {
      set(level, statue, Terrain.STATUE);
    }

    int n = Random.IntRange(1, 2);
    for (int i = 0; i < n; i++) {
      int pos;
      do {
        pos = level.pointToCell(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(Dungeon.depth));
  }
コード例 #2
0
  public static void paint(Level level, Room room) {

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

    pasWidth = room.width() - 2;
    pasHeight = room.height() - 2;
    int per = pasWidth * 2 + pasHeight * 2;

    if (itemsToSpawn == null) generateItems();

    int pos = xy2p(room, room.entrance()) + (per - itemsToSpawn.size()) / 2;
    for (Item item : itemsToSpawn) {

      Point xy = p2xy(room, (pos + per) % per);
      int cell = xy.x + xy.y * Level.WIDTH;

      if (level.heaps.get(cell) != null) {
        do {
          cell = room.random();
        } while (level.heaps.get(cell) != null);
      }

      level.drop(item, cell).type = Heap.Type.FOR_SALE;

      pos++;
    }

    placeShopkeeper(level, room);

    for (Room.Door door : room.connected.values()) {
      door.set(Room.Door.Type.REGULAR);
    }

    itemsToSpawn = null;
  }