From e4d001713706b86dac2a58a9c7574af5485fd964 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 20 Jan 2015 16:49:55 -0500 Subject: [PATCH] v0.2.3e: reworked night mode into a level feeling --- .../shatteredpixeldungeon/Dungeon.java | 4 ---- .../shatteredpixeldungeon/actors/mobs/Mob.java | 2 +- .../shatteredpixeldungeon/levels/Level.java | 17 +++++++++++++++-- .../shatteredpixeldungeon/scenes/GameScene.java | 10 +++++----- .../scenes/SurfaceScene.java | 3 ++- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 9e057794b..b3a7d847e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -169,8 +169,6 @@ public class Dungeon { // Hero's field of view public static boolean[] visible = new boolean[Level.LENGTH]; - - public static boolean nightMode; public static int version; @@ -349,8 +347,6 @@ public class Dungeon { @SuppressWarnings("deprecation") public static void switchLevel( final Level level, int pos ) { - nightMode = new Date().getHours() < 7; - Dungeon.level = level; Actor.init(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 7a7190229..71fd3a0ee 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -382,7 +382,7 @@ public abstract class Mob extends Char { Badges.validateMonstersSlain(); Statistics.qualifiedForNoKilling = false; - if (Dungeon.nightMode) { + if (Dungeon.level.feeling == Feeling.DARK) { Statistics.nightHunt++; } else { Statistics.nightHunt = 0; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index b642bdab6..3c4b8a6f7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -42,6 +42,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Stylus; +import com.shatteredpixel.shatteredpixeldungeon.items.Torch; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; @@ -84,7 +85,8 @@ public abstract class Level implements Bundlable { NONE, CHASM, WATER, - GRASS + GRASS, + DARK }; public static final int WIDTH = 32; @@ -172,6 +174,7 @@ public abstract class Level implements Bundlable { private static final String MOBS = "mobs"; private static final String BLOBS = "blobs"; private static final String FALLING = "falling"; + private static final String FEELING = "feeling"; public void create() { @@ -240,6 +243,11 @@ public abstract class Level implements Bundlable { case 2: feeling = Feeling.GRASS; break; + case 3: + feeling = Feeling.DARK; + addItemToSpawn(new Torch()); + viewDistance = (int)Math.ceil(viewDistance/3f); + break; } } } @@ -330,6 +338,10 @@ public abstract class Level implements Bundlable { } fallingItems = (ArrayList)bundle.getCollection( FALLING ); + + feeling = bundle.getEnum( FEELING, Feeling.class ); + if (feeling == Feeling.DARK) + viewDistance = (int)Math.ceil(viewDistance/3f); buildFlagMaps(); cleanWalls(); @@ -348,6 +360,7 @@ public abstract class Level implements Bundlable { bundle.put( MOBS, mobs ); bundle.put( BLOBS, blobs.values() ); bundle.put( FALLING, fallingItems); + bundle.put( FEELING, feeling ); } public int tunnelTile() { @@ -435,7 +448,7 @@ public abstract class Level implements Bundlable { } } } - spend( Dungeon.nightMode || Statistics.amuletObtained ? TIME_TO_RESPAWN / 2 : TIME_TO_RESPAWN ); + spend( Dungeon.level.feeling == Feeling.DARK || Statistics.amuletObtained ? TIME_TO_RESPAWN / 2 : TIME_TO_RESPAWN ); return true; } }; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 36f6e4524..c741e1b69 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -73,11 +73,11 @@ public class GameScene extends PixelScene { private static final String TXT_WELCOME = "Welcome to the level %d of Pixel Dungeon!"; private static final String TXT_WELCOME_BACK = "Welcome back to the level %d of Pixel Dungeon!"; - private static final String TXT_NIGHT_MODE = "Be cautious, since the dungeon is even more dangerous at night!"; private static final String TXT_CHASM = "Your steps echo across the dungeon."; private static final String TXT_WATER = "You hear water splashing around you."; private static final String TXT_GRASS = "The smell of vegetation is thick in the air."; + private static final String TXT_DARK = "You can hear enemies moving in the darkness..."; private static final String TXT_SECRETS = "The atmosphere hints that this floor hides many secrets."; static GameScene scene; @@ -240,16 +240,16 @@ public class GameScene extends PixelScene { case GRASS: GLog.w( TXT_GRASS ); break; + case DARK: + GLog.w( TXT_DARK ); + break; default: } if (Dungeon.level instanceof RegularLevel && ((RegularLevel)Dungeon.level).secretDoors > Random.IntRange( 3, 4 )) { GLog.w( TXT_SECRETS ); } - if (Dungeon.nightMode && !Dungeon.bossLevel()) { - GLog.w( TXT_NIGHT_MODE ); - } - + busy = new BusyIndicator(); busy.camera = uiCamera; busy.x = 1; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java index 514075a69..42e524d53 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/SurfaceScene.java @@ -18,6 +18,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import java.nio.FloatBuffer; +import java.util.Calendar; import com.watabou.gltextures.Gradient; import com.watabou.gltextures.SmartTexture; @@ -82,7 +83,7 @@ public class SurfaceScene extends PixelScene { window.camera = viewport; add( window ); - boolean dayTime = !Dungeon.nightMode; + boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7; Sky sky = new Sky( dayTime ); sky.scale.set( WIDTH, HEIGHT );