From cdad2fa5e053a34aa212712ef693c6cc72f49c15 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 26 Sep 2017 21:34:08 -0400 Subject: [PATCH] v0.6.2: more secret room implementation --- .../levels/builders/RegularBuilder.java | 4 +- .../rooms/connection/MazeConnectionRoom.java | 7 +- .../rooms/secret/SecretHoneypotRoom.java | 75 ++++++++++++++++ .../levels/rooms/secret/SecretLarderRoom.java | 3 +- .../levels/rooms/secret/SecretRoom.java | 4 +- .../rooms/secret/SecretRunestoneRoom.java | 88 +++++++++++++++++++ .../levels/rooms/secret/SecretTunnelRoom.java | 44 ---------- 7 files changed, 175 insertions(+), 50 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretHoneypotRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRunestoneRoom.java delete mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretTunnelRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java index 1fbaad7c9..ba6c81516 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java @@ -23,8 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.builders; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.MazeConnectionRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretTunnelRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom; @@ -153,7 +153,7 @@ public abstract class RegularBuilder extends Builder { connectionChances[connectingRooms]--; for (int j = 0; j < connectingRooms; j++){ - ConnectionRoom t = r instanceof SecretRoom ? new SecretTunnelRoom() : ConnectionRoom.createRoom(); + ConnectionRoom t = r instanceof SecretRoom ? new MazeConnectionRoom() : ConnectionRoom.createRoom(); tries = 3; do { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/MazeConnectionRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/MazeConnectionRoom.java index 785e0a312..7c961a828 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/MazeConnectionRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/MazeConnectionRoom.java @@ -46,7 +46,12 @@ public class MazeConnectionRoom extends ConnectionRoom { } for (Door door : connected.values()) { - door.set( Door.Type.TUNNEL ); + door.set( Door.Type.HIDDEN ); } } + + @Override + public int maxConnections(int direction) { + return 2; + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretHoneypotRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretHoneypotRoom.java new file mode 100644 index 000000000..07a02b5cf --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretHoneypotRoom.java @@ -0,0 +1,75 @@ +/* + * 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 + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret; + +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee; +import com.shatteredpixel.shatteredpixeldungeon.items.Bomb; +import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.watabou.utils.Point; +import com.watabou.utils.Random; + +public class SecretHoneypotRoom extends SecretRoom { + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + Painter.fill(level, this, 1, Terrain.EMPTY ); + + Point center = center(); + + Honeypot.ShatteredPot pot = new Honeypot.ShatteredPot(); + level.drop(pot, level.pointToCell(center)); + + Bee bee = new Bee(); + bee.spawn( Dungeon.depth ); + bee.HP = bee.HT; + bee.pos = level.pointToCell(center); + level.mobs.add( bee ); + + pot.setBee(bee); + bee.setPotInfo(level.pointToCell(center), null); + + placeItem(new Honeypot(), level); + + placeItem( Random.Int(3) == 0 ? new Bomb.DoubleBomb() : new Bomb(), level); + + if (Random.Int(2) == 0){ + placeItem( new Bomb(), level); + } + + entrance().set(Door.Type.HIDDEN); + } + + private void placeItem(Item item, Level level){ + int itemPos; + do { + itemPos = level.pointToCell(random()); + } while (level.heaps.get(itemPos) != null); + + level.drop(item, itemPos); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java index 1d63808f3..a3d4caacb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretLarderRoom.java @@ -55,8 +55,7 @@ public class SecretLarderRoom extends SecretRoom { @Override public void paint(Level level) { - super.paint(level); - + Painter.fill(level, this, Terrain.WALL); Painter.fill(level, this, 1, Terrain.EMPTY_SP); int nFood = width()-2; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRoom.java index 1a8625574..fd9c5762d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRoom.java @@ -36,7 +36,9 @@ public abstract class SecretRoom extends SpecialRoom { private static final ArrayList> ALL_SECRETS = new ArrayList<>( Arrays.asList( - SecretGardenRoom.class, SecretLaboratoryRoom.class, SecretLibraryRoom.class, SecretLarderRoom.class, SecretTransmutationRoom.class)); + SecretGardenRoom.class, SecretLaboratoryRoom.class, SecretLibraryRoom.class, + SecretLarderRoom.class, SecretTransmutationRoom.class, SecretRunestoneRoom.class, + SecretHoneypotRoom.class)); public static ArrayList> runSecrets = new ArrayList<>(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRunestoneRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRunestoneRoom.java new file mode 100644 index 000000000..69476cfe8 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretRunestoneRoom.java @@ -0,0 +1,88 @@ +/* + * 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 + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret; + +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.watabou.utils.Point; +import com.watabou.utils.Random; + +public class SecretRunestoneRoom extends SecretRoom { + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + Painter.fill(level, this, 1, Terrain.EMPTY); + + Door entrance = entrance(); + Point center = center(); + + if (entrance.x == left || entrance.x == right){ + Painter.drawLine(level, + new Point(center.x, top+1), + new Point(center.x, bottom-1), + Terrain.BOOKSHELF); + if (entrance.x == left) { + Painter.fill(level, center.x+1, top+1, right-center.x-1, height()-2, Terrain.EMPTY_SP); + } else { + Painter.fill(level, left+1, top+1, center.x-left-1, height()-2, Terrain.EMPTY_SP); + } + } else { + Painter.drawLine(level, + new Point(left+1, center.y), + new Point(right-1, center.y), + Terrain.BOOKSHELF); + if (entrance.y == top) { + Painter.fill(level, left+1, center.y+1, width()-2, bottom-center.y-1, Terrain.EMPTY_SP); + } else { + Painter.fill(level, left+1, top+1, width()-2, center.y-top-1, Terrain.EMPTY_SP); + } + } + + level.addItemToSpawn(new PotionOfLiquidFlame()); + + int runeStones = Random.NormalIntRange(2, 4); + for (int i = 0; i - */ - -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret; - -import com.shatteredpixel.shatteredpixeldungeon.levels.Level; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.TunnelRoom; - - -public class SecretTunnelRoom extends TunnelRoom { - - @Override - public int maxConnections(int direction) { - return 2; - } - - @Override - public void paint(Level level) { - super.paint(level); - - for (Door door : connected.values()) { - door.set( Door.Type.HIDDEN ); - } - } - -}