v2.2.0: implemented a bunch of baseline logic for the mining area
This commit is contained in:
@@ -27,13 +27,16 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.BranchesBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.FigureEightBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.MiningLevelPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineEntrance;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineGiantRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineLargeRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineSecretRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineSmallRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
||||
@@ -52,23 +55,37 @@ public class MiningLevel extends CavesLevel {
|
||||
ArrayList<Room> initRooms = new ArrayList<>();
|
||||
initRooms.add ( roomEntrance = new MineEntrance());
|
||||
|
||||
//currently spawns 10-12 cave rooms, of any size
|
||||
int rooms = Random.NormalIntRange(10, 12);
|
||||
//spawns 1 giant, 3-4 large, and 5-8 regular cave rooms
|
||||
StandardRoom s;
|
||||
s = new MineGiantRoom();
|
||||
s.setSizeCat();
|
||||
initRooms.add(s);
|
||||
|
||||
int rooms = Random.NormalIntRange(3, 4);
|
||||
for (int i = 0; i < rooms; i++){
|
||||
StandardRoom s;
|
||||
do {
|
||||
s = new CaveRoom();
|
||||
} while (!s.setSizeCat( 8 ));
|
||||
//i += s.sizeCat.roomValue-1;
|
||||
s = new MineLargeRoom();
|
||||
s.setSizeCat();
|
||||
initRooms.add(s);
|
||||
}
|
||||
|
||||
rooms = Random.NormalIntRange(8, 10);
|
||||
for (int i = 0; i < rooms; i++){
|
||||
s = new MineSmallRoom();
|
||||
s.setSizeCat();
|
||||
initRooms.add(s);
|
||||
}
|
||||
|
||||
rooms = Random.NormalIntRange(1, 2);
|
||||
for (int i = 0; i < rooms; i++){
|
||||
initRooms.add(new MineSecretRoom());
|
||||
}
|
||||
|
||||
return initRooms;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder builder() {
|
||||
return new BranchesBuilder().setTunnelLength(new float[]{1}, new float[]{1});
|
||||
return new FigureEightBuilder().setPathLength(0.8f, new float[]{1}).setTunnelLength(new float[]{1}, new float[]{1});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,8 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Patch;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||
import com.watabou.utils.Graph;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
@@ -135,31 +135,47 @@ 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
|
||||
float hiddenDoorChance = 0.90f;
|
||||
|
||||
//hidden doors become wall tiles
|
||||
//(maybe sometimes become gold ore?)
|
||||
//everything else becomes empty
|
||||
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){
|
||||
if (d.type == Room.Door.Type.HIDDEN){
|
||||
l.map[door] = Terrain.WALL;
|
||||
} else {
|
||||
l.map[door] = Terrain.EMPTY;
|
||||
//some of these are randomly hidden, using the same rules as regular levels
|
||||
if (Random.Float() < hiddenDoorChance) {
|
||||
d.type = Room.Door.Type.HIDDEN;
|
||||
Graph.buildDistanceMap(rooms, r);
|
||||
if (n.distance == Integer.MAX_VALUE){
|
||||
l.map[door] = Terrain.EMPTY;
|
||||
d.type = Room.Door.Type.EMPTY;
|
||||
} else {
|
||||
l.map[door] = Terrain.WALL;
|
||||
}
|
||||
} else {
|
||||
l.map[door] = Terrain.EMPTY;
|
||||
d.type = Room.Door.Type.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if the door is empty, always merge the rooms
|
||||
if (l.map[door] == Terrain.EMPTY){
|
||||
if (roomMerges.get(r) == n || roomMerges.get(n) == r){
|
||||
continue;
|
||||
} else if (mergeRooms(l, r, n, r.connected.get(n), Terrain.EMPTY)) {
|
||||
roomMerges.put(r, n);
|
||||
roomMerges.put(n, r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class MineEntrance extends EntranceRoom {
|
||||
|
||||
int entrance;
|
||||
do {
|
||||
entrance = level.pointToCell(random(2));
|
||||
entrance = level.pointToCell(random(3));
|
||||
} while (level.findMob(entrance) != null || level.map[entrance] == Terrain.WALL);
|
||||
Painter.set( level, entrance, Terrain.ENTRANCE );
|
||||
|
||||
@@ -76,7 +76,7 @@ public class MineEntrance extends EntranceRoom {
|
||||
0,
|
||||
LevelTransition.Type.BRANCH_EXIT));
|
||||
|
||||
//TODO add pre-quest decorations here
|
||||
//TODO add per-quest decorations here
|
||||
}
|
||||
|
||||
public static class QuestExit extends CustomTilemap {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2023 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.rooms.quest;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||
|
||||
public class MineGiantRoom extends CaveRoom {
|
||||
|
||||
@Override
|
||||
public float[] sizeCatProbs() {
|
||||
return new float[]{0, 0, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float fill() {
|
||||
return 0.70f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Level level) {
|
||||
super.paint(level);
|
||||
|
||||
//TODO per-quest details here
|
||||
|
||||
Painter.fillEllipse(level, this, 3, Terrain.EMPTY);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2023 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.rooms.quest;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||
|
||||
public class MineLargeRoom extends CaveRoom {
|
||||
|
||||
@Override
|
||||
public float[] sizeCatProbs() {
|
||||
return new float[]{0, 1, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float fill() {
|
||||
int scale = Math.min(width()*height(), 18*18);
|
||||
return 0.55f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Level level) {
|
||||
super.paint(level);
|
||||
|
||||
//TODO per-quest details here
|
||||
|
||||
Painter.fillEllipse(level, this, 3, Terrain.EMPTY);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2023 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.rooms.quest;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
||||
|
||||
public class MineSecretRoom extends SecretRoom {
|
||||
|
||||
@Override
|
||||
public int minWidth() { return 6; }
|
||||
|
||||
@Override
|
||||
public int minHeight() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Level level) {
|
||||
Painter.fill( level, this, Terrain.WALL );
|
||||
Painter.fill( level, this, 1, Terrain.EMPTY );
|
||||
|
||||
entrance().set( Door.Type.HIDDEN );
|
||||
|
||||
//TODO refine this
|
||||
Painter.fill( level, this, 2, Terrain.WALL_DECO );
|
||||
Painter.fill( level, this, 3, Terrain.WALL );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2023 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.rooms.quest;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||
|
||||
public class MineSmallRoom extends CaveRoom {
|
||||
|
||||
@Override
|
||||
public int minWidth() { return Math.max(6, super.minWidth()); }
|
||||
|
||||
@Override
|
||||
public int minHeight() { return Math.max(6, super.minHeight()); }
|
||||
|
||||
@Override
|
||||
public float[] sizeCatProbs() {
|
||||
return new float[]{1, 0, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float fill() {
|
||||
return 0.40f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Level level) {
|
||||
super.paint(level);
|
||||
|
||||
//TODO per-quest details here
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user