v0.3.1: reworked the trap special room type

This commit is contained in:
Evan Debenham
2015-07-14 00:51:52 -04:00
committed by Evan Debenham
parent 38852c357e
commit 8c96647743
@@ -21,7 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
@@ -29,25 +28,29 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ParalyticTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*;
import com.watabou.utils.Random;
public class TrapsPainter extends Painter {
public static void paint( Level level, Room room ) {
Class traps[] = new Class[]{
ToxicTrap.class, ToxicTrap.class, ToxicTrap.class,
ParalyticTrap.class, ParalyticTrap.class,
!Dungeon.bossLevel(Dungeon.depth + 1) ? null : SummoningTrap.class};
fill( level, room, Terrain.WALL );
Class trap = Random.element(traps);
Class<? extends Trap> trapClass;
switch (Random.Int(5)){
case 0: default:
trapClass = SpearTrap.class;
break;
case 1:
trapClass = !Dungeon.bossLevel(Dungeon.depth + 1)? null : SummoningTrap.class;
break;
case 2: case 3: case 4:
trapClass = Random.oneOf(levelTraps[Dungeon.depth/5]);
break;
}
if (trap == null){
if (trapClass == null){
fill(level, room, 1, Terrain.CHASM);
} else {
fill(level, room, 1, Terrain.TRAP);
@@ -81,7 +84,7 @@ public class TrapsPainter extends Painter {
for(int cell : room.getCells()) {
if (level.map[cell] == Terrain.TRAP){
try {
level.setTrap(((Trap) trap.newInstance()).reveal(), cell);
level.setTrap(((Trap) trapClass.newInstance()).reveal(), cell);
} catch (Exception e) {
e.printStackTrace();
}
@@ -129,4 +132,18 @@ public class TrapsPainter extends Painter {
return prize;
}
@SuppressWarnings("unchecked")
private static Class<?extends Trap>[][] levelTraps = new Class[][]{
//sewers
{ToxicTrap.class, TeleportationTrap.class, FlockTrap.class},
//prison
{ConfusionTrap.class, ExplosiveTrap.class, ParalyticTrap.class},
//caves
{BlazingTrap.class, VenomTrap.class, ExplosiveTrap.class},
//city
{WarpingTrap.class, VenomTrap.class, DisintegrationTrap.class},
//halls, muahahahaha
{GrimTrap.class}
};
}