use of com.shatteredpixel.shatteredpixeldungeon.actors.mobs.NewbornElemental in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CeremonialCandle method checkCandles.
private static void checkCandles() {
Heap heapTop = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width());
Heap heapRight = Dungeon.level.heaps.get(ritualPos + 1);
Heap heapBottom = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width());
Heap heapLeft = Dungeon.level.heaps.get(ritualPos - 1);
if (heapTop != null && heapRight != null && heapBottom != null && heapLeft != null) {
if (heapTop.peek() instanceof CeremonialCandle && heapRight.peek() instanceof CeremonialCandle && heapBottom.peek() instanceof CeremonialCandle && heapLeft.peek() instanceof CeremonialCandle) {
heapTop.pickUp();
heapRight.pickUp();
heapBottom.pickUp();
heapLeft.pickUp();
NewbornElemental elemental = new NewbornElemental();
Char ch = Actor.findChar(ritualPos);
if (ch != null) {
ArrayList<Integer> candidates = new ArrayList<>();
for (int n : PathFinder.NEIGHBOURS8) {
int cell = ritualPos + n;
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
candidates.add(cell);
}
}
if (candidates.size() > 0) {
elemental.pos = Random.element(candidates);
} else {
elemental.pos = ritualPos;
}
} else {
elemental.pos = ritualPos;
}
elemental.state = elemental.HUNTING;
GameScene.add(elemental, 1);
for (int i : PathFinder.NEIGHBOURS9) {
CellEmitter.get(ritualPos + i).burst(ElmoParticle.FACTORY, 10);
}
Sample.INSTANCE.play(Assets.SND_BURNING);
}
}
}
Aggregations