From 161a67b8e185b4fb2a38cf35fc71289cb7bf1ae3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 22 Jun 2023 17:27:57 -0400 Subject: [PATCH] v2.1.3: added basic mining and sub-floor functionality! --- core/src/main/assets/sounds/mine.mp3 | Bin 0 -> 4896 bytes .../shatteredpixeldungeon/Assets.java | 3 +- .../shatteredpixeldungeon/Dungeon.java | 12 ++ .../actors/hero/Hero.java | 59 +++++++++- .../actors/hero/HeroAction.java | 6 + .../levels/MiningLevel.java | 105 ++++++++++++++++++ .../levels/rooms/standard/BlacksmithRoom.java | 18 +++ .../scenes/GameScene.java | 4 + .../tiles/WallBlockingTilemap.java | 6 +- 9 files changed, 209 insertions(+), 4 deletions(-) create mode 100644 core/src/main/assets/sounds/mine.mp3 create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java diff --git a/core/src/main/assets/sounds/mine.mp3 b/core/src/main/assets/sounds/mine.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..5586120af7b5cd78e952fb68e9794b3a62ceb360 GIT binary patch literal 4896 zcmc)M`9Boe`vCAWV`hwftPNQPV@)--7>Titec!k2#+t3-qK0gP7;8h+*lMgH71h1g zgvgSl;-<)cCA6uJ`8J==_kXzO*Yi5B^L{yTSg{&@Vbf zPTnPMWRnb#yuoa`=?#<=+aOaWbH?+a>VfNj@FJPAc+|bWh%#nvn?li+`+gq5$k)D0 z^q?25V~Av=DBVZB&bDvZlKI=i2{`(c;@6eJq`5}i;}_^9xYQ{fRYAAFNB;nb3pADPCdVoS59qg z`GOa2^q|dekM4Z_MyU|y2iCUSbyJ&?aN%wdt-2~B3qLy*yK^k zr!!SnxR94R=}Ds@%Z=`r2B!Bqb2rkD$QAAM2bU7kD(PUD<$(eAVb5@49f`V2YZ2e$ zh>dW(&Zxh&tX+J!Fq@BKR+}OOX@3waXK$8=O?e-KbmNi1VFe{nsm~gE*Q!G*;_Zp* zxNli6&A>Ghbf`C5|CP!o=e@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jpCgr7RDmVHnKML_LCmxf0{BVMLpI2Hv5tsKIgLH_Pq)XfX%FVyQ%>z+c}Rdg(9dSIZD4pQUzxO@*JTdXTJMyR?R&QmX+NB9 zz2qLY1EKzC`%cI{Fo@v7E5WQnm8ZjAoKudxA}D-henH>s ziGpH)P#0jAJi)i>KMmz8tx`aR%?T}9unBUiywHl4y!Qn$LhIp}@tuWA(Bj0k#St-i9J&Q~zYC9xmDyF4K=spwvP~-^aVU z)Mq8VX@u6ve=d;g=2WkJUg{|F6CI-dvxyPb3x+{CL^Jb=U6_Ir%M%X}&1V9B&xc)a zvl`Zh(298Fwg&AdyT0bP#UE`1o(a1&sPz_8e?`oLYyJMske35qV+B8QO;8-89BEhL zcH++nuz!gA==YW~IA`VVvX^!(A`seN5|C=m;ldboV&uotyEWrdO%P8y<**8bZuQDm z%I8`5Ov3MOGLAI<_;;zfVr6{Fce5sw;X;-t34&m_8>^@)AgA*ie&=gZBO88+gN^sc zn;Z7&S*b?Od@pxv5TF)Ew#csFG3j$vny)BUIb2~VDr#7MAGR{E zHc>yJio-SjUM$ZQvMIybQ63$Y@RCP?QO1pDZTw4%<;f)@@spqlobAa1SSF{(3 + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Bones; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.items.Heap; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom; + +public class MiningLevel extends Level { + + { + color1 = 0x534f3e; + color2 = 0xb9d661; + } + + @Override + public String tilesTex() { + return Assets.Environment.TILES_CAVES; + } + + @Override + public String waterTex() { + return Assets.Environment.WATER_CAVES; + } + + @Override + protected boolean build() { + + //a few niceties are needed here before putting this out, things like water, short grass + // tile deco, and a pause to hunger/regen + + 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; + + return true; + } + + @Override + public Mob createMob() { + return null; + } + + @Override + protected void createMobs() { + } + + public Actor addRespawner() { + return null; + } + + @Override + protected void createItems() { + Item item = Bones.get(); + if (item != null) { + drop( item, entrance()-width() ).setHauntedIfCursed().type = Heap.Type.REMAINS; + } + } + + @Override + public int randomRespawnCell( Char ch ) { + return entrance()-width(); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BlacksmithRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BlacksmithRoom.java index 7b41b18be..2a60e8b4e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BlacksmithRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/BlacksmithRoom.java @@ -21,10 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.BurningTrap; import com.watabou.utils.Point; @@ -72,6 +74,22 @@ public class BlacksmithRoom extends StandardRoom { } while (level.heaps.get( npc.pos ) != null); level.mobs.add( npc ); + // TODO need to add some better visuals here (even just a simple custom asset) + Random.pushGenerator(Dungeon.seedCurDepth()+1); + int entrancePos; + do { + entrancePos = level.pointToCell(random( 2 )); + } while (level.heaps.get( npc.pos ) != null || entrancePos == npc.pos); + Random.popGenerator(); + + level.transitions.add(new LevelTransition(level, + entrancePos, + LevelTransition.Type.BRANCH_EXIT, + Dungeon.depth, + Dungeon.branch+1, + LevelTransition.Type.BRANCH_ENTRANCE)); + Painter.set(level, entrancePos, Terrain.EXIT); + for(Point p : getPoints()) { int cell = level.pointToCell(p); if (level.map[cell] == Terrain.TRAP){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 53b4f0b06..a513397d2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -60,6 +60,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportat import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Journal; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.MiningLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; @@ -428,6 +429,9 @@ public class GameScene extends PixelScene { break; } } + if (Dungeon.level instanceof MiningLevel){ + add(new WndStory(Messages.get(this, "blacksmith_quest_window_title") + ":\n\n" + Messages.get(this, "blacksmith_quest_window")).setDelays(0.6f, 1.4f)); + } if (Dungeon.hero.isAlive()) { Badges.validateNoKilling(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/WallBlockingTilemap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/WallBlockingTilemap.java index 75b334a52..0a998a2f3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/WallBlockingTilemap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/WallBlockingTilemap.java @@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.tiles; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.HallsBossLevel; +import com.shatteredpixel.shatteredpixeldungeon.levels.MiningLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.watabou.noosa.TextureFilm; import com.watabou.noosa.Tilemap; @@ -107,9 +108,10 @@ public class WallBlockingTilemap extends Tilemap { //- none of the remaining 5 neighbour cells are both not a wall and visible //if all 3 above are wall we can shortcut and just clear the cell - //unless one or more is a shelf, then we have to just block none + //unless one or more is a shelf, or we can mine, then we have to just block none if (wall(cell - 1 - mapWidth) && wall(cell - mapWidth) && wall(cell + 1 - mapWidth)){ - if (shelf(cell - 1 - mapWidth) || shelf(cell - mapWidth) || shelf(cell + 1 - mapWidth)){ + if (shelf(cell - 1 - mapWidth) || shelf(cell - mapWidth) + || shelf(cell + 1 - mapWidth) || Dungeon.level instanceof MiningLevel){ curr = BLOCK_NONE; } else { curr = CLEARED;