diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java index 386f26880..5b5be3403 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java @@ -20,6 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.levels; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*; import com.watabou.noosa.Scene; import com.watabou.noosa.particles.Emitter; import com.shatteredpixel.shatteredpixeldungeon.Assets; @@ -56,7 +57,21 @@ public class PrisonLevel extends RegularLevel { protected boolean[] grass() { return Patch.generate( feeling == Feeling.GRASS ? 0.60f : 0.40f, 3 ); } - + + @Override + protected Class[] trapClasses() { + return new Class[]{ ChillingTrap.class, FireTrap.class, PoisonTrap.class, SpearTrap.class, ToxicTrap.class, + AlarmTrap.class, FlashingTrap.class, GrippingTrap.class, ParalyticTrap.class, LightningTrap.class, OozeTrap.class, + ConfusionTrap.class, FlockTrap.class, SummoningTrap.class, TeleportationTrap.class, }; + } + + @Override + protected float[] trapChances() { + return new float[]{ 4, 4, 4, 4, + 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1 }; + } + @Override protected boolean assignRoomType() { super.assignRoomType(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 48d176038..de3879bf7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -35,13 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.ShopPainter; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrippingTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ParalyticTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonTrap; -import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*; import com.watabou.utils.Bundle; import com.watabou.utils.Graph; import com.watabou.utils.Random; @@ -337,50 +331,35 @@ public abstract class RegularLevel extends Level { int nTraps = nTraps(); float[] trapChances = trapChances(); + Class[] trapClasses = trapClasses(); for (int i=0; i < nTraps; i++) { int trapPos = Random.Int( LENGTH ); if (map[trapPos] == Terrain.EMPTY) { - map[trapPos] = Terrain.SECRET_TRAP; - switch (Random.chances( trapChances )) { - case 0: - setTrap( new ToxicTrap().hide(), trapPos); - break; - case 1: - setTrap( new FireTrap().hide(), trapPos); - break; - case 2: - setTrap( new ParalyticTrap().hide(), trapPos); - break; - case 3: - setTrap( new PoisonTrap().hide(), trapPos); - break; - case 4: - setTrap( new AlarmTrap().hide(), trapPos); - break; - case 5: - setTrap( new LightningTrap().hide(), trapPos); - break; - case 6: - setTrap( new GrippingTrap().hide(), trapPos); - break; - case 7: - setTrap( new LightningTrap().hide(), trapPos); - break; + try { + Trap trap = ((Trap)trapClasses[Random.chances( trapChances )].newInstance()).hide(); + setTrap( trap, trapPos ); + //some traps will not be hidden + map[trapPos] = trap.visible ? Terrain.TRAP : Terrain.SECRET_TRAP; + } catch (Exception e) { + throw new RuntimeException(e); } } } } protected int nTraps() { - return Dungeon.depth <= 1 ? 0 : Random.Int( 1, rooms.size() + Dungeon.depth ); + return Random.NormalIntRange( 1, rooms.size() + Dungeon.depth ); } + protected Class[] trapClasses(){ + return new Class[]{WornTrap.class}; + } + protected float[] trapChances() { - float[] chances = { 1, 1, 1, 1, 1, 1, 1, 1 }; - return chances; + return new float[]{1}; } protected int minRoomSize = 7; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java index c59692e3e..c5ca77789 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java @@ -20,6 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.levels; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*; import com.watabou.noosa.Game; import com.watabou.noosa.Scene; import com.watabou.noosa.particles.Emitter; @@ -58,7 +59,25 @@ public class SewerLevel extends RegularLevel { protected boolean[] grass() { return Patch.generate( feeling == Feeling.GRASS ? 0.60f : 0.40f, 4 ); } - + + @Override + protected Class[] trapClasses() { + return Dungeon.depth == 1 ? + new Class[]{WornTrap.class} : + new Class[]{ChillingTrap.class, ToxicTrap.class, WornTrap.class, + AlarmTrap.class, OozeTrap.class, + FlockTrap.class, SummoningTrap.class, TeleportationTrap.class, }; +} + + @Override + protected float[] trapChances() { + return Dungeon.depth == 1 ? + new float[]{1} : + new float[]{4, 4, 4, + 2, 2, + 1, 1, 1}; + } + @Override protected void decorate() {