v0.3.0c: trap refactor pt1, moved all traps to be instance based (not properly tied into level logic yet)

This commit is contained in:
Evan Debenham
2015-06-02 00:35:46 -04:00
parent 512c51dee1
commit 40c0d61dfa
15 changed files with 263 additions and 81 deletions
@@ -17,6 +17,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.watabou.noosa.Camera;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
@@ -31,20 +32,24 @@ import com.watabou.utils.Random;
import java.util.ArrayList;
public class LightningTrap {
public class LightningTrap extends Trap {
{
name = "lightning trap";
image = 5;
}
@Override
public void activate() {
Char ch = Actor.findChar( pos );
private static final String name = "lightning trap";
// 00x66CCEE
public static void trigger( int pos, Char ch ) {
if (ch != null) {
ch.damage( Math.max( 1, Random.Int( ch.HP / 3, 2 * ch.HP / 3 ) ), LIGHTNING );
if (ch == Dungeon.hero) {
Camera.main.shake( 2, 0.3f );
if (!ch.isAlive()) {
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
GLog.n( "You were killed by a discharge of a lightning trap..." );
@@ -57,12 +62,12 @@ public class LightningTrap {
ch.sprite.parent.add( new Lightning( arcs, null ) );
}
CellEmitter.center( pos ).burst( SparkParticle.FACTORY, Random.IntRange( 3, 4 ) );
}
//FIXME: this is bad, handle when you rework resistances, make into a category
public static final Electricity LIGHTNING = new Electricity();
public static class Electricity {
public static class Electricity {
}
}