v0.6.0: moved decorate functionality in painters
This commit is contained in:
parent
21251c66c1
commit
01ed933be2
|
@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RotGardenRoom;
|
||||
|
@ -47,7 +47,6 @@ import com.watabou.utils.Bundle;
|
|||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class Wandmaker extends NPC {
|
||||
|
||||
|
@ -251,7 +250,7 @@ public class Wandmaker extends NPC {
|
|||
|
||||
private static boolean questRoomSpawned;
|
||||
|
||||
public static void spawnWandmaker( PrisonLevel level, Room room, Collection<Room> rooms ) {
|
||||
public static void spawnWandmaker( Level level, Room room ) {
|
||||
if (questRoomSpawned) {
|
||||
|
||||
questRoomSpawned = false;
|
||||
|
|
|
@ -162,12 +162,6 @@ public class CavesBossLevel extends Level {
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=width() + 1; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
int n = 0;
|
||||
|
@ -188,7 +182,7 @@ public class CavesBossLevel extends Level {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i=0; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.WALL
|
||||
&& DungeonTileSheet.floorTile(map[i + width()])
|
||||
|
@ -202,6 +196,9 @@ public class CavesBossLevel extends Level {
|
|||
sign = Random.Int( ROOM_LEFT, ROOM_RIGHT ) + Random.Int( ROOM_TOP, ROOM_BOTTOM ) * width();
|
||||
} while (sign == entrance || map[sign] == Terrain.INACTIVE_TRAP);
|
||||
map[sign] = Terrain.SIGN;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,10 +24,9 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.CavesPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.TunnelRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
|
||||
|
@ -48,14 +47,12 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.TeleportationTrap;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.VenomTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.particles.PixelParticle;
|
||||
import com.watabou.utils.PointF;
|
||||
import com.watabou.utils.Random;
|
||||
import com.watabou.utils.Rect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -83,6 +80,14 @@ public class CavesLevel extends RegularLevel {
|
|||
return 1+Random.chances(new float[]{3, 3, 2, 1});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Painter painter() {
|
||||
return new CavesPainter()
|
||||
.setWater(feeling == Feeling.WATER ? 0.85f : 0.30f, 6)
|
||||
.setGrass(feeling == Feeling.GRASS ? 0.65f : 0.15f, 3)
|
||||
.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tilesTex() {
|
||||
return Assets.TILES_CAVES;
|
||||
|
@ -93,26 +98,6 @@ public class CavesLevel extends RegularLevel {
|
|||
return Assets.WATER_CAVES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return feeling == Feeling.WATER ? 0.85f : 0.30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return feeling == Feeling.GRASS ? 0.65f : 0.15f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] trapClasses() {
|
||||
return new Class[]{ FireTrap.class, FrostTrap.class, PoisonTrap.class, SpearTrap.class, VenomTrap.class,
|
||||
|
@ -129,123 +114,6 @@ public class CavesLevel extends RegularLevel {
|
|||
1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (!(room instanceof StandardRoom)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (room.width() <= 4 || room.height() <= 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int s = room.square();
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.left + 1) + (room.top + 1) * width();
|
||||
if (map[corner - 1] == Terrain.WALL && map[corner - width()] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.right - 1) + (room.top + 1) * width();
|
||||
if (map[corner + 1] == Terrain.WALL && map[corner - width()] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.left + 1) + (room.bottom - 1) * width();
|
||||
if (map[corner - 1] == Terrain.WALL && map[corner + width()] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.right - 1) + (room.bottom - 1) * width();
|
||||
if (map[corner + 1] == Terrain.WALL && map[corner + width()] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
for (Room n : room.connected.keySet()) {
|
||||
if ((n instanceof StandardRoom || n instanceof TunnelRoom) && Random.Int( 3 ) == 0) {
|
||||
Painter.set( this, room.connected.get( n ), Terrain.EMPTY_DECO );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=width() + 1; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
int n = 0;
|
||||
if (map[i+1] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i-1] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i+width()] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i-width()] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (Random.Int( 6 ) <= n) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
DungeonTileSheet.floorTile(map[i + width()])
|
||||
&& Random.Int( 4 ) == 0) {
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
placeSign();
|
||||
|
||||
if (Dungeon.bossLevel( Dungeon.depth + 1 )) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Room r : rooms) {
|
||||
if (r instanceof StandardRoom) {
|
||||
for (Room n : r.neigbours) {
|
||||
if (n instanceof StandardRoom && !r.connected.containsKey( n )) {
|
||||
Rect w = r.intersect( n );
|
||||
if (w.left == w.right && w.bottom - w.top >= 5) {
|
||||
|
||||
w.top += 2;
|
||||
w.bottom -= 1;
|
||||
|
||||
w.right++;
|
||||
|
||||
Painter.fill( this, w.left, w.top, 1, w.height(), Terrain.CHASM );
|
||||
|
||||
} else if (w.top == w.bottom && w.right - w.left >= 5) {
|
||||
|
||||
w.left += 2;
|
||||
w.right -= 1;
|
||||
|
||||
w.bottom++;
|
||||
|
||||
Painter.fill( this, w.left, w.top, w.width(), 1, Terrain.CHASM );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileName( int tile ) {
|
||||
switch (tile) {
|
||||
|
|
|
@ -129,12 +129,6 @@ public class CityBossLevel extends Level {
|
|||
entrance = (TOP + HALL_HEIGHT + 3 + Random.Int( CHAMBER_HEIGHT - 2 )) * width() + LEFT + (/*1 +*/ Random.Int( HALL_WIDTH-2 ));
|
||||
map[entrance] = Terrain.ENTRANCE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
|
@ -147,6 +141,8 @@ public class CityBossLevel extends Level {
|
|||
|
||||
int sign = arenaDoor + 2*width() + 1;
|
||||
map[sign] = Terrain.SIGN;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int pedestal( boolean left ) {
|
||||
|
|
|
@ -24,6 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.CityPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BlazingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.CursingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisarmingTrap;
|
||||
|
@ -43,7 +45,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.VenomTrap;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WeakeningTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
|
@ -79,25 +80,13 @@ public class CityLevel extends RegularLevel {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return feeling == Feeling.WATER ? 0.90f : 0.30f;
|
||||
protected Painter painter() {
|
||||
return new CityPainter()
|
||||
.setWater(feeling == Feeling.WATER ? 0.90f : 0.30f, 4)
|
||||
.setGrass(feeling == Feeling.GRASS ? 0.80f : 0.20f, 3)
|
||||
.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return feeling == Feeling.GRASS ? 0.80f : 0.20f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] trapClasses() {
|
||||
return new Class[]{ BlazingTrap.class, FrostTrap.class, SpearTrap.class, VenomTrap.class,
|
||||
|
@ -114,22 +103,6 @@ public class CityLevel extends RegularLevel {
|
|||
1, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
} else if (map[i] == Terrain.WALL
|
||||
&& DungeonTileSheet.floorTile(map[i + width()])
|
||||
&& Random.Int( 21 - Dungeon.depth ) == 0) {
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
placeSign();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createItems() {
|
||||
super.createItems();
|
||||
|
|
|
@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class DeadEndLevel extends Level {
|
||||
|
||||
|
@ -73,17 +72,6 @@ public class DeadEndLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
for (int i=0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
} else if (map[i] == Terrain.WALL && Random.Int( 8 ) == 0) {
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
}
|
||||
|
|
|
@ -96,53 +96,49 @@ public class HallsBossLevel extends Level {
|
|||
|
||||
setSize(32, 32);
|
||||
|
||||
for (int i=0; i < 5; i++) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
int top = Random.IntRange( 2, ROOM_TOP - 1 );
|
||||
int bottom = Random.IntRange( ROOM_BOTTOM + 1, 22 );
|
||||
Painter.fill( this, 2 + i * 4, top, 4, bottom - top + 1, Terrain.EMPTY );
|
||||
int top = Random.IntRange(2, ROOM_TOP - 1);
|
||||
int bottom = Random.IntRange(ROOM_BOTTOM + 1, 22);
|
||||
Painter.fill(this, 2 + i * 4, top, 4, bottom - top + 1, Terrain.EMPTY);
|
||||
|
||||
if (i == 2) {
|
||||
exit = (i * 4 + 3) + (top - 1) * width() ;
|
||||
exit = (i * 4 + 3) + (top - 1) * width();
|
||||
}
|
||||
|
||||
for (int j=0; j < 4; j++) {
|
||||
if (Random.Int( 2 ) == 0) {
|
||||
int y = Random.IntRange( top + 1, bottom - 1 );
|
||||
map[i*4+j + y*width()] = Terrain.WALL_DECO;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (Random.Int(2) == 0) {
|
||||
int y = Random.IntRange(top + 1, bottom - 1);
|
||||
map[i * 4 + j + y * width()] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map[exit] = Terrain.LOCKED_EXIT;
|
||||
|
||||
Painter.fill( this, ROOM_LEFT - 1, ROOM_TOP - 1,
|
||||
ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL );
|
||||
Painter.fill( this, ROOM_LEFT, ROOM_TOP,
|
||||
ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP + 1, Terrain.EMPTY );
|
||||
Painter.fill(this, ROOM_LEFT - 1, ROOM_TOP - 1,
|
||||
ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL);
|
||||
Painter.fill(this, ROOM_LEFT, ROOM_TOP,
|
||||
ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP + 1, Terrain.EMPTY);
|
||||
|
||||
entrance = Random.Int( ROOM_LEFT + 1, ROOM_RIGHT - 1 ) +
|
||||
Random.Int( ROOM_TOP + 1, ROOM_BOTTOM - 1 ) * width();
|
||||
entrance = Random.Int(ROOM_LEFT + 1, ROOM_RIGHT - 1) +
|
||||
Random.Int(ROOM_TOP + 1, ROOM_BOTTOM - 1) * width();
|
||||
map[entrance] = Terrain.ENTRANCE;
|
||||
|
||||
boolean[] patch = Patch.generate( width, height, 0.30f, 6, true );
|
||||
for (int i=0; i < length(); i++) {
|
||||
boolean[] patch = Patch.generate(width, height, 0.30f, 6, true);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && patch[i]) {
|
||||
map[i] = Terrain.WATER;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
for (int i = 0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int(10) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,8 @@ import android.opengl.GLES20;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Torch;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.HallsPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BlazingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.CursingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisarmingTrap;
|
||||
|
@ -50,7 +52,6 @@ import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
|||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.particles.PixelParticle;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.PointF;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
|
@ -76,6 +77,14 @@ public class HallsLevel extends RegularLevel {
|
|||
return 1 + Random.chances(new float[]{1, 3, 3, 2});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Painter painter() {
|
||||
return new HallsPainter()
|
||||
.setWater(feeling == Feeling.WATER ? 0.70f : 0.15f, 6)
|
||||
.setGrass(feeling == Feeling.GRASS ? 0.65f : 0.10f, 3)
|
||||
.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
addItemToSpawn( new Torch() );
|
||||
|
@ -92,26 +101,6 @@ public class HallsLevel extends RegularLevel {
|
|||
return Assets.WATER_HALLS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return feeling == Feeling.WATER ? 0.70f : 0.15f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return feeling == Feeling.GRASS ? 0.65f : 0.10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] trapClasses() {
|
||||
return new Class[]{ BlazingTrap.class, DisintegrationTrap.class, FrostTrap.class, SpearTrap.class, VenomTrap.class,
|
||||
|
@ -128,36 +117,6 @@ public class HallsLevel extends RegularLevel {
|
|||
1, 1, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=width() + 1; i < length() - width() - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
int count = 0;
|
||||
for (int j=0; j < PathFinder.NEIGHBOURS8.length; j++) {
|
||||
if ((Terrain.flags[map[i + PathFinder.NEIGHBOURS8[j]]] & Terrain.PASSABLE) > 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( 80 ) < count) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
|
||||
} else
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i-1] != Terrain.WALL_DECO && map[i-width()] != Terrain.WALL_DECO &&
|
||||
Random.Int( 20 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
placeSign();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileName( int tile ) {
|
||||
switch (tile) {
|
||||
|
|
|
@ -100,21 +100,17 @@ public class LastLevel extends Level {
|
|||
map[pos-3] = map[pos-2] = map[pos-1] = map[pos] = map[pos+1] = map[pos+2] = map[pos+3] = Terrain.WATER;
|
||||
pos+=width();
|
||||
map[pos-2] = map[pos+2] = Terrain.WATER;
|
||||
|
||||
|
||||
feeling = Feeling.NONE;
|
||||
viewDistance = 8;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
feeling = Feeling.NONE;
|
||||
viewDistance = 8;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,18 +24,18 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LineBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.CityPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ImpShopRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -59,7 +59,18 @@ public class LastShopLevel extends RegularLevel {
|
|||
@Override
|
||||
protected boolean build() {
|
||||
feeling = Feeling.CHASM;
|
||||
return super.build();
|
||||
if (super.build()){
|
||||
|
||||
for (int i=0; i < length(); i++) {
|
||||
if (map[i] == Terrain.SECRET_DOOR) {
|
||||
map[i] = Terrain.DOOR;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,27 +93,10 @@ public class LastShopLevel extends RegularLevel {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < length(); i++) {
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
|
||||
} else if (map[i] == Terrain.WALL && Random.Int( 8 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
|
||||
} else if (map[i] == Terrain.SECRET_DOOR) {
|
||||
|
||||
map[i] = Terrain.DOOR;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (Imp.Quest.isCompleted()) {
|
||||
placeSign();
|
||||
}
|
||||
protected Painter painter() {
|
||||
return new CityPainter()
|
||||
.setWater( 0.10f, 4 )
|
||||
.setGrass( 0.10f, 3 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,30 +157,6 @@ public class LastShopLevel extends RegularLevel {
|
|||
return super.tileDesc( tile );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return 0.10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return 0.10f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
protected int nTraps() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group addVisuals( ) {
|
||||
|
|
|
@ -250,7 +250,6 @@ public abstract class Level implements Bundlable {
|
|||
customWalls = new HashSet<>();
|
||||
|
||||
} while (!build());
|
||||
decorate();
|
||||
|
||||
buildFlagMaps();
|
||||
cleanWalls();
|
||||
|
@ -462,8 +461,6 @@ public abstract class Level implements Bundlable {
|
|||
|
||||
abstract protected boolean build();
|
||||
|
||||
abstract protected void decorate();
|
||||
|
||||
abstract protected void createMobs();
|
||||
|
||||
abstract protected void createItems();
|
||||
|
|
|
@ -122,7 +122,6 @@ public class PrisonBossLevel extends Level {
|
|||
setSize(32, 32);
|
||||
|
||||
map = MAP_START.clone();
|
||||
decorate();
|
||||
|
||||
buildFlagMaps();
|
||||
cleanWalls();
|
||||
|
@ -136,11 +135,6 @@ public class PrisonBossLevel extends Level {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
//do nothing, all decorations are hard-coded.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMobs() {
|
||||
tengu = new Tengu(); //We want to keep track of tengu independently of other mobs, he's not always in the level.
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Halo;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.PrisonPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
||||
|
@ -73,6 +75,14 @@ public class PrisonLevel extends RegularLevel {
|
|||
return 1+Random.chances(new float[]{4, 3, 3});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Painter painter() {
|
||||
return new PrisonPainter()
|
||||
.setWater(feeling == Feeling.WATER ? 0.90f : 0.30f, 4)
|
||||
.setGrass(feeling == Feeling.GRASS ? 0.80f : 0.20f, 3)
|
||||
.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tilesTex() {
|
||||
return Assets.TILES_PRISON;
|
||||
|
@ -83,26 +93,6 @@ public class PrisonLevel extends RegularLevel {
|
|||
return Assets.WATER_PRISON;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return feeling == Feeling.WATER ? 0.90f : 0.30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return feeling == Feeling.GRASS ? 0.80f : 0.20f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] trapClasses() {
|
||||
return new Class[]{ ChillingTrap.class, FireTrap.class, PoisonTrap.class, SpearTrap.class, ToxicTrap.class,
|
||||
|
@ -116,56 +106,6 @@ public class PrisonLevel extends RegularLevel {
|
|||
2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
Wandmaker.Quest.spawnWandmaker( this, roomEntrance, rooms );
|
||||
|
||||
for (int i=width() + 1; i < length() - width() - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
float c = 0.05f;
|
||||
if (map[i + 1] == Terrain.WALL && map[i + width()] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i - 1] == Terrain.WALL && map[i + width()] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i + 1] == Terrain.WALL && map[i - width()] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i - 1] == Terrain.WALL && map[i - width()] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
|
||||
if (Random.Float() < c) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < width(); i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
(map[i + width()] == Terrain.EMPTY || map[i + width()] == Terrain.EMPTY_SP) &&
|
||||
Random.Int( 6 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=width(); i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i - width()] == Terrain.WALL &&
|
||||
(map[i + width()] == Terrain.EMPTY || map[i + width()] == Terrain.EMPTY_SP) &&
|
||||
Random.Int( 3 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
placeSign();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tileName( int tile ) {
|
||||
|
|
|
@ -32,10 +32,9 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.BranchesBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LineBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.RegularPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
||||
|
@ -70,7 +69,6 @@ public abstract class RegularLevel extends Level {
|
|||
|
||||
builder = builder();
|
||||
|
||||
|
||||
ArrayList<Room> initRooms = initRooms();
|
||||
Random.shuffle(initRooms);
|
||||
|
||||
|
@ -82,7 +80,12 @@ public abstract class RegularLevel extends Level {
|
|||
rooms = builder.build((ArrayList<Room>)initRooms.clone());
|
||||
} while (rooms == null);
|
||||
|
||||
return painter().paint(this, rooms);
|
||||
if (painter().paint(this, rooms)){
|
||||
placeSign();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,8 +104,8 @@ public abstract class RegularLevel extends Level {
|
|||
int specials = specialRooms();
|
||||
SpecialRoom.initForFloor();
|
||||
for (int i = 0; i < specials; i++)
|
||||
initRooms.add(SpecialRoom.createRoom());
|
||||
|
||||
initRooms.add(SpecialRoom.createRoom());
|
||||
|
||||
return initRooms;
|
||||
}
|
||||
|
||||
|
@ -116,16 +119,10 @@ public abstract class RegularLevel extends Level {
|
|||
|
||||
protected Builder builder(){
|
||||
//TODO need a much better builder here
|
||||
return new LineBuilder();
|
||||
return new BranchesBuilder();
|
||||
}
|
||||
|
||||
protected Painter painter(){
|
||||
RegularPainter p = new RegularPainter();
|
||||
p.setGrass(grassFill(), grassSmoothing());
|
||||
p.setWater(waterFill(), waterSmoothing());
|
||||
p.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
return p;
|
||||
}
|
||||
protected abstract Painter painter();
|
||||
|
||||
protected void placeSign(){
|
||||
while (true) {
|
||||
|
@ -135,6 +132,15 @@ public abstract class RegularLevel extends Level {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//teaches players about secret doors
|
||||
if (Dungeon.depth == 2) {
|
||||
for (Room r : roomEntrance.connected.keySet()) {
|
||||
Room.Door d = roomEntrance.connected.get(r);
|
||||
if (d.type == Room.Door.Type.REGULAR)
|
||||
map[d.x + d.y * width()] = Terrain.SECRET_DOOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected float waterFill(){
|
||||
|
|
|
@ -26,7 +26,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Ripple;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.DewVial;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.SewerPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FlockTrap;
|
||||
|
@ -71,6 +72,14 @@ public class SewerLevel extends RegularLevel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Painter painter() {
|
||||
return new SewerPainter()
|
||||
.setWater(feeling == Feeling.WATER ? 0.85f : 0.30f, 5)
|
||||
.setGrass(feeling == Feeling.GRASS ? 0.80f : 0.20f, 4)
|
||||
.setTraps(nTraps(), trapClasses(), trapChances());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tilesTex() {
|
||||
return Assets.TILES_SEWERS;
|
||||
|
@ -81,26 +90,6 @@ public class SewerLevel extends RegularLevel {
|
|||
return Assets.WATER_SEWERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float waterFill() {
|
||||
return feeling == Feeling.WATER ? 0.85f : 0.30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int waterSmoothing() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float grassFill() {
|
||||
return feeling == Feeling.GRASS ? 0.80f : 0.20f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int grassSmoothing() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] trapClasses() {
|
||||
return Dungeon.depth == 1 ?
|
||||
|
@ -118,54 +107,6 @@ public class SewerLevel extends RegularLevel {
|
|||
2, 2,
|
||||
1, 1, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decorate() {
|
||||
|
||||
for (int i=0; i < width(); i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i + width()] == Terrain.WATER &&
|
||||
Random.Int( 4 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=width(); i < length() - width(); i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i - width()] == Terrain.WALL &&
|
||||
map[i + width()] == Terrain.WATER &&
|
||||
Random.Int( 2 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=width() + 1; i < length() - width() - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
int count =
|
||||
(map[i + 1] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i - 1] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i + width()] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i - width()] == Terrain.WALL ? 1 : 0);
|
||||
|
||||
if (Random.Int( 16 ) < count * count) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//hides all doors in the entrance room on floor 2, teaches the player to search.
|
||||
if (Dungeon.depth == 2)
|
||||
for (Room r : roomEntrance.connected.keySet()){
|
||||
Room.Door d = roomEntrance.connected.get(r);
|
||||
if (d.type == Room.Door.Type.REGULAR)
|
||||
map[d.x + d.y * width()] = Terrain.SECRET_DOOR;
|
||||
}
|
||||
|
||||
placeSign();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createItems() {
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2017 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||
import com.watabou.utils.Random;
|
||||
import com.watabou.utils.Rect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CavesPainter extends RegularPainter {
|
||||
|
||||
@Override
|
||||
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||
|
||||
int w = level.width();
|
||||
int l = level.length();
|
||||
int[] map = level.map;
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (!(room instanceof StandardRoom)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (room.width() <= 4 || room.height() <= 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int s = room.square();
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.left + 1) + (room.top + 1) * w;
|
||||
if (map[corner - 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
level.traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.right - 1) + (room.top + 1) * w;
|
||||
if (map[corner + 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
level.traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.left + 1) + (room.bottom - 1) * w;
|
||||
if (map[corner - 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
level.traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( s ) > 8) {
|
||||
int corner = (room.right - 1) + (room.bottom - 1) * w;
|
||||
if (map[corner + 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) {
|
||||
map[corner] = Terrain.WALL;
|
||||
level.traps.remove(corner);
|
||||
}
|
||||
}
|
||||
|
||||
for (Room n : room.connected.keySet()) {
|
||||
if ((n instanceof StandardRoom || n instanceof ConnectionRoom) && Random.Int( 3 ) == 0) {
|
||||
Painter.set( level, room.connected.get( n ), Terrain.EMPTY_DECO );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=w + 1; i < l - w; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
int n = 0;
|
||||
if (map[i+1] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i-1] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i+w] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (map[i-w] == Terrain.WALL) {
|
||||
n++;
|
||||
}
|
||||
if (Random.Int( 6 ) <= n) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < l - w; i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
DungeonTileSheet.floorTile(map[i + w])
|
||||
&& Random.Int( 4 ) == 0) {
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (Room r : rooms) {
|
||||
if (r instanceof StandardRoom) {
|
||||
for (Room n : r.neigbours) {
|
||||
if (n instanceof StandardRoom && !r.connected.containsKey( n )) {
|
||||
Rect i = r.intersect( n );
|
||||
if (i.left == i.right && i.bottom - i.top >= 5) {
|
||||
|
||||
i.top += 2;
|
||||
i.bottom -= 1;
|
||||
|
||||
i.right++;
|
||||
|
||||
Painter.fill( level, i.left, i.top, 1, i.height(), Terrain.CHASM );
|
||||
|
||||
} else if (i.top == i.bottom && i.right - i.left >= 5) {
|
||||
|
||||
i.left += 2;
|
||||
i.right -= 1;
|
||||
|
||||
i.bottom++;
|
||||
|
||||
Painter.fill( level, i.left, i.top, i.width(), 1, Terrain.CHASM );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2017 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CityPainter extends RegularPainter {
|
||||
|
||||
@Override
|
||||
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||
|
||||
int[] map = level.map;
|
||||
int w = level.width();
|
||||
int l = level.length();
|
||||
|
||||
for (int i=0; i < l - w; i++) {
|
||||
|
||||
if (map[i] == Terrain.EMPTY && Random.Int( 10 ) == 0) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
|
||||
} else if (map[i] == Terrain.WALL
|
||||
&& !DungeonTileSheet.wallStitcheable(map[i + w])
|
||||
&& Random.Int( 22 - Dungeon.depth ) == 0) {
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2017 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HallsPainter extends RegularPainter {
|
||||
|
||||
@Override
|
||||
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||
|
||||
int[] map = level.map;
|
||||
int w = level.width();
|
||||
int l = level.length();
|
||||
|
||||
for (int i=w + 1; i < l - w - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
int count = 0;
|
||||
for (int j = 0; j < PathFinder.NEIGHBOURS8.length; j++) {
|
||||
if ((Terrain.flags[map[i + PathFinder.NEIGHBOURS8[j]]] & Terrain.PASSABLE) > 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Random.Int( 80 ) < count) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
|
||||
} else
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i-1] != Terrain.WALL_DECO && map[i-w] != Terrain.WALL_DECO &&
|
||||
Random.Int( 20 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2017 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PrisonPainter extends RegularPainter {
|
||||
|
||||
@Override
|
||||
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||
|
||||
for (Room r : rooms) {
|
||||
if (r instanceof EntranceRoom) {
|
||||
Wandmaker.Quest.spawnWandmaker(level, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int w = level.width();
|
||||
int l = level.length();
|
||||
int[] map = level.map;
|
||||
|
||||
for (int i=w + 1; i < l - w - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
float c = 0.05f;
|
||||
if (map[i + 1] == Terrain.WALL && map[i + w] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i - 1] == Terrain.WALL && map[i + w] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i + 1] == Terrain.WALL && map[i - w] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
if (map[i - 1] == Terrain.WALL && map[i - w] == Terrain.WALL) {
|
||||
c += 0.2f;
|
||||
}
|
||||
|
||||
if (Random.Float() < c) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < w; i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
(map[i + w] == Terrain.EMPTY || map[i + w] == Terrain.EMPTY_SP) &&
|
||||
Random.Int( 6 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=w; i < l - w; i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i - w] == Terrain.WALL &&
|
||||
(map[i + w] == Terrain.EMPTY || map[i + w] == Terrain.EMPTY_SP) &&
|
||||
Random.Int( 3 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Point;
|
||||
|
@ -37,59 +37,75 @@ import com.watabou.utils.Rect;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RegularPainter extends Painter {
|
||||
public abstract class RegularPainter extends Painter {
|
||||
|
||||
private float waterFill = 0f;
|
||||
private int waterSmoothness;
|
||||
|
||||
public RegularPainter setWater(float fill, int smoothness){
|
||||
waterFill = fill;
|
||||
waterSmoothness = smoothness;
|
||||
return this;
|
||||
}
|
||||
|
||||
private float grassFill = 0f;
|
||||
private int grassSmoothness;
|
||||
|
||||
public RegularPainter setGrass(float fill, int smoothness){
|
||||
grassFill = fill;
|
||||
grassSmoothness = smoothness;
|
||||
return this;
|
||||
}
|
||||
|
||||
private int nTraps = 0;
|
||||
private Class<? extends Trap>[] trapClasses;
|
||||
private float[] trapChances;
|
||||
|
||||
public void setWater(float fill, int smoothness){
|
||||
waterFill = fill;
|
||||
waterSmoothness = smoothness;
|
||||
}
|
||||
|
||||
public void setGrass(float fill, int smoothness){
|
||||
grassFill = fill;
|
||||
grassSmoothness = smoothness;
|
||||
}
|
||||
|
||||
public void setTraps(int num, Class<?>[] classes, float[] chances){
|
||||
public RegularPainter setTraps(int num, Class<?>[] classes, float[] chances){
|
||||
nTraps = num;
|
||||
trapClasses = (Class<? extends Trap>[]) classes;
|
||||
trapChances = chances;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paint(Level level, ArrayList<Room> rooms) {
|
||||
int leftMost = Integer.MAX_VALUE, topMost = Integer.MAX_VALUE;
|
||||
|
||||
for (Room r : rooms){
|
||||
if (r.left < leftMost) leftMost = r.left;
|
||||
if (r.top < topMost) topMost = r.top;
|
||||
//painter can be used without rooms
|
||||
if (rooms != null) {
|
||||
int leftMost = Integer.MAX_VALUE, topMost = Integer.MAX_VALUE;
|
||||
|
||||
for (Room r : rooms) {
|
||||
if (r.left < leftMost) leftMost = r.left;
|
||||
if (r.top < topMost) topMost = r.top;
|
||||
}
|
||||
|
||||
//subtract 1 for padding
|
||||
leftMost--;
|
||||
topMost--;
|
||||
|
||||
int rightMost = 0, bottomMost = 0;
|
||||
|
||||
for (Room r : rooms) {
|
||||
r.shift(-leftMost, -topMost);
|
||||
if (r.right > rightMost) rightMost = r.right;
|
||||
if (r.bottom > bottomMost) bottomMost = r.bottom;
|
||||
}
|
||||
|
||||
//add 1 for padding
|
||||
rightMost++;
|
||||
bottomMost++;
|
||||
|
||||
//add 1 to account for 0 values
|
||||
level.setSize(rightMost + 1, bottomMost + 1);
|
||||
} else {
|
||||
//check if the level's size was already initialized by something else
|
||||
if (level.length() == 0) return false;
|
||||
|
||||
//easier than checking for null everywhere
|
||||
rooms = new ArrayList<>();
|
||||
}
|
||||
|
||||
leftMost--;
|
||||
topMost--;
|
||||
|
||||
int width = 0, height = 0;
|
||||
|
||||
for (Room r : rooms){
|
||||
r.shift( -leftMost, -topMost);
|
||||
if (r.right > width) width = r.right;
|
||||
if (r.bottom > height) height = r.bottom;
|
||||
}
|
||||
|
||||
width++;
|
||||
height++;
|
||||
|
||||
level.setSize(width+1, height+1);
|
||||
|
||||
for (Room r : rooms) {
|
||||
placeDoors( r );
|
||||
r.paint( level );
|
||||
|
@ -111,9 +127,13 @@ public class RegularPainter extends Painter {
|
|||
paintTraps( level );
|
||||
}
|
||||
|
||||
decorate( level, rooms );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void decorate(Level level, ArrayList<Room> rooms);
|
||||
|
||||
private void placeDoors( Room r ) {
|
||||
for (Room n : r.connected.keySet()) {
|
||||
Room.Door door = r.connected.get( n );
|
||||
|
@ -137,6 +157,7 @@ public class RegularPainter extends Painter {
|
|||
for (Room n : r.connected.keySet()) {
|
||||
|
||||
if (joinRooms( l, r, n )) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -176,10 +197,11 @@ public class RegularPainter extends Painter {
|
|||
|
||||
protected boolean joinRooms( Level l, Room r, Room n ) {
|
||||
|
||||
if (!(r instanceof StandardRoom && n instanceof StandardRoom)) {
|
||||
if (!(r instanceof EmptyRoom && n instanceof EmptyRoom)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO decide on good probabilities and dimension restrictions
|
||||
Rect w = r.intersect( n );
|
||||
if (w.left == w.right) {
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2017 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SewerPainter extends RegularPainter {
|
||||
|
||||
@Override
|
||||
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||
|
||||
int[] map = level.map;
|
||||
int w = level.width();
|
||||
int l = level.length();
|
||||
|
||||
for (int i=0; i < w; i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i + w] == Terrain.WATER &&
|
||||
Random.Int( 4 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=w; i < l - w; i++) {
|
||||
if (map[i] == Terrain.WALL &&
|
||||
map[i - w] == Terrain.WALL &&
|
||||
map[i + w] == Terrain.WATER &&
|
||||
Random.Int( 2 ) == 0) {
|
||||
|
||||
map[i] = Terrain.WALL_DECO;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=w + 1; i < l - w - 1; i++) {
|
||||
if (map[i] == Terrain.EMPTY) {
|
||||
|
||||
int count =
|
||||
(map[i + 1] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i - 1] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i + w] == Terrain.WALL ? 1 : 0) +
|
||||
(map[i - w] == Terrain.WALL ? 1 : 0);
|
||||
|
||||
if (Random.Int( 16 ) < count * count) {
|
||||
map[i] = Terrain.EMPTY_DECO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user