From eb65e2b3568f207113436c0312adf043a038af06 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 27 Aug 2020 01:09:41 -0400 Subject: [PATCH] v0.8.2c: refactored goo's particle effects --- .../actors/mobs/Goo.java | 48 ++++++------------- .../sprites/GooSprite.java | 43 ++++++++++++++++- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Goo.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Goo.java index 066d4d41f..8d0172650 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Goo.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Goo.java @@ -26,14 +26,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; -import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.GooWarn; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze; -import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; -import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey; import com.shatteredpixel.shatteredpixeldungeon.items.quest.GooBlob; @@ -42,7 +38,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.GooSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BossHealthBar; -import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Camera; import com.watabou.noosa.audio.Sample; @@ -71,11 +66,6 @@ public class Goo extends Mob { int max = (HP*2 <= HT) ? 12 : 8; if (pumpedUp > 0) { pumpedUp = 0; - PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 ); - for (int i = 0; i < PathFinder.distance.length; i++) { - if (PathFinder.distance[i] < Integer.MAX_VALUE) - CellEmitter.get(i).burst(ElmoParticle.FACTORY, 10); - } Sample.INSTANCE.play( Assets.Sounds.BURNING ); return Random.NormalIntRange( min*3, max*3 ); } else { @@ -103,11 +93,6 @@ public class Goo extends Mob { @Override public boolean act() { - - //ensures goo warning blob acts at the correct times - //as normally blobs act one extra time when initialized if they normally act before - //whatever spawned them - GameScene.add(Blob.seed(pos, 0, GooWarn.class)); if (Dungeon.level.water[pos] && HP < HT) { sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); @@ -121,9 +106,6 @@ public class Goo extends Mob { if (state != SLEEPING){ Dungeon.level.seal(); } - - //prevents goo pump animation from persisting when it shouldn't - sprite.idle(); return super.act(); } @@ -148,15 +130,19 @@ public class Goo extends Mob { return damage; } + @Override + public void updateSpriteState() { + super.updateSpriteState(); + + if (pumpedUp > 0){ + ((GooSprite)sprite).pumpUp( pumpedUp ); + } + } + @Override protected boolean doAttack( Char enemy ) { if (pumpedUp == 1) { - ((GooSprite)sprite).pumpUp(); - PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 2 ); - for (int i = 0; i < PathFinder.distance.length; i++) { - if (PathFinder.distance[i] < Integer.MAX_VALUE) - GameScene.add(Blob.seed(i, 1, GooWarn.class)); - } + ((GooSprite)sprite).pumpUp( 2 ); pumpedUp++; Sample.INSTANCE.play( Assets.Sounds.CHARGEUP ); @@ -170,9 +156,9 @@ public class Goo extends Mob { if (visible) { if (pumpedUp >= 2) { ((GooSprite) sprite).pumpAttack(); + } else { + sprite.attack(enemy.pos); } - else - sprite.attack( enemy.pos ); } else { attack( enemy ); } @@ -185,14 +171,7 @@ public class Goo extends Mob { pumpedUp++; - ((GooSprite)sprite).pumpUp(); - - for (int i=0; i < PathFinder.NEIGHBOURS9.length; i++) { - int j = pos + PathFinder.NEIGHBOURS9[i]; - if (!Dungeon.level.solid[j]) { - GameScene.add(Blob.seed(j, 1, GooWarn.class)); - } - } + ((GooSprite)sprite).pumpUp( 1 ); if (Dungeon.level.heroFOV[pos]) { sprite.showStatus( CharSprite.NEGATIVE, Messages.get(this, "!!!") ); @@ -216,6 +195,7 @@ public class Goo extends Mob { @Override protected boolean getCloser( int target ) { pumpedUp = 0; + sprite.idle(); return super.getCloser( target ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GooSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GooSprite.java index fd2f0e619..0aa6e6950 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GooSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GooSprite.java @@ -22,20 +22,28 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; +import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.watabou.noosa.TextureFilm; import com.watabou.noosa.particles.Emitter; import com.watabou.noosa.particles.Emitter.Factory; import com.watabou.noosa.particles.PixelParticle; +import com.watabou.utils.PathFinder; import com.watabou.utils.PointF; import com.watabou.utils.Random; +import java.util.ArrayList; + public class GooSprite extends MobSprite { private Animation pump; private Animation pumpAttack; private Emitter spray; + private ArrayList pumpUpEmitters = new ArrayList<>(); public GooSprite() { super(); @@ -77,12 +85,38 @@ public class GooSprite extends MobSprite { spray(true); } - public void pumpUp() { - play( pump ); + public void pumpUp( int warnDist ) { + if (warnDist == 0){ + for (Emitter e : pumpUpEmitters){ + e.on = false; + } + pumpUpEmitters.clear(); + } else { + play(pump); + PathFinder.buildDistanceMap(ch.pos, BArray.not(Dungeon.level.solid, null), 2); + for (int i = 0; i < PathFinder.distance.length; i++) { + if (PathFinder.distance[i] <= warnDist) { + Emitter e = CellEmitter.get(i); + e.pour(GooParticle.FACTORY, 0.04f); + pumpUpEmitters.add(e); + } + } + } } public void pumpAttack() { play(pumpAttack); } + @Override + public void play(Animation anim) { + if (anim != pump && anim != pumpAttack){ + for (Emitter e : pumpUpEmitters){ + e.on = false; + } + pumpUpEmitters.clear(); + } + super.play(anim); + } + @Override public int blood() { return 0xFF000000; @@ -143,6 +177,11 @@ public class GooSprite extends MobSprite { if (anim == pumpAttack) { + for (Emitter e : pumpUpEmitters){ + e.burst(ElmoParticle.FACTORY, 10); + } + pumpUpEmitters.clear(); + idle(); ch.onAttackComplete(); } else if (anim == die) {