private boolean canTryToSummon() { if (Undead.count < maxArmySize()) { Char ch = Actor.findChar(CityBossLevel.pedestal(nextPedestal)); return ch == this || ch == null; } else { return false; } }
@Override public boolean attack(Char enemy) { if (canTryToSummon() && pos == CityBossLevel.pedestal(nextPedestal)) { summon(); return true; } else { if (Actor.findChar(CityBossLevel.pedestal(nextPedestal)) == enemy) { nextPedestal = !nextPedestal; } return super.attack(enemy); } }
private void summon() { nextPedestal = !nextPedestal; sprite.centerEmitter().start(Speck.factory(Speck.SCREAM), 0.4f, 2); Sample.INSTANCE.play(Assets.SND_CHALLENGE); boolean[] passable = Level.passable.clone(); for (Char c : Actor.chars()) { passable[c.pos] = false; } int undeadsToSummon = maxArmySize() - Undead.count; PathFinder.buildDistanceMap(pos, passable, undeadsToSummon); PathFinder.distance[pos] = Integer.MAX_VALUE; int dist = 1; undeadLabel: for (int i = 0; i < undeadsToSummon; i++) { do { for (int j = 0; j < Level.LENGTH; j++) { if (PathFinder.distance[j] == dist) { Undead undead = new Undead(); undead.pos = j; GameScene.add(undead); ScrollOfTeleportation.appear(undead, j); new Flare(3, 32).color(0x000000, false).show(undead.sprite, 2f); PathFinder.distance[j] = Integer.MAX_VALUE; continue undeadLabel; } } dist++; } while (dist < undeadsToSummon); } yell("Arise, slaves!"); }