diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java b/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java index e9fdff730..024e58f61 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Assets.java @@ -33,6 +33,7 @@ public class Assets { public static final String HP_BAR = "hp_bar.png"; public static final String XP_BAR = "exp_bar.png"; public static final String TOOLBAR = "toolbar.png"; + public static final String SHADOW = "shadow.png"; public static final String WARRIOR = "warrior.png"; public static final String MAGE = "mage.png"; @@ -83,7 +84,9 @@ public class Assets { public static final String TROLL = "blacksmith.png"; public static final String IMP = "demon.png"; public static final String RATKING = "ratking.png"; - + public static final String BEE = "bee.png"; + public static final String MIMIC = "mimic.png"; + public static final String ITEMS = "items.png"; public static final String PLANTS = "plants.png"; @@ -157,4 +160,7 @@ public class Assets { public static final String SND_GHOST = "snd_ghost.mp3"; public static final String SND_SECRET = "snd_secret.mp3"; public static final String SND_BONES = "snd_bones.mp3"; + public static final String SND_BEE = "snd_bee.mp3"; + public static final String SND_DEGRADE = "snd_degrade.mp3"; + public static final String SND_MIMIC = "snd_mimic.mp3"; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java index 379312430..68e00504d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java @@ -45,6 +45,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; +import com.watabou.utils.Callback; public class Badges { @@ -168,7 +169,9 @@ public class Badges { private static HashSet local = new HashSet(); private static boolean saveNeeded = false; - + + public static Callback loadingListener = null; + public static void reset() { local.clear(); loadGlobal(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java b/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java index c43672f64..55f15f132 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Challenges.java @@ -25,18 +25,20 @@ public class Challenges { public static final int NO_HERBALISM = 8; public static final int SWARM_INTELLIGENCE = 16; public static final int DARKNESS = 32; + public static final int NO_SCROLLS = 64; public static final String[] NAMES = { - "No food", - "No armors", - "No healing potions", - "No dew, no seeds", - "Swarm intelligence", - "Darkness" + "On diet", + "Faith is my armor", + "Pharmacophobia", + "Barren land", + "Swarm intelligence", + "Into darkness", + "Forbidden runes" }; public static final int[] MASKS = { - NO_FOOD, NO_ARMOR, NO_HEALING, NO_HERBALISM, SWARM_INTELLIGENCE, DARKNESS + NO_FOOD, NO_ARMOR, NO_HEALING, NO_HERBALISM, SWARM_INTELLIGENCE, DARKNESS, NO_SCROLLS }; } \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index dc5c9f3a4..d5689c804 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -75,59 +75,7 @@ import java.util.Date; import java.util.HashSet; public class Dungeon { - - private static final String NO_TIPS = "The text is indecipherable..."; - private static final String[] TIPS = { - "Almost all equipment has a strength requirement. Don't overestimate your strength, using equipment you can't " + - "handle has big penalties!\n\nRaising your strength is not the only way to access better equipment, " + - "you can also lower equipment strength requirements with Scrolls of Upgrade.\n\n\n" + - "Items found in the dungeon will often be unidentified. Some items will have unknown effects, others " + - "may be upgraded, or degraded and cursed! Unidentified items are unpredictable, so be careful!", - "Charging forward recklessly is a great way to get killed.\n\n" + - "Slowing down a bit to examine enemies and use the environment and items to your advantage can make a" + - " big difference.\n\nThe dungeon is full of traps and hidden passageways as well, keep your eyes open!", - "Levelling up is important!\n\nBeing at least the same level as the floor you are on is a good idea. " + - "Don't be afraid to slow down a little and train yourself up.", - "The rogue isn't the only character that benefits from being sneaky. You can retreat to the other side of a " + - "door to ambush a chasing opponent for a guaranteed hit!" + - "\n\nAny attack on an unaware opponent is guaranteed to hit them.", - - "Note to all sewer maintenance & cleaning crews: TURN BACK NOW. Some sort of sludge monster has made its home" + - " here and several crews have been lost trying to deal with it.\n\n" + - "Approval has been given to seal off the lower sewers, this area has been condemned, LEAVE NOW.", - - "Pixel-Mart - all you need for successful adventure!", - "Identify your potions and scrolls as soon as possible. Don't put it off to the moment " + - "when you actually need them.", - "Being hungry doesn't hurt, but starving does hurt.", - "Surprise attack has a better chance to hit. For example, you can ambush your enemy behind " + - "a closed door when you know it is approaching.", - - "Don't let The Tengu out!", - - "Pixel-Mart. Spend money. Live longer.", - "When you're attacked by several monsters at the same time, try to retreat behind a door.", - "If you are burning, you can't put out the fire in the water while levitating.", - "There is no sense in possessing more than one unblessed Ankh at the same time, " + - "because you will lose them upon resurrecting.", - - "DANGER! Heavy machinery can cause injury, loss of limbs or death!", - - "Pixel-Mart. A safer life in dungeon.", - "When you upgrade an enchanted weapon, there is a chance to destroy that enchantment.", - "In a Well of Transmutation you can get an item, that cannot be obtained otherwise.", - "The only way to enchant a weapon is by upgrading it with a Scroll of Weapon Upgrade.", - - "No weapons allowed in the presence of His Majesty!", - - "Pixel-Mart. Special prices for demon hunters!", - "The text is written in demonic language.", - "The text is written in demonic language.", - "The text is written in demonic language." - }; - - private static final String TXT_DEAD_END = - "What are you doing here?!"; + public static boolean dewVial; // true if the dew vial can be spawned public static int transmutation; // depth number for a well of transmutation @@ -314,24 +262,6 @@ public class Dungeon { switchLevel( level, level.entrance ); } - public static String tip() { - - if (level instanceof DeadEndLevel) { - - return TXT_DEAD_END; - - } else { - - int index = depth - 1; - - if (index < TIPS.length) { - return TIPS[index]; - } else { - return NO_TIPS; - } - } - } - public static boolean shopOnLevel() { return depth == 6 || depth == 11 || depth == 16; } @@ -392,7 +322,7 @@ public class Dungeon { return chance( quota, limitedDrops.strengthPotions.count ); } - public static boolean soeNeeded() { + public static boolean souNeeded() { int[] quota = {5, 3, 10, 6, 15, 9, 20, 12, 25, 13}; return chance( quota, limitedDrops.upgradeScrolls.count ); } @@ -547,8 +477,8 @@ public class Dungeon { saveGame( gameFile( hero.heroClass ) ); saveLevel(); - GamesInProgress.set( hero.heroClass, depth, hero.lvl ); - + GamesInProgress.set( hero.heroClass, depth, hero.lvl, challenges != 0 ); + } else if (WndResurrect.instance != null) { WndResurrect.instance.hide(); @@ -688,6 +618,7 @@ public class Dungeon { public static void preview( GamesInProgress.Info info, Bundle bundle ) { info.depth = bundle.getInt( DEPTH ); + info.challenges = (bundle.getInt( CHALLENGES ) != 0); if (info.depth == -1) { info.depth = bundle.getInt( "maxDepth" ); // FIXME } @@ -703,6 +634,8 @@ public class Dungeon { public static void win( String desc ) { + hero.belongings.identify(); + if (challenges != 0) { Badges.validateChampion(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java b/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java index a212b5907..1bb4c71c3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/GamesInProgress.java @@ -51,11 +51,12 @@ public class GamesInProgress { } } - - public static void set( HeroClass cl, int depth, int level ) { + + public static void set( HeroClass cl, int depth, int level, boolean challenges ) { Info info = new Info(); info.depth = depth; info.level = level; + info.challenges = challenges; state.put( cl, info ); } @@ -70,5 +71,6 @@ public class GamesInProgress { public static class Info { public int depth; public int level; + public boolean challenges; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Rankings.java b/src/com/shatteredpixel/shatteredpixeldungeon/Rankings.java index c555342bb..d6167f7df 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Rankings.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Rankings.java @@ -44,7 +44,8 @@ public enum Rankings { public ArrayList records; public int lastRecord; public int totalNumber; - + public int wonNumber; + public void submit( boolean win ) { load(); @@ -91,7 +92,10 @@ public enum Rankings { } totalNumber++; - + if (win) { + wonNumber++; + } + Badges.validateGamesPlayed(); save(); @@ -104,13 +108,15 @@ public enum Rankings { private static final String RECORDS = "records"; private static final String LATEST = "latest"; private static final String TOTAL = "total"; - + private static final String WON = "won"; + public void save() { Bundle bundle = new Bundle(); bundle.put( RECORDS, records ); bundle.put( LATEST, lastRecord ); bundle.put( TOTAL, totalNumber ); - + bundle.put( WON, wonNumber ); + try { OutputStream output = Game.instance.openFileOutput( RANKINGS_FILE, Game.MODE_PRIVATE ); Bundle.write( bundle, output ); @@ -142,7 +148,17 @@ public enum Rankings { totalNumber = records.size(); } + wonNumber = bundle.getInt( WON ); + if (wonNumber == 0) { + for (Record rec : records) { + if (rec.win) { + wonNumber++; + } + } + } + } catch (IOException e) { + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 16e6affbe..9ee1c4246 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -37,15 +37,20 @@ public class ShatteredPixelDungeon extends Game { public ShatteredPixelDungeon() { super( TitleScene.class ); - /* - // 1.7.2 - com.watabou.utils.Bundle.addAlias( - com.shatteredpixel.shatteredpixeldungeon.plants.Dreamweed.class, - "com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed" ); - com.watabou.utils.Bundle.addAlias( - com.shatteredpixel.shatteredpixeldungeon.plants.Dreamweed.Seed.class, - "com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed$Seed" ); - */ + + // 0.2.4 + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shock.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Piercing" ); + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shock.class, + "com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Swing" ); + /* If I rename scroll of weapon upgrade, uncomment this and correct it. + com.watabou.utils.Bundle.addAlias( + com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfEnchantment.class, + "com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade" ); + */ + } @SuppressWarnings("deprecation") @@ -75,6 +80,55 @@ public class ShatteredPixelDungeon extends Game { Music.INSTANCE.enable( music() ); Sample.INSTANCE.enable( soundFx() ); + + Sample.INSTANCE.load( + Assets.SND_CLICK, + Assets.SND_BADGE, + Assets.SND_GOLD, + + Assets.SND_DESCEND, + Assets.SND_STEP, + Assets.SND_WATER, + Assets.SND_OPEN, + Assets.SND_UNLOCK, + Assets.SND_ITEM, + Assets.SND_DEWDROP, + Assets.SND_HIT, + Assets.SND_MISS, + Assets.SND_EAT, + Assets.SND_READ, + Assets.SND_LULLABY, + Assets.SND_DRINK, + Assets.SND_SHATTER, + Assets.SND_ZAP, + Assets.SND_LIGHTNING, + Assets.SND_LEVELUP, + Assets.SND_DEATH, + Assets.SND_CHALLENGE, + Assets.SND_CURSED, + Assets.SND_EVOKE, + Assets.SND_TRAP, + Assets.SND_TOMB, + Assets.SND_ALERT, + Assets.SND_MELD, + Assets.SND_BOSS, + Assets.SND_BLAST, + Assets.SND_PLANT, + Assets.SND_RAY, + Assets.SND_BEACON, + Assets.SND_TELEPORT, + Assets.SND_CHARMS, + Assets.SND_MASTERY, + Assets.SND_PUFF, + Assets.SND_ROCKS, + Assets.SND_BURNING, + Assets.SND_FALLING, + Assets.SND_GHOST, + Assets.SND_SECRET, + Assets.SND_BONES, + Assets.SND_BEE, + Assets.SND_DEGRADE, + Assets.SND_MIMIC ); } @Override @@ -142,16 +196,21 @@ public class ShatteredPixelDungeon extends Game { @SuppressLint("NewApi") public static void updateImmersiveMode() { if (android.os.Build.VERSION.SDK_INT >= 19) { - instance.getWindow().getDecorView().setSystemUiVisibility( - immersed() ? - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - : - 0 ); + try { + // Sometime NullPointerException happens here + instance.getWindow().getDecorView().setSystemUiVisibility( + immersed() ? + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + : + 0 ); + } catch (Exception e) { + reportException( e ); + } } } @@ -241,8 +300,8 @@ public class ShatteredPixelDungeon extends Game { /* * <--- Preferences */ - - public static void reportException( Exception e ) { - Log.e( "PD", Log.getStackTraceString( e ) ); + + public static void reportException( Throwable tr ) { + Log.e("PD", Log.getStackTraceString(tr)); } } \ No newline at end of file