v3.3.0: improved how Goo's sprite emitters handle Goo being pushed
This commit is contained in:
@@ -43,6 +43,9 @@ public class GooSprite extends MobSprite {
|
|||||||
private Animation pumpAttack;
|
private Animation pumpAttack;
|
||||||
|
|
||||||
private Emitter spray;
|
private Emitter spray;
|
||||||
|
|
||||||
|
private int pumpUpEmitterDist = 0;
|
||||||
|
private int lastPumpUpPos = -1;
|
||||||
private ArrayList<Emitter> pumpUpEmitters = new ArrayList<>();
|
private ArrayList<Emitter> pumpUpEmitters = new ArrayList<>();
|
||||||
|
|
||||||
public GooSprite() {
|
public GooSprite() {
|
||||||
@@ -88,18 +91,25 @@ public class GooSprite extends MobSprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pumpUp( int warnDist ) {
|
public void pumpUp( int warnDist ) {
|
||||||
if (warnDist == 0){
|
pumpUpEmitterDist = warnDist;
|
||||||
clearEmitters();
|
if (warnDist > 0){
|
||||||
} else {
|
|
||||||
play(pump);
|
play(pump);
|
||||||
Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, warnDist == 1 ? 0.8f : 1f );
|
Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, warnDist == 1 ? 0.8f : 1f );
|
||||||
|
}
|
||||||
|
updateEmitters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateEmitters( ){
|
||||||
|
clearEmitters();
|
||||||
|
if (pumpUpEmitterDist > 0 && ch != null) {
|
||||||
|
lastPumpUpPos = ch.pos;
|
||||||
if (ch.fieldOfView == null || ch.fieldOfView.length != Dungeon.level.length()) {
|
if (ch.fieldOfView == null || ch.fieldOfView.length != Dungeon.level.length()) {
|
||||||
ch.fieldOfView = new boolean[Dungeon.level.length()];
|
ch.fieldOfView = new boolean[Dungeon.level.length()];
|
||||||
Dungeon.level.updateFieldOfView(ch, ch.fieldOfView);
|
Dungeon.level.updateFieldOfView(ch, ch.fieldOfView);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < Dungeon.level.length(); i++) {
|
for (int i = 0; i < Dungeon.level.length(); i++) {
|
||||||
if (ch.fieldOfView != null && ch.fieldOfView[i]
|
if (ch.fieldOfView != null && ch.fieldOfView[i]
|
||||||
&& Dungeon.level.distance(i, ch.pos) <= warnDist
|
&& Dungeon.level.distance(i, ch.pos) <= pumpUpEmitterDist
|
||||||
&& new Ballistica(ch.pos, i, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == i
|
&& new Ballistica(ch.pos, i, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == i
|
||||||
&& new Ballistica(i, ch.pos, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == ch.pos) {
|
&& new Ballistica(i, ch.pos, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == ch.pos) {
|
||||||
Emitter e = CellEmitter.get(i);
|
Emitter e = CellEmitter.get(i);
|
||||||
@@ -122,6 +132,7 @@ public class GooSprite extends MobSprite {
|
|||||||
e.burst(ElmoParticle.FACTORY, 10);
|
e.burst(ElmoParticle.FACTORY, 10);
|
||||||
}
|
}
|
||||||
Sample.INSTANCE.play( Assets.Sounds.BURNING );
|
Sample.INSTANCE.play( Assets.Sounds.BURNING );
|
||||||
|
pumpUpEmitterDist = 0;
|
||||||
pumpUpEmitters.clear();
|
pumpUpEmitters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +141,7 @@ public class GooSprite extends MobSprite {
|
|||||||
@Override
|
@Override
|
||||||
public void play(Animation anim) {
|
public void play(Animation anim) {
|
||||||
if (anim != pump && anim != pumpAttack){
|
if (anim != pump && anim != pumpAttack){
|
||||||
|
pumpUpEmitterDist = 0;
|
||||||
clearEmitters();
|
clearEmitters();
|
||||||
}
|
}
|
||||||
super.play(anim);
|
super.play(anim);
|
||||||
@@ -151,6 +163,9 @@ public class GooSprite extends MobSprite {
|
|||||||
spray.pos(center());
|
spray.pos(center());
|
||||||
spray.visible = visible;
|
spray.visible = visible;
|
||||||
}
|
}
|
||||||
|
if (pumpUpEmitterDist > 0 && ch != null && ch.pos != lastPumpUpPos){
|
||||||
|
updateEmitters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GooParticle extends PixelParticle.Shrinking {
|
public static class GooParticle extends PixelParticle.Shrinking {
|
||||||
|
|||||||
Reference in New Issue
Block a user