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:
parent
512c51dee1
commit
40c0d61dfa
BIN
assets/traps.png
Normal file
BIN
assets/traps.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
|
@ -89,6 +89,7 @@ public class Assets {
|
||||||
|
|
||||||
public static final String ITEMS = "items.png";
|
public static final String ITEMS = "items.png";
|
||||||
public static final String PLANTS = "plants.png";
|
public static final String PLANTS = "plants.png";
|
||||||
|
public static final String TRAPS = "traps.png";
|
||||||
|
|
||||||
public static final String TILES_SEWERS = "tiles0.png";
|
public static final String TILES_SEWERS = "tiles0.png";
|
||||||
public static final String TILES_PRISON = "tiles1.png";
|
public static final String TILES_PRISON = "tiles1.png";
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class CursedWand {
|
||||||
|
|
||||||
//shock and recharge
|
//shock and recharge
|
||||||
case 3:
|
case 3:
|
||||||
LightningTrap.trigger(user.pos, user);
|
new LightningTrap().set( user.pos ).activate();
|
||||||
Buff.prolong(user, ScrollOfRecharging.Recharging.class, 20f);
|
Buff.prolong(user, ScrollOfRecharging.Recharging.class, 20f);
|
||||||
ScrollOfRecharging.charge(user);
|
ScrollOfRecharging.charge(user);
|
||||||
SpellSprite.show(user, SpellSprite.CHARGE);
|
SpellSprite.show(user, SpellSprite.CHARGE);
|
||||||
|
@ -322,7 +322,7 @@ public class CursedWand {
|
||||||
|
|
||||||
//summon monsters
|
//summon monsters
|
||||||
case 3:
|
case 3:
|
||||||
SummoningTrap.trigger( user.pos, user );
|
new SummoningTrap().set( user.pos ).activate();
|
||||||
wand.wandUsed();
|
wand.wandUsed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,56 +731,56 @@ public abstract class Level implements Bundlable {
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.TOXIC_TRAP:
|
case Terrain.TOXIC_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) ToxicTrap.trigger( cell, ch );
|
if (!frozen) new ToxicTrap().set(cell).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_FIRE_TRAP:
|
case Terrain.SECRET_FIRE_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.FIRE_TRAP:
|
case Terrain.FIRE_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) FireTrap.trigger( cell, ch );
|
if (!frozen) new FireTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_PARALYTIC_TRAP:
|
case Terrain.SECRET_PARALYTIC_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.PARALYTIC_TRAP:
|
case Terrain.PARALYTIC_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) ParalyticTrap.trigger( cell, ch );
|
if (!frozen) new ParalyticTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_POISON_TRAP:
|
case Terrain.SECRET_POISON_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.POISON_TRAP:
|
case Terrain.POISON_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) PoisonTrap.trigger( cell, ch );
|
if (!frozen) new PoisonTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_ALARM_TRAP:
|
case Terrain.SECRET_ALARM_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.ALARM_TRAP:
|
case Terrain.ALARM_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) AlarmTrap.trigger( cell, ch );
|
if (!frozen) new AlarmTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_LIGHTNING_TRAP:
|
case Terrain.SECRET_LIGHTNING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.LIGHTNING_TRAP:
|
case Terrain.LIGHTNING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) LightningTrap.trigger( cell, ch );
|
if (!frozen) new LightningTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_GRIPPING_TRAP:
|
case Terrain.SECRET_GRIPPING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.GRIPPING_TRAP:
|
case Terrain.GRIPPING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) GrippingTrap.trigger( cell, ch );
|
if (!frozen) new GrippingTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SECRET_SUMMONING_TRAP:
|
case Terrain.SECRET_SUMMONING_TRAP:
|
||||||
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
GLog.i( TXT_HIDDEN_PLATE_CLICKS );
|
||||||
case Terrain.SUMMONING_TRAP:
|
case Terrain.SUMMONING_TRAP:
|
||||||
trap = true;
|
trap = true;
|
||||||
if (!frozen) SummoningTrap.trigger( cell, ch );
|
if (!frozen) new SummoningTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.HIGH_GRASS:
|
case Terrain.HIGH_GRASS:
|
||||||
|
@ -843,35 +843,35 @@ public abstract class Level implements Bundlable {
|
||||||
switch (map[cell]) {
|
switch (map[cell]) {
|
||||||
|
|
||||||
case Terrain.TOXIC_TRAP:
|
case Terrain.TOXIC_TRAP:
|
||||||
ToxicTrap.trigger( cell, mob );
|
new ToxicTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.FIRE_TRAP:
|
case Terrain.FIRE_TRAP:
|
||||||
FireTrap.trigger( cell, mob );
|
new FireTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.PARALYTIC_TRAP:
|
case Terrain.PARALYTIC_TRAP:
|
||||||
ParalyticTrap.trigger( cell, mob );
|
new ParalyticTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.POISON_TRAP:
|
case Terrain.POISON_TRAP:
|
||||||
PoisonTrap.trigger( cell, mob );
|
new PoisonTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.ALARM_TRAP:
|
case Terrain.ALARM_TRAP:
|
||||||
AlarmTrap.trigger( cell, mob );
|
new AlarmTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.LIGHTNING_TRAP:
|
case Terrain.LIGHTNING_TRAP:
|
||||||
LightningTrap.trigger( cell, mob );
|
new LightningTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.GRIPPING_TRAP:
|
case Terrain.GRIPPING_TRAP:
|
||||||
GrippingTrap.trigger( cell, mob );
|
new GrippingTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.SUMMONING_TRAP:
|
case Terrain.SUMMONING_TRAP:
|
||||||
SummoningTrap.trigger( cell, mob );
|
new SummoningTrap().set( cell ).activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Terrain.DOOR:
|
case Terrain.DOOR:
|
||||||
|
|
|
@ -26,23 +26,26 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
|
||||||
public class AlarmTrap {
|
public class AlarmTrap extends Trap {
|
||||||
|
|
||||||
// 0xDD3333
|
// 0xDD3333
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char ch ) {
|
name = "alarm trap";
|
||||||
|
image = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
for (Mob mob : Dungeon.level.mobs) {
|
for (Mob mob : Dungeon.level.mobs) {
|
||||||
if (mob != ch) {
|
|
||||||
mob.beckon( pos );
|
mob.beckon( pos );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Dungeon.visible[pos]) {
|
if (Dungeon.visible[pos]) {
|
||||||
GLog.w( "The trap emits a piercing sound that echoes throughout the dungeon!" );
|
GLog.w( "The trap emits a piercing sound that echoes throughout the dungeon!" );
|
||||||
CellEmitter.center( pos ).start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
|
CellEmitter.center( pos ).start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample.INSTANCE.play( Assets.SND_ALERT );
|
Sample.INSTANCE.play( Assets.SND_ALERT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,19 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
|
||||||
public class FireTrap {
|
public class FireTrap extends Trap {
|
||||||
|
|
||||||
// 0xFF7708
|
// 0xFF7708
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char ch ) {
|
name = "fire trap";
|
||||||
|
image = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
GameScene.add( Blob.seed( pos, 2, Fire.class ) );
|
GameScene.add( Blob.seed( pos, 2, Fire.class ) );
|
||||||
CellEmitter.get( pos ).burst( FlameParticle.FACTORY, 5 );
|
CellEmitter.get( pos ).burst( FlameParticle.FACTORY, 5 );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
|
@ -25,10 +26,18 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Wound;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Wound;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class GrippingTrap {
|
public class GrippingTrap extends Trap {
|
||||||
|
|
||||||
public static void trigger( int pos, Char c ) {
|
{
|
||||||
|
name = "gripping trap";
|
||||||
|
image = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
|
Char c = Actor.findChar( pos );
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
int damage = Math.max( 0, (Dungeon.depth + 3) - Random.IntRange( 0, c.dr() / 2 ) );
|
int damage = Math.max( 0, (Dungeon.depth + 3) - Random.IntRange( 0, c.dr() / 2 ) );
|
||||||
Buff.affect( c, Bleeding.class ).set( damage );
|
Buff.affect( c, Bleeding.class ).set( damage );
|
||||||
|
@ -37,6 +46,6 @@ public class GrippingTrap {
|
||||||
} else {
|
} else {
|
||||||
Wound.hit( pos );
|
Wound.hit( pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
|
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
|
||||||
|
@ -31,20 +32,24 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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) {
|
if (ch != null) {
|
||||||
ch.damage( Math.max( 1, Random.Int( ch.HP / 3, 2 * ch.HP / 3 ) ), LIGHTNING );
|
ch.damage( Math.max( 1, Random.Int( ch.HP / 3, 2 * ch.HP / 3 ) ), LIGHTNING );
|
||||||
if (ch == Dungeon.hero) {
|
if (ch == Dungeon.hero) {
|
||||||
|
|
||||||
Camera.main.shake( 2, 0.3f );
|
Camera.main.shake( 2, 0.3f );
|
||||||
|
|
||||||
if (!ch.isAlive()) {
|
if (!ch.isAlive()) {
|
||||||
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
|
Dungeon.fail( Utils.format( ResultDescriptions.TRAP, name ) );
|
||||||
GLog.n( "You were killed by a discharge of a lightning trap..." );
|
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 ) );
|
ch.sprite.parent.add( new Lightning( arcs, null ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CellEmitter.center( pos ).burst( SparkParticle.FACTORY, Random.IntRange( 3, 4 ) );
|
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 final Electricity LIGHTNING = new Electricity();
|
||||||
public static class Electricity {
|
public static class Electricity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,18 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
|
||||||
public class ParalyticTrap {
|
public class ParalyticTrap extends Trap{
|
||||||
|
|
||||||
// 0xCCCC55
|
// 0xCCCC55
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char ch ) {
|
name = "paralytic gas trap";
|
||||||
|
image = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
GameScene.add( Blob.seed( pos, 80 + 5 * Dungeon.depth, ParalyticGas.class ) );
|
GameScene.add( Blob.seed( pos, 80 + 5 * Dungeon.depth, ParalyticGas.class ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,23 +18,31 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle;
|
||||||
|
|
||||||
public class PoisonTrap {
|
public class PoisonTrap extends Trap{
|
||||||
|
|
||||||
// 0xBB66EE
|
// 0xBB66EE
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char ch ) {
|
name = "poison trap";
|
||||||
|
image = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
|
Char ch = Actor.findChar( pos );
|
||||||
|
|
||||||
if (ch != null) {
|
if (ch != null) {
|
||||||
Buff.affect( ch, Poison.class ).set( Poison.durationFactor( ch ) * (4 + Dungeon.depth / 2) );
|
Buff.affect( ch, Poison.class ).set( Poison.durationFactor( ch ) * (4 + Dungeon.depth / 2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CellEmitter.center( pos ).burst( PoisonParticle.SPLASH, 3 );
|
CellEmitter.center( pos ).burst( PoisonParticle.SPLASH, 3 );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,24 +29,31 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class SummoningTrap {
|
public class SummoningTrap extends Trap {
|
||||||
|
|
||||||
private static final float DELAY = 2f;
|
private static final float DELAY = 2f;
|
||||||
|
|
||||||
private static final Mob DUMMY = new Mob() {};
|
private static final Mob DUMMY = new Mob() {};
|
||||||
|
|
||||||
// 0x770088
|
// 0x770088
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char c ) {
|
name = "summoning trap";
|
||||||
|
image = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
if (Dungeon.bossLevel()) {
|
if (Dungeon.bossLevel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Char c = Actor.findChar( pos );
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
Actor.occupyCell( c );
|
Actor.occupyCell( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
int nMobs = 1;
|
int nMobs = 1;
|
||||||
if (Random.Int( 2 ) == 0) {
|
if (Random.Int( 2 ) == 0) {
|
||||||
nMobs++;
|
nMobs++;
|
||||||
|
@ -54,35 +61,36 @@ public class SummoningTrap {
|
||||||
nMobs++;
|
nMobs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's complicated here, because these traps can be activated in chain
|
// It's complicated here, because these traps can be activated in chain
|
||||||
|
|
||||||
ArrayList<Integer> candidates = new ArrayList<Integer>();
|
ArrayList<Integer> candidates = new ArrayList<>();
|
||||||
|
|
||||||
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
|
for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
|
||||||
int p = pos + Level.NEIGHBOURS8[i];
|
int p = pos + Level.NEIGHBOURS8[i];
|
||||||
if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
|
if (Actor.findChar( p ) == null && (Level.passable[p] || Level.avoid[p])) {
|
||||||
candidates.add( p );
|
candidates.add( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Integer> respawnPoints = new ArrayList<Integer>();
|
ArrayList<Integer> respawnPoints = new ArrayList<>();
|
||||||
|
|
||||||
while (nMobs > 0 && candidates.size() > 0) {
|
while (nMobs > 0 && candidates.size() > 0) {
|
||||||
int index = Random.index( candidates );
|
int index = Random.index( candidates );
|
||||||
|
|
||||||
DUMMY.pos = candidates.get( index );
|
DUMMY.pos = candidates.get( index );
|
||||||
Actor.occupyCell( DUMMY );
|
Actor.occupyCell( DUMMY );
|
||||||
|
|
||||||
respawnPoints.add( candidates.remove( index ) );
|
respawnPoints.add( candidates.remove( index ) );
|
||||||
nMobs--;
|
nMobs--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Integer point : respawnPoints) {
|
for (Integer point : respawnPoints) {
|
||||||
Mob mob = Bestiary.mob( Dungeon.depth );
|
Mob mob = Bestiary.mob( Dungeon.depth );
|
||||||
mob.state = mob.WANDERING;
|
mob.state = mob.WANDERING;
|
||||||
GameScene.add( mob, DELAY );
|
GameScene.add( mob, DELAY );
|
||||||
ScrollOfTeleportation.appear( mob, point );
|
ScrollOfTeleportation.appear( mob, point );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,18 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
|
||||||
public class ToxicTrap {
|
public class ToxicTrap extends Trap{
|
||||||
|
|
||||||
// 0x40CC55
|
// 0x40CC55
|
||||||
|
{
|
||||||
public static void trigger( int pos, Char ch ) {
|
name = "toxic gas trap";
|
||||||
|
image = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activate() {
|
||||||
|
|
||||||
GameScene.add( Blob.seed( pos, 300 + 20 * Dungeon.depth, ToxicGas.class ) );
|
GameScene.add( Blob.seed( pos, 300 + 20 * Dungeon.depth, ToxicGas.class ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.levels.traps;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.utils.Bundlable;
|
||||||
|
import com.watabou.utils.Bundle;
|
||||||
|
|
||||||
|
public abstract class Trap implements Bundlable {
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public int image;
|
||||||
|
public int pos;
|
||||||
|
|
||||||
|
public TrapSprite sprite;
|
||||||
|
public boolean visible;
|
||||||
|
|
||||||
|
private static final String POS = "pos";
|
||||||
|
|
||||||
|
public Trap set(int pos){
|
||||||
|
this.pos = pos;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reveal() {
|
||||||
|
visible = true;
|
||||||
|
if (sprite != null)
|
||||||
|
sprite.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hide() {
|
||||||
|
visible = false;
|
||||||
|
if (sprite != null)
|
||||||
|
sprite.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trigger() {
|
||||||
|
if (Dungeon.visible[pos]){
|
||||||
|
Sample.INSTANCE.play(Assets.SND_TRAP);
|
||||||
|
}
|
||||||
|
activate();
|
||||||
|
disarm();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void activate();
|
||||||
|
|
||||||
|
protected void disarm(){
|
||||||
|
//Dungeon.level.traps.delete( pos );
|
||||||
|
Level.set(pos, Terrain.INACTIVE_TRAP);
|
||||||
|
sprite.kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
|
pos = bundle.getInt( POS );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle( Bundle bundle ) {
|
||||||
|
bundle.put( POS, pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String desc() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.sprites;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||||
|
import com.watabou.noosa.Image;
|
||||||
|
import com.watabou.noosa.TextureFilm;
|
||||||
|
|
||||||
|
public class TrapSprite extends Image {
|
||||||
|
|
||||||
|
private static TextureFilm frames;
|
||||||
|
|
||||||
|
private int pos = -1;
|
||||||
|
|
||||||
|
public TrapSprite() {
|
||||||
|
super( Assets.TRAPS );
|
||||||
|
|
||||||
|
if (frames == null) {
|
||||||
|
frames = new TextureFilm( texture, 16, 16 );
|
||||||
|
}
|
||||||
|
|
||||||
|
origin.set( 8, 12 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrapSprite( int image ) {
|
||||||
|
this();
|
||||||
|
reset( image );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset( Trap trap ) {
|
||||||
|
|
||||||
|
revive();
|
||||||
|
|
||||||
|
reset( trap.image + (((Dungeon.depth-1) / 5) * 8) );
|
||||||
|
alpha( 1f );
|
||||||
|
|
||||||
|
pos = trap.pos;
|
||||||
|
x = (pos % Level.WIDTH) * DungeonTilemap.SIZE;
|
||||||
|
y = (pos / Level.WIDTH) * DungeonTilemap.SIZE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset( int image ) {
|
||||||
|
frame( frames.get( image ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
|
||||||
|
|
||||||
|
public class WndInfoTrap extends WndTitledMessage {
|
||||||
|
|
||||||
|
public WndInfoTrap(Trap trap) {
|
||||||
|
|
||||||
|
super(new TrapSprite( trap.image ), trap.name, trap.desc());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user