From 44245c5a75aba546769497c6c8ac034d7b5ed295 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 16 May 2017 15:53:46 -0400 Subject: [PATCH] v0.6.0: added two new standard rooms: garden and aquarium --- .../levels/rooms/standard/AquariumRoom.java | 71 ++++++++++++ .../levels/rooms/standard/EmptyRoom.java | 4 +- .../levels/rooms/standard/GardenRoom.java | 104 ++++++++++++++++++ .../levels/rooms/standard/StandardRoom.java | 19 ++-- 4 files changed, 190 insertions(+), 8 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/AquariumRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GardenRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/AquariumRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/AquariumRoom.java new file mode 100644 index 000000000..8b0c44d96 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/AquariumRoom.java @@ -0,0 +1,71 @@ +/* + * 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.standard; + +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; + +public class AquariumRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 7); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 7); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{3, 1, 0}; + } + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); + Painter.fill( level, this, 2, Terrain.EMPTY_SP ); + Painter.fill( level, this, 3, Terrain.WATER ); + + int minDim = Math.min(width(), height()); + int numFish = (minDim - 4)/3; //1-3 fish, depending on room size + + for (int i=0; i < numFish; i++) { + Piranha piranha = new Piranha(); + do { + piranha.pos = level.pointToCell(random(3)); + } while (level.map[piranha.pos] != Terrain.WATER|| level.findMob( piranha.pos ) != null); + level.mobs.add( piranha ); + } + + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); + } + + super.paint(level); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java index 03a22d24c..72ebf0b89 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EmptyRoom.java @@ -30,8 +30,10 @@ public class EmptyRoom extends StandardRoom { @Override public void paint(Level level) { Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1 , Terrain.EMPTY ); + for (Door door : connected.values()) { door.set( Door.Type.REGULAR ); - }Painter.fill( level, this, 1 , Terrain.EMPTY ); + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GardenRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GardenRoom.java new file mode 100644 index 000000000..f2fafaf36 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/GardenRoom.java @@ -0,0 +1,104 @@ +/* + * 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.standard; + +import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; +import com.watabou.utils.Point; +import com.watabou.utils.Random; + +public class GardenRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(super.minWidth(), 5); + } + + @Override + public int minHeight() { + return Math.max(super.minHeight(), 5); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{3, 1, 0}; + } + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.GRASS ); + Painter.fill( level, this, 2, Terrain.HIGH_GRASS ); + + if (Math.min(width(), height()) >= 7){ + Painter.fill( level, this, 3, Terrain.GRASS ); + } + + Point center = center(); + + //place at least 2 plants for rooms with at least 9 in one dimensions + if (Math.max(width(), height()) >= 9){ + + //place 4 plants for very large rooms + if (Math.min(width(), height()) >= 11) { + Painter.drawLine(level, new Point(left+2, center.y), new Point(right-2, center.y), Terrain.HIGH_GRASS); + Painter.drawLine(level, new Point(center.x, top+2), new Point(center.x, bottom-2), Terrain.HIGH_GRASS); + level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y-1))); + level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y-1))); + level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y+1))); + level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y+1))); + + //place 2 plants otherwise + //left/right + } else if (width() > height() || (width() == height() && Random.Int(2) == 0)){ + Painter.drawLine(level, new Point(center.x, top+2), new Point(center.x, bottom-2), Terrain.HIGH_GRASS); + level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y))); + level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y))); + + //top/bottom + } else { + Painter.drawLine(level, new Point(left+2, center.y), new Point(right-2, center.y), Terrain.HIGH_GRASS); + level.plant( randomSeed(), level.pointToCell(new Point(center.x, center.y-1))); + level.plant( randomSeed(), level.pointToCell(new Point(center.x, center.y+1))); + + } + + //place just one plant for smaller sized rooms + } else { + level.plant( randomSeed(), level.pointToCell(center)); + } + + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); + } + + super.paint(level); + } + + //TODO: sungrass, blandfruit, and starflower seeds can grow here, perhaps that's too good. + private static Plant.Seed randomSeed(){ + return (Plant.Seed) Generator.random(Generator.Category.SEED); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index 2178568b9..84a32c961 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -113,14 +113,19 @@ public abstract class StandardRoom extends Room { private static HashMap, Float> chances = new LinkedHashMap<>(); static { - chances.put(EmptyRoom.class, 24f); + //currently effective average room size value is 1.15916 + chances.put(EmptyRoom.class, 24f);//average value: 1.0000, +.00000 overall - chances.put(PlatformRoom.class, 1f); - chances.put(BurnedRoom.class, 1f); - chances.put(FissureRoom.class, 1f); - chances.put(GrassyGraveRoom.class, 1f); - chances.put(StripedRoom.class, 1f); - chances.put(StudyRoom.class, 1f); + chances.put(RingRoom.class, 8f); //average value: 1.5000, +.10000 overall + + chances.put(GardenRoom.class, 1f); //average value: 1.2500, +.00625 overall + chances.put(AquariumRoom.class, 1f); //average value: 1.2500, +.00625 overall + chances.put(PlatformRoom.class, 1f); //average value: 1.5000, +.01250 overall + chances.put(BurnedRoom.class, 1f); //average value: 1.2000, +.00500 overall + chances.put(FissureRoom.class, 1f); //average value: 1.5000, +.01250 overall + chances.put(GrassyGraveRoom.class, 1f); //average value: 1.0000, +.00000 overall + chances.put(StripedRoom.class, 1f); //average value: 1.3333, +.00833 overall + chances.put(StudyRoom.class, 1f); //average value: 1.3333, +.00833 overall } public static StandardRoom createRoom(){