@Override protected void doRead() { ArrayList<Integer> respawnPoints = new ArrayList<Integer>(); for (int i = 0; i < Level.NEIGHBOURS8.length; i++) { int p = curUser.pos + Level.NEIGHBOURS8[i]; if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) { respawnPoints.add(p); } } int nImages = NIMAGES; while (nImages > 0 && respawnPoints.size() > 0) { int index = Random.index(respawnPoints); MirrorImage mob = new MirrorImage(); mob.duplicate(curUser); GameScene.add(mob); WandOfBlink.appear(mob, respawnPoints.get(index)); respawnPoints.remove(index); nImages--; } if (nImages < NIMAGES) { setKnown(); } Sample.INSTANCE.play(Assets.SND_READ); Invisibility.dispel(); curUser.spendAndNext(TIME_TO_READ); }
public static boolean[] generate(float seed, int nGen) { int w = Level.WIDTH; int h = Level.HEIGHT; for (int i = 0; i < Level.LENGTH; i++) { off[i] = Random.Float() < seed; } for (int i = 0; i < nGen; i++) { for (int y = 1; y < h - 1; y++) { for (int x = 1; x < w - 1; x++) { int pos = x + y * w; int count = 0; if (off[pos - w - 1]) { count++; } if (off[pos - w]) { count++; } if (off[pos - w + 1]) { count++; } if (off[pos - 1]) { count++; } if (off[pos + 1]) { count++; } if (off[pos + w - 1]) { count++; } if (off[pos + w]) { count++; } if (off[pos + w + 1]) { count++; } if (!off[pos] && count >= 5) { cur[pos] = true; } else if (off[pos] && count >= 4) { cur[pos] = true; } else { cur[pos] = false; } } } boolean[] tmp = cur; cur = off; off = tmp; } return off; }