From c5e9ffa9fe68510619920a289302950f9590b7a2 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 5 Jun 2015 11:03:44 -0400 Subject: [PATCH] v0.3.0c: refactored staff visual effects to be contained in wands. --- .../items/wands/Wand.java | 9 ++ .../items/wands/WandOfBlastWave.java | 10 +++ .../items/wands/WandOfCorruption.java | 10 +++ .../items/wands/WandOfDisintegration.java | 14 ++- .../items/wands/WandOfFireblast.java | 10 +++ .../items/wands/WandOfFrost.java | 10 +++ .../items/wands/WandOfLightning.java | 14 ++- .../items/wands/WandOfPrismaticLight.java | 11 +++ .../items/wands/WandOfRegrowth.java | 12 ++- .../items/wands/WandOfTransfusion.java | 11 +++ .../items/wands/WandOfVenom.java | 9 ++ .../items/weapon/melee/MagesStaff.java | 90 ++++--------------- 12 files changed, 133 insertions(+), 77 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index bd3d24e7c..78f358b05 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -40,6 +40,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; import com.watabou.utils.Callback; +import com.watabou.utils.PointF; import com.watabou.utils.Random; public abstract class Wand extends Item { @@ -233,6 +234,14 @@ public abstract class Wand extends Item { Sample.INSTANCE.play( Assets.SND_ZAP ); } + public void staffFx( MagesStaff.StaffParticle particle ){ + particle.color(0xFFFFFF); particle.am = 0.3f; + particle.setLifespan( 1f); + particle.speed.polar( Random.Float(PointF.PI2), 2f ); + particle.setSize( 1f, 2.5f ); + particle.radiateXY(1f); + } + protected void wandUsed() { usagesToKnow -= cursed ? 1 : chargesPerCast(); curCharges -= cursed ? 1 : chargesPerCast(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java index 9c31b159e..99ee16745 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfBlastWave.java @@ -24,6 +24,7 @@ import com.watabou.noosa.Group; import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Callback; +import com.watabou.utils.PointF; import com.watabou.utils.Random; /** @@ -135,6 +136,15 @@ public class WandOfBlastWave extends Wand { Sample.INSTANCE.play(Assets.SND_ZAP); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0x664422 ); particle.am = 0.6f; + particle.setLifespan(2f); + particle.speed.polar(Random.Float(PointF.PI2), 0.3f); + particle.setSize( 1f, 2f); + particle.radiateXY(3f); + } + public static class BlastWave extends Image { private static final float TIME_TO_FADE = 0.2f; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java index 0572ee289..eed3c43ec 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java @@ -91,6 +91,16 @@ public class WandOfCorruption extends Wand { Sample.INSTANCE.play( Assets.SND_ZAP ); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0 ); + particle.am = 0.6f; + particle.setLifespan(0.6f); + particle.acc.set(0, 40); + particle.setSize( 0f, 3f); + particle.shuffleXY(2f); + } + @Override public String desc() { return "This wand radiates dark energy, if that weren't already obvious from the small decorative skull shaped onto its tip.\n" + diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfDisintegration.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfDisintegration.java index c7794588c..53158f848 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfDisintegration.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfDisintegration.java @@ -65,7 +65,7 @@ public class WandOfDisintegration extends Wand { //we don't want to count passed terrain after the last enemy hit. That would be a lot of bonus levels. //terrainPassed starts at 2, equivalent of rounding up when /3 for integer arithmetic. terrainBonus += terrainPassed/3; - terrainPassed = 1; + terrainPassed = terrainPassed%3; chars.add( ch ); } @@ -116,7 +116,17 @@ public class WandOfDisintegration extends Wand { curUser.sprite.parent.add(new Beam.DeathRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld( cell ))); callback.call(); } - + + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color(0x220022); + particle.am = 0.6f; + particle.setLifespan(0.6f); + particle.acc.set(40, -40); + particle.setSize(0f, 3f); + particle.shuffleXY(2f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java index a39097e29..7927712db 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java @@ -158,6 +158,16 @@ public class WandOfFireblast extends Wand { return Math.max(1, (int)Math.ceil(curCharges*0.4f)); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0xEE7722 ); + particle.am = 0.5f; + particle.setLifespan(0.6f); + particle.acc.set(0, -40); + particle.setSize( 0f, 3f); + particle.shuffleXY(2f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFrost.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFrost.java index d7aa2ae46..13f4e2b2b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFrost.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFrost.java @@ -78,6 +78,16 @@ public class WandOfFrost extends Wand { new Slow().proc(staff, attacker, defender, damage); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0xFFFFFF ); + particle.am = 0.5f; + particle.setLifespan(1.2f); + particle.speed.set(0, Random.Float(5, 8)); + particle.setSize( 0f, 1f); + particle.shuffleXY(2f); + } + @Override public String desc() { return "This wand seems to be made out of some kind of magical ice. It grows brighter towards its " + diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfLightning.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfLightning.java index e9a4ea0d2..4fb23d4c7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfLightning.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfLightning.java @@ -129,7 +129,19 @@ public class WandOfLightning extends Wand { curUser.sprite.parent.add( new Lightning( arcs, null ) ); callback.call(); } - + + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color(0xFFFFFF); + particle.am = 0.6f; + particle.setLifespan(0.6f); + particle.acc.set(0, +10); + particle.speed.polar(-Random.Float(3.1415926f), 6f); + particle.setSize(0f, 1.5f); + particle.sizeJitter = 1f; + particle.shuffleXY(2f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfPrismaticLight.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfPrismaticLight.java index ac3aa9c1c..01ca431cd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfPrismaticLight.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfPrismaticLight.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Callback; +import com.watabou.utils.PointF; import com.watabou.utils.Random; import java.util.Arrays; @@ -139,6 +140,16 @@ public class WandOfPrismaticLight extends Wand { new Paralysis().proc(staff, attacker, defender, damage); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( Random.Int( 0x1000000 ) ); + particle.am = 0.3f; + particle.setLifespan(1f); + particle.speed.polar(Random.Float(PointF.PI2), 2f); + particle.setSize( 1f, 2.5f); + particle.radiateXY(1f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java index 2f5d2cfbb..8f691d18b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java @@ -37,8 +37,8 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; -import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Callback; +import com.watabou.utils.ColorMath; import com.watabou.utils.Random; import java.util.ArrayList; @@ -222,6 +222,16 @@ public class WandOfRegrowth extends Wand { return Math.max(1, curCharges); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( ColorMath.random(0x004400, 0x88CC44) ); + particle.am = 1f; + particle.setLifespan(0.6f); + particle.acc.set(0, 40); + particle.setSize( 1f, 2f); + particle.shuffleXY(2f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTransfusion.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTransfusion.java index 89db0a117..c77898c35 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTransfusion.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTransfusion.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Callback; +import com.watabou.utils.PointF; import com.watabou.utils.Random; import java.util.Arrays; @@ -207,6 +208,16 @@ public class WandOfTransfusion extends Wand { callback.call(); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0xCC0000 ); + particle.am = 0.6f; + particle.setLifespan(0.8f); + particle.speed.polar( Random.Float(PointF.PI2), 2f ); + particle.setSize( 1f, 2.5f); + particle.radiateXY(1f); + } + @Override public String desc() { return "A fairly plainly shaped wand, it stands out due to its magenta hue and pitch black gem at the tip.\n" + diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfVenom.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfVenom.java index eb0fb8dc6..913161fae 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfVenom.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfVenom.java @@ -42,6 +42,15 @@ public class WandOfVenom extends Wand { new Poison().proc(staff, attacker, defender, damage); } + @Override + public void staffFx(MagesStaff.StaffParticle particle) { + particle.color( 0x8844FF ); particle.am = 0.6f; + particle.setLifespan(0.6f); + particle.acc.set(0, 40); + particle.setSize( 0f, 3f); + particle.shuffleXY(2f); + } + @Override public String desc() { return diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index ac5297747..56030635b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -337,11 +337,11 @@ public class MagesStaff extends MeleeWeapon { }; //determines particle effects to use based on wand the staff owns. - private class StaffParticle extends PixelParticle{ + public class StaffParticle extends PixelParticle{ private float minSize; private float maxSize; - private float sizeRandomness = 0; + public float sizeJitter = 0; public StaffParticle(){ super(); @@ -355,82 +355,26 @@ public class MagesStaff extends MeleeWeapon { this.x = x; this.y = y; - if (wand instanceof WandOfMagicMissile){ - color(0xFFFFFF); am = 0.3f; - lifespan = left = 1f; - speed.polar( Random.Float(PointF.PI2), 2f ); - minSize = 1f; maxSize = 2.5f; - radiateXY(1f); - } else if (wand instanceof WandOfLightning){ - color(0xFFFFFF); am = 0.6f; - lifespan = left = 0.6f; - acc.set( 0, +10 ); speed.polar(-Random.Float(3.1415926f), 6f); - minSize = 0f; maxSize = 1.5f; - sizeRandomness = 1f; - shuffleXY(2f); - } else if (wand instanceof WandOfDisintegration){ - color(0x220022); am = 0.6f; - lifespan = left = 0.6f; - acc.set(40, -40); - minSize = 0f; maxSize = 3f; - shuffleXY(2f); - } else if (wand instanceof WandOfFireblast) { - color( 0xEE7722 ); am = 0.5f; - lifespan = left = 0.6f; - acc.set(0, -40); - minSize = 0f; maxSize = 3f; - shuffleXY(2f); - } else if (wand instanceof WandOfVenom) { - color( 0x8844FF ); am = 0.6f; - lifespan = left = 0.6f; - acc.set(0, 40); - minSize = 0f; maxSize = 3f; - shuffleXY(2f); - } else if (wand instanceof WandOfBlastWave) { - color( 0x664422 ); am = 0.6f; - lifespan = left = 2f; - speed.polar(Random.Float(PointF.PI2), 0.3f); - minSize = 1f; maxSize = 2f; - radiateXY(3f); - } else if (wand instanceof WandOfFrost) { - color( 0xFFFFFF ); am = 0.5f; - lifespan = left = 1.2f; - speed.set( 0, Random.Float( 5, 8 ) ); - minSize = 0f; maxSize = 1f; - shuffleXY(2f); - } else if (wand instanceof WandOfPrismaticLight) { - color( Random.Int( 0x1000000 ) ); am = 0.3f; - lifespan = left = 1f; - speed.polar(Random.Float(PointF.PI2), 2f); - minSize = 1f; maxSize = 2.5f; - radiateXY(1f); - } else if (wand instanceof WandOfTransfusion) { - color( 0xCC0000 ); am = 0.6f; - lifespan = left = 0.8f; - speed.polar( Random.Float(PointF.PI2), 2f ); - minSize = 1f; maxSize = 2.5f; - radiateXY(1f); - } else if (wand instanceof WandOfCorruption) { - color( 0 ); am = 0.6f; - lifespan = left = 0.6f; - acc.set(0, 40); - minSize = 0f; maxSize = 3f; - shuffleXY(2f); - } else if (wand instanceof WandOfRegrowth) { - color( ColorMath.random(0x004400, 0x88CC44) ); am = 1f; - lifespan = left = 0.6f; - acc.set(0, 40); - minSize = 1f; maxSize = 2f; - shuffleXY(2f); - } + if (wand != null) + wand.staffFx( this ); + } - private void shuffleXY(float amt){ + public void setSize( float minSize, float maxSize ){ + this.minSize = minSize; + this.maxSize = maxSize; + } + + public void setLifespan( float life ){ + lifespan = left = life; + } + + public void shuffleXY(float amt){ x += Random.Float(-amt, amt); y += Random.Float(-amt, amt); } - private void radiateXY(float amt){ + public void radiateXY(float amt){ float hypot = (float)Math.hypot(speed.x, speed.y); this.x += speed.x/hypot*amt; this.y += speed.y/hypot*amt; @@ -439,7 +383,7 @@ public class MagesStaff extends MeleeWeapon { @Override public void update() { super.update(); - size(minSize + (left / lifespan)*(maxSize-minSize) + Random.Float(sizeRandomness)); + size(minSize + (left / lifespan)*(maxSize-minSize) + Random.Float(sizeJitter)); } } }