v0.3.1: implemented generation logic for traps from floors 1 to 9
This commit is contained in:
parent
67e8904194
commit
8d0e21aea0
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*;
|
||||||
import com.watabou.noosa.Scene;
|
import com.watabou.noosa.Scene;
|
||||||
import com.watabou.noosa.particles.Emitter;
|
import com.watabou.noosa.particles.Emitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
@ -56,7 +57,21 @@ public class PrisonLevel extends RegularLevel {
|
||||||
protected boolean[] grass() {
|
protected boolean[] grass() {
|
||||||
return Patch.generate( feeling == Feeling.GRASS ? 0.60f : 0.40f, 3 );
|
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
|
@Override
|
||||||
protected boolean assignRoomType() {
|
protected boolean assignRoomType() {
|
||||||
super.assignRoomType();
|
super.assignRoomType();
|
||||||
|
|
|
@ -35,13 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.ShopPainter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.ShopPainter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*;
|
||||||
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.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Graph;
|
import com.watabou.utils.Graph;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
@ -337,50 +331,35 @@ public abstract class RegularLevel extends Level {
|
||||||
|
|
||||||
int nTraps = nTraps();
|
int nTraps = nTraps();
|
||||||
float[] trapChances = trapChances();
|
float[] trapChances = trapChances();
|
||||||
|
Class<?>[] trapClasses = trapClasses();
|
||||||
|
|
||||||
for (int i=0; i < nTraps; i++) {
|
for (int i=0; i < nTraps; i++) {
|
||||||
|
|
||||||
int trapPos = Random.Int( LENGTH );
|
int trapPos = Random.Int( LENGTH );
|
||||||
|
|
||||||
if (map[trapPos] == Terrain.EMPTY) {
|
if (map[trapPos] == Terrain.EMPTY) {
|
||||||
map[trapPos] = Terrain.SECRET_TRAP;
|
try {
|
||||||
switch (Random.chances( trapChances )) {
|
Trap trap = ((Trap)trapClasses[Random.chances( trapChances )].newInstance()).hide();
|
||||||
case 0:
|
setTrap( trap, trapPos );
|
||||||
setTrap( new ToxicTrap().hide(), trapPos);
|
//some traps will not be hidden
|
||||||
break;
|
map[trapPos] = trap.visible ? Terrain.TRAP : Terrain.SECRET_TRAP;
|
||||||
case 1:
|
} catch (Exception e) {
|
||||||
setTrap( new FireTrap().hide(), trapPos);
|
throw new RuntimeException(e);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int nTraps() {
|
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() {
|
protected float[] trapChances() {
|
||||||
float[] chances = { 1, 1, 1, 1, 1, 1, 1, 1 };
|
return new float[]{1};
|
||||||
return chances;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int minRoomSize = 7;
|
protected int minRoomSize = 7;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Scene;
|
import com.watabou.noosa.Scene;
|
||||||
import com.watabou.noosa.particles.Emitter;
|
import com.watabou.noosa.particles.Emitter;
|
||||||
|
@ -58,7 +59,25 @@ public class SewerLevel extends RegularLevel {
|
||||||
protected boolean[] grass() {
|
protected boolean[] grass() {
|
||||||
return Patch.generate( feeling == Feeling.GRASS ? 0.60f : 0.40f, 4 );
|
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
|
@Override
|
||||||
protected void decorate() {
|
protected void decorate() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user