v1.1.0: fixed various errors with mass sheep spawning
This commit is contained in:
parent
f2d17231ca
commit
e43a0b56da
|
@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Sheep;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
|
@ -34,6 +35,8 @@ import com.watabou.noosa.audio.Sample;
|
|||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WoollyBomb extends Bomb {
|
||||
|
||||
{
|
||||
|
@ -45,18 +48,23 @@ public class WoollyBomb extends Bomb {
|
|||
super.explode(cell);
|
||||
|
||||
PathFinder.buildDistanceMap( cell, BArray.not( Dungeon.level.solid, null ), 4 );
|
||||
ArrayList<Integer> spawnPoints = new ArrayList<>();
|
||||
for (int i = 0; i < PathFinder.distance.length; i++) {
|
||||
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 12, 16 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
}
|
||||
spawnPoints.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : spawnPoints){
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 12, 16 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Sheep;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
|
@ -34,6 +35,8 @@ import com.watabou.noosa.audio.Sample;
|
|||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StoneOfFlock extends Runestone {
|
||||
|
||||
{
|
||||
|
@ -47,20 +50,26 @@ public class StoneOfFlock extends Runestone {
|
|||
protected void activate(int cell) {
|
||||
|
||||
PathFinder.buildDistanceMap( cell, BArray.not( Dungeon.level.solid, null ), 2 );
|
||||
ArrayList<Integer> spawnPoints = new ArrayList<>();
|
||||
for (int i = 0; i < PathFinder.distance.length; i++) {
|
||||
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 6, 8 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
}
|
||||
spawnPoints.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : spawnPoints){
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 6, 8 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
}
|
||||
}
|
||||
|
||||
CellEmitter.get(cell).burst(Speck.factory(Speck.WOOL), 4);
|
||||
Sample.INSTANCE.play(Assets.Sounds.PUFF);
|
||||
Sample.INSTANCE.play(Assets.Sounds.SHEEP);
|
||||
|
|
|
@ -33,6 +33,8 @@ import com.watabou.noosa.audio.Sample;
|
|||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FlockTrap extends Trap {
|
||||
|
||||
{
|
||||
|
@ -44,27 +46,32 @@ public class FlockTrap extends Trap {
|
|||
@Override
|
||||
public void activate() {
|
||||
PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 );
|
||||
ArrayList<Integer> spawnPoints = new ArrayList<>();
|
||||
for (int i = 0; i < PathFinder.distance.length; i++) {
|
||||
Trap t;
|
||||
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 4, 8 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
//before the tile is pressed, directly trigger traps to avoid sfx spam
|
||||
if ((t = Dungeon.level.traps.get(i)) != null && t.active){
|
||||
if (t.disarmedByActivation) t.disarm();
|
||||
t.reveal();
|
||||
t.activate();
|
||||
}
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
Sample.INSTANCE.play(Assets.Sounds.PUFF);
|
||||
Sample.INSTANCE.play(Assets.Sounds.SHEEP);
|
||||
spawnPoints.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : spawnPoints){
|
||||
Trap t;
|
||||
if (Dungeon.level.insideMap(i)
|
||||
&& Actor.findChar(i) == null
|
||||
&& !(Dungeon.level.pit[i])) {
|
||||
Sheep sheep = new Sheep();
|
||||
sheep.lifespan = Random.NormalIntRange( 4, 8 );
|
||||
sheep.pos = i;
|
||||
GameScene.add(sheep);
|
||||
CellEmitter.get(i).burst(Speck.factory(Speck.WOOL), 4);
|
||||
//before the tile is pressed, directly trigger traps to avoid sfx spam
|
||||
if ((t = Dungeon.level.traps.get(i)) != null && t.active){
|
||||
if (t.disarmedByActivation) t.disarm();
|
||||
t.reveal();
|
||||
t.activate();
|
||||
}
|
||||
Dungeon.level.occupyCell(sheep);
|
||||
Sample.INSTANCE.play(Assets.Sounds.PUFF);
|
||||
Sample.INSTANCE.play(Assets.Sounds.SHEEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user