v0.3.0: refactored beam effects, added Light Ray effect.

This commit is contained in:
Evan Debenham 2015-04-10 12:04:44 -04:00
parent 7cce41e650
commit 6bda20b7b7
5 changed files with 40 additions and 24 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -27,16 +27,16 @@ import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.PointF; import com.watabou.utils.PointF;
public class DeathRay extends Image { public class Beam extends Image {
private static final double A = 180 / Math.PI; private static final double A = 180 / Math.PI;
private static final float DURATION = 0.5f; private float duration;
private float timeLeft; private float timeLeft;
public DeathRay( PointF s, PointF e ) { private Beam(PointF s, PointF e, Effects.Type asset, float duration) {
super( Effects.get( Effects.Type.RAY ) ); super( Effects.get( asset ) );
origin.set( 0, height / 2 ); origin.set( 0, height / 2 );
@ -50,14 +50,26 @@ public class DeathRay extends Image {
Sample.INSTANCE.play( Assets.SND_RAY ); Sample.INSTANCE.play( Assets.SND_RAY );
timeLeft = DURATION; timeLeft = this.duration = duration;
}
public static class DeathRay extends Beam{
public DeathRay(PointF s, PointF e){
super(s, e, Effects.Type.DEATH_RAY, 0.5f);
}
}
public static class LightRay extends Beam{
public LightRay(PointF s, PointF e){
super(s, e, Effects.Type.LIGHT_RAY, 1f);
}
} }
@Override @Override
public void update() { public void update() {
super.update(); super.update();
float p = timeLeft / DURATION; float p = timeLeft / duration;
alpha( p ); alpha( p );
scale.set( scale.x, p ); scale.set( scale.x, p );

View File

@ -26,24 +26,28 @@ public class Effects {
RIPPLE, RIPPLE,
LIGHTNING, LIGHTNING,
WOUND, WOUND,
RAY DEATH_RAY,
LIGHT_RAY
}; };
public static Image get( Type type ) { public static Image get( Type type ) {
Image icon = new Image( Assets.EFFECTS ); Image icon = new Image( Assets.EFFECTS );
switch (type) { switch (type) {
case RIPPLE: case RIPPLE:
icon.frame( icon.texture.uvRect( 0, 0, 16, 16 ) ); icon.frame(icon.texture.uvRect(0, 0, 16, 16));
break; break;
case LIGHTNING: case LIGHTNING:
icon.frame( icon.texture.uvRect( 16, 0, 32, 8 ) ); icon.frame(icon.texture.uvRect(16, 0, 32, 8));
break; break;
case WOUND: case WOUND:
icon.frame( icon.texture.uvRect( 16, 8, 32, 16 ) ); icon.frame(icon.texture.uvRect(16, 8, 32, 16));
break; break;
case RAY: case DEATH_RAY:
icon.frame( icon.texture.uvRect( 16, 16, 32, 24 ) ); icon.frame(icon.texture.uvRect(16, 16, 32, 24));
break; break;
case LIGHT_RAY:
icon.frame(icon.texture.uvRect(16, 23, 32, 31));
break;
} }
return icon; return icon;
} }

View File

@ -24,7 +24,7 @@ import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.DeathRay; import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Death; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Death;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
@ -113,7 +113,7 @@ public class WandOfDisintegration extends Wand {
protected void fx( Ballistica beam, Callback callback ) { protected void fx( Ballistica beam, Callback callback ) {
int cell = beam.path.get(Math.min(beam.dist, distance())); int cell = beam.path.get(Math.min(beam.dist, distance()));
curUser.sprite.parent.add( new DeathRay( curUser.sprite.center(), DungeonTilemap.tileCenterToWorld( cell ) ) ); curUser.sprite.parent.add(new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld( cell )));
callback.call(); callback.call();
} }

View File

@ -21,7 +21,7 @@ import com.watabou.noosa.TextureFilm;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap; import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.effects.DeathRay; import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
public class EyeSprite extends MobSprite { public class EyeSprite extends MobSprite {
@ -61,7 +61,7 @@ public class EyeSprite extends MobSprite {
if (anim == attack) { if (anim == attack) {
if (Dungeon.visible[ch.pos] || Dungeon.visible[attackPos]) { if (Dungeon.visible[ch.pos] || Dungeon.visible[attackPos]) {
parent.add( new DeathRay( center(), DungeonTilemap.tileCenterToWorld( attackPos ) ) ); parent.add( new Beam.DeathRay( center(), DungeonTilemap.tileCenterToWorld( attackPos ) ) );
} }
} }
} }