v2.2.0: made a bunch of WIP improvements to mining level layout
This commit is contained in:
+43
-104
@@ -23,88 +23,59 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
|||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
import com.shatteredpixel.shatteredpixeldungeon.Bones;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.BranchesBuilder;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.MiningLevelPainter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.MiningLevelPainter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
||||||
import com.watabou.noosa.Group;
|
import com.watabou.noosa.Group;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.Tilemap;
|
import com.watabou.noosa.Tilemap;
|
||||||
import com.watabou.noosa.audio.Music;
|
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class MiningLevel extends Level {
|
public class MiningLevel extends CavesLevel {
|
||||||
|
|
||||||
{
|
@Override
|
||||||
color1 = 0x534f3e;
|
protected ArrayList<Room> initRooms() {
|
||||||
color2 = 0xb9d661;
|
ArrayList<Room> initRooms = new ArrayList<>();
|
||||||
|
initRooms.add ( roomEntrance = new EntranceRoom());
|
||||||
|
|
||||||
|
//currently spawns 10-12 cave rooms, of any size
|
||||||
|
int rooms = Random.NormalIntRange(10, 12);
|
||||||
|
for (int i = 0; i < rooms; i++){
|
||||||
|
StandardRoom s;
|
||||||
|
do {
|
||||||
|
s = new CaveRoom();
|
||||||
|
} while (!s.setSizeCat( 8 ));
|
||||||
|
//i += s.sizeCat.roomValue-1;
|
||||||
|
initRooms.add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return initRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playLevelMusic() {
|
protected Builder builder() {
|
||||||
Music.INSTANCE.playTracks(
|
return new BranchesBuilder().setTunnelLength(new float[]{1}, new float[]{1});
|
||||||
new String[]{Assets.Music.CAVES_1, Assets.Music.CAVES_2, Assets.Music.CAVES_2},
|
|
||||||
new float[]{1, 1, 0.5f},
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String tilesTex() {
|
protected Painter painter() {
|
||||||
return Assets.Environment.TILES_CAVES;
|
return new MiningLevelPainter()
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String waterTex() {
|
|
||||||
return Assets.Environment.WATER_CAVES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean build() {
|
|
||||||
|
|
||||||
setSize(32, 32);
|
|
||||||
|
|
||||||
CaveRoom c = new CaveRoom();
|
|
||||||
c.set(1, 1, 31, 31);
|
|
||||||
c.paint(this);
|
|
||||||
|
|
||||||
Painter.fill(this, 15, 15, 3, 3, Terrain.EMPTY);
|
|
||||||
int entrance = 16 * width() + 16;
|
|
||||||
|
|
||||||
transitions.add(new LevelTransition(this,
|
|
||||||
entrance,
|
|
||||||
LevelTransition.Type.BRANCH_ENTRANCE,
|
|
||||||
Dungeon.depth,
|
|
||||||
0,
|
|
||||||
LevelTransition.Type.BRANCH_EXIT));
|
|
||||||
|
|
||||||
map[entrance] = Terrain.ENTRANCE;
|
|
||||||
|
|
||||||
Painter painter = new MiningLevelPainter()
|
|
||||||
.setGold(Random.NormalIntRange(42, 46))
|
.setGold(Random.NormalIntRange(42, 46))
|
||||||
.setWater(0.35f, 6)
|
.setWater(0.35f, 6)
|
||||||
.setGrass(0.10f, 3);
|
.setGrass(0.10f, 3);
|
||||||
|
|
||||||
painter.paint(this, null);
|
|
||||||
|
|
||||||
CustomTilemap vis = new BorderTopDarken();
|
|
||||||
vis.setRect(0, 0, width, 1);
|
|
||||||
customTiles.add(vis);
|
|
||||||
|
|
||||||
vis = new BorderWallsDarken();
|
|
||||||
vis.setRect(0, 0, width, height);
|
|
||||||
customWalls.add(vis);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,53 +95,12 @@ public class MiningLevel extends Level {
|
|||||||
protected void createItems() {
|
protected void createItems() {
|
||||||
Item item = Bones.get();
|
Item item = Bones.get();
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
drop( item, entrance()-width() ).setHauntedIfCursed().type = Heap.Type.REMAINS;
|
int cell = randomDropCell();
|
||||||
}
|
if (map[cell] == Terrain.HIGH_GRASS || map[cell] == Terrain.FURROWED_GRASS) {
|
||||||
}
|
map[cell] = Terrain.GRASS;
|
||||||
|
losBlocking[cell] = false;
|
||||||
@Override
|
}
|
||||||
public int randomRespawnCell( Char ch ) {
|
drop( item, cell ).setHauntedIfCursed().type = Heap.Type.REMAINS;
|
||||||
return entrance()-width();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String tileName( int tile ) {
|
|
||||||
switch (tile) {
|
|
||||||
case Terrain.GRASS:
|
|
||||||
return Messages.get(CavesLevel.class, "grass_name");
|
|
||||||
case Terrain.HIGH_GRASS:
|
|
||||||
return Messages.get(CavesLevel.class, "high_grass_name");
|
|
||||||
case Terrain.WATER:
|
|
||||||
return Messages.get(CavesLevel.class, "water_name");
|
|
||||||
case Terrain.STATUE:
|
|
||||||
//city statues are used
|
|
||||||
return Messages.get(CityLevel.class, "statue_name");
|
|
||||||
default:
|
|
||||||
return super.tileName( tile );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String tileDesc( int tile ) {
|
|
||||||
switch (tile) {
|
|
||||||
case Terrain.WATER:
|
|
||||||
return super.tileDesc( tile ) + "\n\n" + Messages.get(CavesBossLevel.class, "water_desc");
|
|
||||||
case Terrain.ENTRANCE:
|
|
||||||
return Messages.get(CavesLevel.class, "entrance_desc");
|
|
||||||
case Terrain.EXIT:
|
|
||||||
//city exit is used
|
|
||||||
return Messages.get(CityLevel.class, "exit_desc");
|
|
||||||
case Terrain.HIGH_GRASS:
|
|
||||||
return Messages.get(CavesLevel.class, "high_grass_desc");
|
|
||||||
case Terrain.WALL_DECO:
|
|
||||||
return Messages.get(CavesLevel.class, "wall_deco_desc");
|
|
||||||
case Terrain.BOOKSHELF:
|
|
||||||
return Messages.get(CavesLevel.class, "bookshelf_desc");
|
|
||||||
//city statues are used
|
|
||||||
case Terrain.STATUE:
|
|
||||||
return Messages.get(CityLevel.class, "statue_desc");
|
|
||||||
default:
|
|
||||||
return super.tileDesc( tile );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +108,15 @@ public class MiningLevel extends Level {
|
|||||||
public Group addVisuals() {
|
public Group addVisuals() {
|
||||||
super.addVisuals();
|
super.addVisuals();
|
||||||
CavesLevel.addCavesVisuals(this, visuals);
|
CavesLevel.addCavesVisuals(this, visuals);
|
||||||
|
|
||||||
|
CustomTilemap vis = new BorderTopDarken();
|
||||||
|
vis.setRect(0, 0, width, 1);
|
||||||
|
customTiles.add(vis);
|
||||||
|
|
||||||
|
vis = new BorderWallsDarken();
|
||||||
|
vis.setRect(0, 0, width, height);
|
||||||
|
customWalls.add(vis);
|
||||||
|
|
||||||
return visuals;
|
return visuals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+50
-3
@@ -25,11 +25,13 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Patch;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Patch;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||||
import com.watabou.utils.PathFinder;
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class MiningLevelPainter extends CavesPainter {
|
public class MiningLevelPainter extends CavesPainter {
|
||||||
|
|
||||||
@@ -80,7 +82,7 @@ public class MiningLevelPainter extends CavesPainter {
|
|||||||
//fill in only the exposed potential gold cells...
|
//fill in only the exposed potential gold cells...
|
||||||
for (int i : goldPosCandidates){
|
for (int i : goldPosCandidates){
|
||||||
if (map[i] == Terrain.WALL) {
|
if (map[i] == Terrain.WALL) {
|
||||||
map[i] = Terrain.BARRICADE;
|
map[i] = Terrain.WALL_DECO;
|
||||||
goldToAdd--;
|
goldToAdd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +90,7 @@ public class MiningLevelPainter extends CavesPainter {
|
|||||||
for (int k : PathFinder.NEIGHBOURS4){
|
for (int k : PathFinder.NEIGHBOURS4){
|
||||||
if (!level.insideMap(i+k)) continue;
|
if (!level.insideMap(i+k)) continue;
|
||||||
if (goldToAdd > 0 && goldPosCandidates.contains(i+k) && map[i+k] == Terrain.WALL){
|
if (goldToAdd > 0 && goldPosCandidates.contains(i+k) && map[i+k] == Terrain.WALL){
|
||||||
map[i+k] = Terrain.BARRICADE;
|
map[i+k] = Terrain.WALL_DECO;
|
||||||
goldToAdd--;
|
goldToAdd--;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -104,7 +106,7 @@ public class MiningLevelPainter extends CavesPainter {
|
|||||||
for (int k : PathFinder.NEIGHBOURS4){
|
for (int k : PathFinder.NEIGHBOURS4){
|
||||||
if (!level.insideMap(i+k)) continue;
|
if (!level.insideMap(i+k)) continue;
|
||||||
if (goldToAdd > 0 && gold[i+k] && map[i+k] == Terrain.WALL){
|
if (goldToAdd > 0 && gold[i+k] && map[i+k] == Terrain.WALL){
|
||||||
map[i+k] = Terrain.BARRICADE;
|
map[i+k] = Terrain.WALL_DECO;
|
||||||
goldToAdd--;
|
goldToAdd--;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -130,4 +132,49 @@ public class MiningLevelPainter extends CavesPainter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintDoors(Level l, ArrayList<Room> rooms) {
|
||||||
|
|
||||||
|
HashMap<Room, Room> roomMerges = new HashMap<>();
|
||||||
|
|
||||||
|
//add door types are empty, except secret, which becomes wall
|
||||||
|
for (Room r : rooms) {
|
||||||
|
for (Room n : r.connected.keySet()) {
|
||||||
|
|
||||||
|
//normal sized rooms can be merged at most once. Large and Giant rooms can be merged many times
|
||||||
|
if (roomMerges.get(r) == n || roomMerges.get(n) == r){
|
||||||
|
continue;
|
||||||
|
} else if (!roomMerges.containsKey(r) && !roomMerges.containsKey(n) &&
|
||||||
|
mergeRooms(l, r, n, r.connected.get(n), Terrain.EMPTY)) {
|
||||||
|
if (((StandardRoom) r).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(r, n);
|
||||||
|
if (((StandardRoom) n).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(n, r);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Room.Door d = r.connected.get(n);
|
||||||
|
int door = d.x + d.y * l.width();
|
||||||
|
|
||||||
|
//TODO should be more purposeful about this
|
||||||
|
if (Random.Int(2) == 0 || d.type == Room.Door.Type.HIDDEN){
|
||||||
|
l.map[door] = Terrain.WALL;
|
||||||
|
} else {
|
||||||
|
l.map[door] = Terrain.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void decorate(Level level, ArrayList<Room> rooms) {
|
||||||
|
super.decorate(level, rooms);
|
||||||
|
|
||||||
|
//no chasms allowed, replace with ground!
|
||||||
|
for (int i = 0; i < level.length(); i++){
|
||||||
|
if (level.map[i] == Terrain.CHASM){
|
||||||
|
level.map[i] = Terrain.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user