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