コード例 #1
0
  public static void reallyDie(Object cause) {

    int length = Level.LENGTH;
    int[] map = Dungeon.level.map;
    boolean[] visited = Dungeon.level.visited;
    boolean[] discoverable = Level.discoverable;

    for (int i = 0; i < length; i++) {

      int terr = map[i];

      if (discoverable[i]) {

        visited[i] = true;
        if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
          Level.set(i, Terrain.discover(terr));
          GameScene.updateMap(i);
        }
      }
    }

    Bones.leave();

    Dungeon.observe();

    Dungeon.hero.belongings.identify();

    int pos = Dungeon.hero.pos;

    ArrayList<Integer> passable = new ArrayList<Integer>();
    for (Integer ofs : Level.NEIGHBOURS8) {
      int cell = pos + ofs;
      if ((Level.passable[cell] || Level.avoid[cell]) && Dungeon.level.heaps.get(cell) == null) {
        passable.add(cell);
      }
    }
    Collections.shuffle(passable);

    ArrayList<Item> items = new ArrayList<Item>(Dungeon.hero.belongings.backpack.items);
    for (Integer cell : passable) {
      if (items.isEmpty()) {
        break;
      }

      Item item = Random.element(items);
      Dungeon.level.drop(item, cell).sprite.drop(pos);
      items.remove(item);
    }

    GameScene.gameOver();

    if (cause instanceof Hero.Doom) {
      ((Hero.Doom) cause).onDeath();
    }

    Dungeon.deleteGame(Dungeon.hero.heroClass, true);
  }