v0.6.2: implement new secret room logic.
Specific secret room implementations are still needed
This commit is contained in:
parent
a5df5e9b5b
commit
4a8373246b
|
@ -55,6 +55,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonBossLevel;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.SewerBossLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.SewerLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
|
@ -199,6 +200,7 @@ public class Dungeon {
|
|||
Ring.initGems();
|
||||
|
||||
SpecialRoom.initForRun();
|
||||
SecretRoom.initForRun();
|
||||
|
||||
Random.seed();
|
||||
|
||||
|
@ -520,6 +522,7 @@ public class Dungeon {
|
|||
bundle.put( QUESTS, quests );
|
||||
|
||||
SpecialRoom.storeRoomsInBundle( bundle );
|
||||
SecretRoom.storeRoomsInBundle( bundle );
|
||||
|
||||
Statistics.storeInBundle( bundle );
|
||||
Notes.storeInBundle( bundle );
|
||||
|
@ -635,6 +638,7 @@ public class Dungeon {
|
|||
}
|
||||
|
||||
SpecialRoom.restoreRoomsFromBundle(bundle);
|
||||
SecretRoom.restoreRoomsFromBundle(bundle);
|
||||
}
|
||||
|
||||
Bundle badges = bundle.getBundle(BADGES);
|
||||
|
|
|
@ -78,7 +78,18 @@ public class ShatteredPixelDungeon extends Game {
|
|||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation.class,
|
||||
"com.shatteredpixel.shatteredpixeldungeon.items.food.OverpricedRation" );
|
||||
|
||||
|
||||
//v0.6.2
|
||||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.RatKingRoom.class,
|
||||
"com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RatKingRoom" );
|
||||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.PlantsRoom.class,
|
||||
"com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.GardenRoom" );
|
||||
com.watabou.utils.Bundle.addAlias(
|
||||
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.GardenRoom.class,
|
||||
"com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.FoliageRoom" );
|
||||
|
||||
com.watabou.utils.Bundle.exceptionReporter =
|
||||
new com.watabou.utils.Bundle.BundleExceptionCallback() {
|
||||
@Override
|
||||
|
@ -86,7 +97,7 @@ public class ShatteredPixelDungeon extends Game {
|
|||
ShatteredPixelDungeon.reportException(t);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LoopBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||
|
@ -109,6 +110,10 @@ public abstract class RegularLevel extends Level {
|
|||
for (int i = 0; i < specials; i++)
|
||||
initRooms.add(SpecialRoom.createRoom());
|
||||
|
||||
int secrets = SecretRoom.secretsForFloor(Dungeon.depth);
|
||||
for (int i = 0; i < secrets; i++)
|
||||
initRooms.add(SecretRoom.createRoom());
|
||||
|
||||
return initRooms;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LoopBuilder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RatKingRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.RatKingRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.SewerBossEntranceRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
|
|
|
@ -23,6 +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.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;
|
||||
|
@ -135,8 +137,13 @@ public abstract class RegularBuilder extends Builder {
|
|||
float[] connectionChances = connChances.clone();
|
||||
while (i < roomsToBranch.size()){
|
||||
|
||||
Room r = roomsToBranch.get(i);
|
||||
|
||||
connectingRoomsThisBranch.clear();
|
||||
curr = Random.element(branchable);
|
||||
|
||||
do {
|
||||
curr = Random.element(branchable);
|
||||
} while( r instanceof SecretRoom && curr instanceof ConnectionRoom);
|
||||
|
||||
int connectingRooms = Random.chances(connectionChances);
|
||||
if (connectingRooms == -1){
|
||||
|
@ -146,7 +153,7 @@ public abstract class RegularBuilder extends Builder {
|
|||
connectionChances[connectingRooms]--;
|
||||
|
||||
for (int j = 0; j < connectingRooms; j++){
|
||||
ConnectionRoom t = ConnectionRoom.createRoom();
|
||||
ConnectionRoom t = r instanceof SecretRoom ? new SecretTunnelRoom() : ConnectionRoom.createRoom();
|
||||
tries = 3;
|
||||
|
||||
do {
|
||||
|
@ -155,9 +162,9 @@ public abstract class RegularBuilder extends Builder {
|
|||
} while (angle == -1 && tries > 0);
|
||||
|
||||
if (angle == -1) {
|
||||
for (Room r : connectingRoomsThisBranch){
|
||||
r.clearConnections();
|
||||
rooms.remove(r);
|
||||
for (Room c : connectingRoomsThisBranch){
|
||||
c.clearConnections();
|
||||
rooms.remove(c);
|
||||
}
|
||||
connectingRoomsThisBranch.clear();
|
||||
break;
|
||||
|
@ -173,8 +180,6 @@ public abstract class RegularBuilder extends Builder {
|
|||
continue;
|
||||
}
|
||||
|
||||
Room r = roomsToBranch.get(i);
|
||||
|
||||
tries = 10;
|
||||
|
||||
do {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.RatKing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
||||
|
@ -29,15 +29,15 @@ 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.Room;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.SewerBossEntranceRoom;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class RatKingRoom extends SpecialRoom {
|
||||
public class RatKingRoom extends SecretRoom {
|
||||
|
||||
@Override
|
||||
public boolean canConnect(Room r) {
|
||||
//never at the end of a connection room, or at the entrance
|
||||
return r instanceof EmptyRoom && super.canConnect(r);
|
||||
//never connects at the entrance
|
||||
return !(r instanceof SewerBossEntranceRoom) && super.canConnect(r);
|
||||
}
|
||||
|
||||
//reduced max size to limit chest numbers.
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Foliage;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
//TODO specific implementation
|
||||
public class SecretGardenRoom extends SecretRoom {
|
||||
|
||||
public void paint( Level level ) {
|
||||
|
||||
Painter.fill( level, this, Terrain.WALL );
|
||||
Painter.fill( level, this, 1, Terrain.HIGH_GRASS );
|
||||
Painter.fill( level, this, 2, Terrain.GRASS );
|
||||
|
||||
entrance().set( Door.Type.HIDDEN );
|
||||
|
||||
if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
|
||||
level.plant(new Sungrass.Seed(), plantPos(level));
|
||||
} else {
|
||||
level.plant(new BlandfruitBush.Seed(), plantPos(level));
|
||||
}
|
||||
|
||||
level.plant(new WandOfRegrowth.Seedpod.Seed(), plantPos( level ));
|
||||
level.plant(new WandOfRegrowth.Dewcatcher.Seed(), plantPos( level ));
|
||||
|
||||
if (Random.Int(2) == 0){
|
||||
level.plant(new WandOfRegrowth.Seedpod.Seed(), plantPos( level ));
|
||||
} else {
|
||||
level.plant(new WandOfRegrowth.Dewcatcher.Seed(), plantPos( level ));
|
||||
}
|
||||
|
||||
Foliage light = (Foliage)level.blobs.get( Foliage.class );
|
||||
if (light == null) {
|
||||
light = new Foliage();
|
||||
}
|
||||
for (int i=top + 1; i < bottom; i++) {
|
||||
for (int j=left + 1; j < right; j++) {
|
||||
light.seed( level, j + level.width() * i, 1 );
|
||||
}
|
||||
}
|
||||
level.blobs.put( Foliage.class, light );
|
||||
}
|
||||
|
||||
private int plantPos( Level level ){
|
||||
int pos;
|
||||
do{
|
||||
pos = level.pointToCell(random());
|
||||
} while (level.plants.get(pos) != null);
|
||||
return pos;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
//TODO specific implementation
|
||||
public class SecretLaboratoryRoom extends SecretRoom {
|
||||
|
||||
private static HashMap<Class<? extends Potion>, Float> potionChances = new HashMap<>();
|
||||
static{
|
||||
potionChances.put(PotionOfHealing.class, 2f);
|
||||
potionChances.put(PotionOfExperience.class, 4f);
|
||||
potionChances.put(PotionOfToxicGas.class, 1f);
|
||||
potionChances.put(PotionOfParalyticGas.class, 2f);
|
||||
potionChances.put(PotionOfLiquidFlame.class, 1f);
|
||||
potionChances.put(PotionOfLevitation.class, 1f);
|
||||
potionChances.put(PotionOfStrength.class, 0f);
|
||||
potionChances.put(PotionOfMindVision.class, 2f);
|
||||
potionChances.put(PotionOfPurity.class, 2f);
|
||||
potionChances.put(PotionOfInvisibility.class, 1f);
|
||||
potionChances.put(PotionOfMight.class, 0f);
|
||||
potionChances.put(PotionOfFrost.class, 1f);
|
||||
}
|
||||
|
||||
public void paint( Level level ) {
|
||||
|
||||
Painter.fill( level, this, Terrain.WALL );
|
||||
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
|
||||
|
||||
Door entrance = entrance();
|
||||
|
||||
Point pot = null;
|
||||
if (entrance.x == left) {
|
||||
pot = new Point( right-1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
|
||||
} else if (entrance.x == right) {
|
||||
pot = new Point( left+1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
|
||||
} else if (entrance.y == top) {
|
||||
pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 );
|
||||
} else if (entrance.y == bottom) {
|
||||
pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+1 );
|
||||
}
|
||||
Painter.set( level, pot, Terrain.ALCHEMY );
|
||||
|
||||
Alchemy alchemy = new Alchemy();
|
||||
alchemy.seed( level, pot.x + level.width() * pot.y, Random.IntRange(40, 75) );
|
||||
level.blobs.put( Alchemy.class, alchemy );
|
||||
|
||||
int n = Random.IntRange( 3, 4 );
|
||||
HashMap<Class<? extends Potion>, Float> chances = new HashMap<>(potionChances);
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = level.pointToCell(random());
|
||||
} while (
|
||||
level.map[pos] != Terrain.EMPTY_SP ||
|
||||
level.heaps.get( pos ) != null);
|
||||
level.drop( prize( level ), pos );
|
||||
}
|
||||
|
||||
entrance.set( Door.Type.HIDDEN );
|
||||
}
|
||||
|
||||
private static Item prize(Level level ) {
|
||||
|
||||
Item prize = level.findPrizeItem( Potion.class );
|
||||
if (prize == null)
|
||||
prize = Generator.random( Generator.Category.POTION );
|
||||
|
||||
return prize;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
//TODO specific implementation
|
||||
public class SecretLibraryRoom extends SecretRoom {
|
||||
|
||||
public void paint( Level level ) {
|
||||
|
||||
Painter.fill( level, this, Terrain.WALL );
|
||||
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
|
||||
|
||||
Door entrance = entrance();
|
||||
|
||||
Painter.fill( level, left + 1, top+1, width() - 2, 1 , Terrain.BOOKSHELF );
|
||||
Painter.drawInside(level, this, entrance, 1, Terrain.EMPTY_SP );
|
||||
|
||||
int n = Random.IntRange( 2, 3 );
|
||||
for (int i=0; i < n; i++) {
|
||||
int pos;
|
||||
do {
|
||||
pos = level.pointToCell(random());
|
||||
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get( pos ) != null);
|
||||
Item item;
|
||||
if (i == 0)
|
||||
item = Random.Int(2) == 0 ? new ScrollOfIdentify() : new ScrollOfRemoveCurse();
|
||||
else
|
||||
item = prize( level );
|
||||
level.drop( item, pos );
|
||||
}
|
||||
|
||||
entrance.set( Door.Type.HIDDEN );
|
||||
|
||||
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
|
||||
}
|
||||
|
||||
private static Item prize( Level level ) {
|
||||
|
||||
Item prize = level.findPrizeItem( Scroll.class );
|
||||
if (prize == null)
|
||||
prize = Generator.random( Generator.Category.SCROLL );
|
||||
|
||||
return prize;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public abstract class SecretRoom extends SpecialRoom {
|
||||
|
||||
|
||||
private static final ArrayList<Class<? extends SecretRoom>> ALL_SECRETS = new ArrayList<>( Arrays.asList(
|
||||
SecretGardenRoom.class, SecretLaboratoryRoom.class, SecretLibraryRoom.class));
|
||||
|
||||
public static ArrayList<Class<? extends SecretRoom>> runSecrets = new ArrayList<>();
|
||||
|
||||
//this is the number of secret rooms per region (whole value),
|
||||
// plus the chance for an extra secret room (fractional value)
|
||||
private static float[] baseRegionSecrets = new float[]{1.4f, 1.8f, 2.2f, 2.6f, 3.0f};
|
||||
private static int[] regionSecretsThisRun = new int[5];
|
||||
|
||||
public static void initForRun(){
|
||||
|
||||
float[] regionChances = baseRegionSecrets.clone();
|
||||
|
||||
/*if (StartScene.curClass == HeroClass.ROGUE){
|
||||
for (int i = 0; i < regionChances.length; i++){
|
||||
regionChances[i] += 0.6f;
|
||||
}
|
||||
}*/
|
||||
|
||||
for (int i = 0; i < regionSecretsThisRun.length; i++){
|
||||
regionSecretsThisRun[i] = (int)regionChances[i];
|
||||
if (Random.Float() < regionChances[i] % 1f){
|
||||
regionSecretsThisRun[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
runSecrets = new ArrayList<>(ALL_SECRETS);
|
||||
Random.shuffle(runSecrets);
|
||||
|
||||
}
|
||||
|
||||
public static int secretsForFloor(int depth){
|
||||
if (depth == 1) return 0;
|
||||
|
||||
int region = depth/5;
|
||||
int floor = depth%5;
|
||||
|
||||
int floorsLeft = 5 - floor;
|
||||
|
||||
float secrets;
|
||||
if (floorsLeft == 0) {
|
||||
secrets = regionSecretsThisRun[region];
|
||||
} else {
|
||||
secrets = regionSecretsThisRun[region] / floorsLeft;
|
||||
if (Random.Float() < secrets % 1f){
|
||||
secrets = (float)Math.ceil(secrets);
|
||||
} else {
|
||||
secrets = (float)Math.floor(secrets);
|
||||
}
|
||||
}
|
||||
|
||||
regionSecretsThisRun[region] -= (int)secrets;
|
||||
return (int)secrets;
|
||||
}
|
||||
|
||||
public static SecretRoom createRoom(){
|
||||
|
||||
SecretRoom r = null;
|
||||
int index = runSecrets.size();
|
||||
for (int i = 0; i < 4; i++){
|
||||
int newidx = Random.Int( runSecrets.size() );
|
||||
if (newidx < index) index = newidx;
|
||||
}
|
||||
try {
|
||||
r = runSecrets.get( index ).newInstance();
|
||||
} catch (Exception e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
}
|
||||
|
||||
runSecrets.add(runSecrets.remove(index));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static final String ROOMS = "secret_rooms";
|
||||
private static final String REGIONS = "region_secrets";
|
||||
|
||||
public static void restoreRoomsFromBundle( Bundle bundle ) {
|
||||
runSecrets.clear();
|
||||
if (bundle.contains( ROOMS )) {
|
||||
for (Class<? extends SecretRoom> type : bundle.getClassArray(ROOMS)) {
|
||||
if (type != null) runSecrets.add(type);
|
||||
}
|
||||
} else {
|
||||
initForRun();
|
||||
ShatteredPixelDungeon.reportException(new Exception("secrets array didn't exist!"));
|
||||
}
|
||||
regionSecretsThisRun = bundle.getIntArray(REGIONS);
|
||||
}
|
||||
|
||||
public static void storeRoomsInBundle( Bundle bundle ) {
|
||||
bundle.put( ROOMS, runSecrets.toArray(new Class[0]) );
|
||||
bundle.put( REGIONS, regionSecretsThisRun );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class FoliageRoom extends SpecialRoom {
|
||||
public class GardenRoom extends SpecialRoom {
|
||||
|
||||
public void paint( Level level ) {
|
||||
|
||||
|
@ -43,22 +43,17 @@ public class FoliageRoom extends SpecialRoom {
|
|||
|
||||
if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
|
||||
if (Random.Int(2) == 0){
|
||||
level.plant(new Sungrass.Seed(), level.pointToCell(random()));
|
||||
level.plant(new Sungrass.Seed(), plantPos( level ));
|
||||
}
|
||||
} else {
|
||||
int bushes = Random.Int(3);
|
||||
if (bushes == 0) {
|
||||
level.plant(new Sungrass.Seed(), level.pointToCell(random()));
|
||||
level.plant(new Sungrass.Seed(), plantPos( level ));
|
||||
} else if (bushes == 1) {
|
||||
level.plant(new BlandfruitBush.Seed(), level.pointToCell(random()));
|
||||
level.plant(new BlandfruitBush.Seed(), plantPos( level ));
|
||||
} else if (Random.Int(5) == 0) {
|
||||
int plant1, plant2;
|
||||
plant1 = level.pointToCell(random());
|
||||
level.plant(new Sungrass.Seed(), plant1);
|
||||
do {
|
||||
plant2 = level.pointToCell(random());
|
||||
} while (plant2 == plant1);
|
||||
level.plant(new BlandfruitBush.Seed(), plant2);
|
||||
level.plant(new Sungrass.Seed(), plantPos( level ));
|
||||
level.plant(new BlandfruitBush.Seed(), plantPos( level ));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,4 +68,12 @@ public class FoliageRoom extends SpecialRoom {
|
|||
}
|
||||
level.blobs.put( Foliage.class, light );
|
||||
}
|
||||
|
||||
private int plantPos( Level level ){
|
||||
int pos;
|
||||
do{
|
||||
pos = level.pointToCell(random());
|
||||
} while (level.plants.get(pos) != null);
|
||||
return pos;
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ public class SpecialRoom extends Room {
|
|||
}
|
||||
|
||||
private static final ArrayList<Class<? extends SpecialRoom>> ALL_SPEC = new ArrayList<>( Arrays.asList(
|
||||
WeakFloorRoom.class, MagicWellRoom.class, CryptRoom.class, PoolRoom.class, FoliageRoom.class, LibraryRoom.class, ArmoryRoom.class,
|
||||
WeakFloorRoom.class, MagicWellRoom.class, CryptRoom.class, PoolRoom.class, GardenRoom.class, LibraryRoom.class, ArmoryRoom.class,
|
||||
TreasuryRoom.class, TrapsRoom.class, StorageRoom.class, StatueRoom.class, LaboratoryRoom.class, VaultRoom.class
|
||||
) );
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class SpecialRoom extends Room {
|
|||
}
|
||||
if (Dungeon.isChallenged( Challenges.NO_HERBALISM )){
|
||||
//Would be a bit mean to spawn these with no plants in them
|
||||
runSpecials.remove( FoliageRoom.class );
|
||||
runSpecials.remove( GardenRoom.class );
|
||||
}
|
||||
|
||||
pitNeededDepth = -1;
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
|||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class GardenRoom extends StandardRoom {
|
||||
public class PlantsRoom extends StandardRoom {
|
||||
|
||||
@Override
|
||||
public int minWidth() {
|
|
@ -132,7 +132,7 @@ public abstract class StandardRoom extends Room {
|
|||
rooms.add(SkullsRoom.class);
|
||||
|
||||
|
||||
rooms.add(GardenRoom.class);
|
||||
rooms.add(PlantsRoom.class);
|
||||
rooms.add(AquariumRoom.class);
|
||||
rooms.add(PlatformRoom.class);
|
||||
rooms.add(BurnedRoom.class);
|
||||
|
|
Loading…
Reference in New Issue
Block a user