diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 38e4c43ddb..c941f22f1c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,15 +1,15 @@ + android:minSdkVersion="9" + android:targetSdkVersion="20"/> @@ -25,6 +25,7 @@ android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:allowBackup="false"> + - - - - - diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml deleted file mode 100644 index a91fd0372b..0000000000 --- a/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/res/values/strings.xml b/res/values/strings.xml index 632a9f6ee9..b81e1a4a95 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,4 +3,4 @@ Pixel Dungeon - \ No newline at end of file + diff --git a/res/values/styles.xml b/res/values/styles.xml deleted file mode 100644 index 6ce89c7ba4..0000000000 --- a/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/src/com/watabou/pixeldungeon/Assets.java b/src/com/watabou/pixeldungeon/Assets.java index 7ad4b01b1f..d4c6061d14 100644 --- a/src/com/watabou/pixeldungeon/Assets.java +++ b/src/com/watabou/pixeldungeon/Assets.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -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,6 +84,8 @@ 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/watabou/pixeldungeon/Badges.java b/src/com/watabou/pixeldungeon/Badges.java index ea575b0148..dbba628ff1 100644 --- a/src/com/watabou/pixeldungeon/Badges.java +++ b/src/com/watabou/pixeldungeon/Badges.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -46,6 +46,7 @@ import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.utils.GLog; import com.watabou.utils.Bundle; +import com.watabou.utils.Callback; public class Badges { @@ -75,7 +76,7 @@ public static enum Badge { DEATH_FROM_POISON( "Death from poison", 25 ), DEATH_FROM_GAS( "Death from toxic gas", 26 ), DEATH_FROM_HUNGER( "Death from hunger", 27 ), - DEATH_FROM_GLYPH( "Death from a glyph", 57 ), + DEATH_FROM_GLYPH( "Death from an enchantment", 57 ), DEATH_FROM_FALLING( "Death from falling down", 59 ), YASD( "Death from fire, poison, toxic gas & hunger", 34, true ), BOSS_SLAIN_1_WARRIOR, @@ -169,6 +170,8 @@ private Badge() { private static boolean saveNeeded = false; + public static Callback loadingListener = null; + public static void reset() { local.clear(); loadGlobal(); @@ -225,9 +228,12 @@ public static void loadGlobal() { } public static void saveGlobal() { + + Bundle bundle = null; + if (saveNeeded) { - Bundle bundle = new Bundle(); + bundle = new Bundle(); store( bundle, global ); try { @@ -393,9 +399,9 @@ public static void validatePiranhasKilled() { public static void validateItemLevelAquired( Item item ) { // This method should be called: - // 1) When an item is obtained (Item.collect) - // 2) When an item is upgraded (ScrollOfUpgrade, ScrollOfWeaponUpgrade, ShortSword, WandOfMagicMissile) - // 3) When an item is identified + // 1) When an item gets obtained (Item.collect) + // 2) When an item gets upgraded (ScrollOfUpgrade, ScrollOfWeaponUpgrade, ShortSword, WandOfMagicMissile) + // 3) When an item gets identified if (!item.levelKnown) { return; } diff --git a/src/com/watabou/pixeldungeon/Bones.java b/src/com/watabou/pixeldungeon/Bones.java index 4114784950..52f8076bfc 100644 --- a/src/com/watabou/pixeldungeon/Bones.java +++ b/src/com/watabou/pixeldungeon/Bones.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/Challenges.java b/src/com/watabou/pixeldungeon/Challenges.java index c0bb978059..6644232e15 100644 --- a/src/com/watabou/pixeldungeon/Challenges.java +++ b/src/com/watabou/pixeldungeon/Challenges.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -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", + "On diet", + "Faith is my armor", + "Pharmacophobia", + "Barren land", "Swarm intelligence", - "Darkness" + "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 }; } diff --git a/src/com/watabou/pixeldungeon/Chrome.java b/src/com/watabou/pixeldungeon/Chrome.java index 2cb5958c33..7a11abbb13 100644 --- a/src/com/watabou/pixeldungeon/Chrome.java +++ b/src/com/watabou/pixeldungeon/Chrome.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -27,7 +27,6 @@ public enum Type { WINDOW, BUTTON, TAG, - GEM, SCROLL, TAB_SET, TAB_SELECTED, @@ -46,8 +45,6 @@ public static NinePatch get( Type type ) { return new NinePatch( Assets.CHROME, 58, 0, 4, 4, 1 ); case TAG: return new NinePatch( Assets.CHROME, 22, 18, 16, 14, 3 ); - case GEM: - return new NinePatch( Assets.CHROME, 0, 32, 32, 32, 13 ); case SCROLL: return new NinePatch( Assets.CHROME, 32, 32, 32, 32, 5, 11, 5, 11 ); case TAB_SET: diff --git a/src/com/watabou/pixeldungeon/Dungeon.java b/src/com/watabou/pixeldungeon/Dungeon.java index c5a0e5963e..ca15741923 100644 --- a/src/com/watabou/pixeldungeon/Dungeon.java +++ b/src/com/watabou/pixeldungeon/Dungeon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -36,6 +37,7 @@ import com.watabou.pixeldungeon.actors.mobs.npcs.Ghost; import com.watabou.pixeldungeon.actors.mobs.npcs.Wandmaker; import com.watabou.pixeldungeon.items.Ankh; +import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.items.potions.Potion; import com.watabou.pixeldungeon.items.rings.Ring; import com.watabou.pixeldungeon.items.scrolls.Scroll; @@ -57,60 +59,21 @@ import com.watabou.pixeldungeon.levels.SewerLevel; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.pixeldungeon.scenes.StartScene; +import com.watabou.pixeldungeon.ui.QuickSlot; import com.watabou.pixeldungeon.utils.BArray; import com.watabou.pixeldungeon.utils.Utils; import com.watabou.pixeldungeon.windows.WndResurrect; +import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; +import com.watabou.utils.SparseArray; public class Dungeon { - private static final String NO_TIPS = "The text is indecipherable..."; - private static final String[] TIPS = { - "Don't overestimate your strength, use weapons and armor you can handle.", - "Not all doors in the dungeon are visible at first sight. If you are stuck, search for hidden doors.", - "Remember, that raising your strength is not the only way to access better equipment, you can go " + - "the other way lowering its strength requirement with Scrolls of Upgrade.", - "You can spend your gold in shops on deeper levels of the dungeon. The first one is on the 6th level.", - - "Beware of Goo!", - - "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 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 int potionOfStrength; public static int scrollsOfUpgrade; - public static int arcaneStyli; + public static int scrollsOfEnchantment; public static boolean dewVial; // true if the dew vial can be spawned public static int transmutation; // depth number for a well of transmutation @@ -119,9 +82,6 @@ public class Dungeon { public static Hero hero; public static Level level; - // Either Item or Class - public static Object quickslot; - public static int depth; public static int gold; // Reason of death @@ -134,6 +94,8 @@ public class Dungeon { public static boolean nightMode; + public static SparseArray> droppedItems; + public static void init() { challenges = PixelDungeon.challenges(); @@ -153,9 +115,11 @@ public static void init() { depth = 0; gold = 0; + droppedItems = new SparseArray>(); + potionOfStrength = 0; scrollsOfUpgrade = 0; - arcaneStyli = 0; + scrollsOfEnchantment = 0; dewVial = true; transmutation = Random.IntRange( 6, 14 ); @@ -168,6 +132,9 @@ public static void init() { Room.shuffleTypes(); + QuickSlot.primaryValue = null; + QuickSlot.secondaryValue = null; + hero = new Hero(); hero.live(); @@ -272,24 +239,6 @@ public static void resetLevel() { 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; } @@ -323,16 +272,29 @@ public static void switchLevel( final Level level, int pos ) { observe(); } + public static void dropToChasm( Item item ) { + int depth = Dungeon.depth + 1; + ArrayList dropped = (ArrayList)Dungeon.droppedItems.get( depth ); + if (dropped == null) { + Dungeon.droppedItems.put( depth, dropped = new ArrayList() ); + } + dropped.add( item ); + } + public static boolean posNeeded() { int[] quota = {4, 2, 9, 4, 14, 6, 19, 8, 24, 9}; return chance( quota, potionOfStrength ); } - public static boolean soeNeeded() { + public static boolean souNeeded() { int[] quota = {5, 3, 10, 6, 15, 9, 20, 12, 25, 13}; return chance( quota, scrollsOfUpgrade ); } + public static boolean soeNeeded() { + return Random.Int( 12 * (1 + scrollsOfEnchantment) ) < depth; + } + private static boolean chance( int[] quota, int number ) { for (int i=0; i < quota.length; i += 2) { @@ -346,10 +308,6 @@ private static boolean chance( int[] quota, int number ) { return false; } - public static boolean asNeeded() { - return Random.Int( 12 * (1 + arcaneStyli) ) < depth; - } - private static final String RG_GAME_FILE = "game.dat"; private static final String RG_DEPTH_FILE = "depth%d.dat"; @@ -367,11 +325,11 @@ public static boolean asNeeded() { private static final String HERO = "hero"; private static final String GOLD = "gold"; private static final String DEPTH = "depth"; - private static final String QUICKSLOT = "quickslot"; private static final String LEVEL = "level"; + private static final String DROPPED = "dropped%d"; private static final String POS = "potionsOfStrength"; private static final String SOU = "scrollsOfEnhancement"; - private static final String AS = "arcaneStyli"; + private static final String SOE = "scrollsOfEnchantment"; private static final String DV = "dewVial"; private static final String WT = "transmutation"; private static final String CHAPTERS = "chapters"; @@ -414,9 +372,13 @@ public static void saveGame( String fileName ) throws IOException { bundle.put( GOLD, gold ); bundle.put( DEPTH, depth ); + for (int d : droppedItems.keyArray()) { + bundle.put( String.format( DROPPED, d ), droppedItems.get( d ) ); + } + bundle.put( POS, potionOfStrength ); bundle.put( SOU, scrollsOfUpgrade ); - bundle.put( AS, arcaneStyli ); + bundle.put( SOE, scrollsOfEnchantment ); bundle.put( DV, dewVial ); bundle.put( WT, transmutation ); @@ -439,9 +401,7 @@ public static void saveGame( String fileName ) throws IOException { Statistics.storeInBundle( bundle ); Journal.storeInBundle( bundle ); - if (quickslot instanceof Class) { - bundle.put( QUICKSLOT, ((Class)quickslot).getName() ); - } + QuickSlot.save( bundle ); Scroll.save( bundle ); Potion.save( bundle ); @@ -478,7 +438,7 @@ public static void saveAll() throws IOException { 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) { @@ -516,7 +476,7 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept potionOfStrength = bundle.getInt( POS ); scrollsOfUpgrade = bundle.getInt( SOU ); - arcaneStyli = bundle.getInt( AS ); + scrollsOfEnchantment = bundle.getInt( SOE ); dewVial = bundle.getBoolean( DV ); transmutation = bundle.getInt( WT ); @@ -552,15 +512,7 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept Badges.reset(); } - String qsClass = bundle.getString( QUICKSLOT ); - if (qsClass != null) { - try { - quickslot = Class.forName( qsClass ); - } catch (ClassNotFoundException e) { - } - } else { - quickslot = null; - } + QuickSlot.restore( bundle ); @SuppressWarnings("unused") String version = bundle.getString( VERSION ); @@ -568,11 +520,24 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept hero = null; hero = (Hero)bundle.get( HERO ); + QuickSlot.compress(); + gold = bundle.getInt( GOLD ); depth = bundle.getInt( DEPTH ); Statistics.restoreFromBundle( bundle ); Journal.restoreFromBundle( bundle ); + + droppedItems = new SparseArray>(); + for (int i=2; i <= Statistics.deepestFloor + 1; i++) { + ArrayList dropped = new ArrayList(); + for (Bundlable b : bundle.getCollection( String.format( DROPPED, i ) ) ) { + dropped.add( (Item)b ); + } + if (!dropped.isEmpty()) { + droppedItems.put( i, dropped ); + } + } } public static Level loadLevel( HeroClass cl ) throws IOException { @@ -612,6 +577,7 @@ public static Bundle gameBundle( String fileName ) throws IOException { 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 } @@ -627,6 +593,8 @@ public static void fail( String desc ) { public static void win( String desc ) { + hero.belongings.identify(); + if (challenges != 0) { Badges.validateChampion(); } diff --git a/src/com/watabou/pixeldungeon/DungeonTilemap.java b/src/com/watabou/pixeldungeon/DungeonTilemap.java index 0cab64d132..8981db017b 100644 --- a/src/com/watabou/pixeldungeon/DungeonTilemap.java +++ b/src/com/watabou/pixeldungeon/DungeonTilemap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/FogOfWar.java b/src/com/watabou/pixeldungeon/FogOfWar.java index 39d51b7b31..723a3e26c1 100644 --- a/src/com/watabou/pixeldungeon/FogOfWar.java +++ b/src/com/watabou/pixeldungeon/FogOfWar.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/GamesInProgress.java b/src/com/watabou/pixeldungeon/GamesInProgress.java index 797170e46a..fdf584c23d 100644 --- a/src/com/watabou/pixeldungeon/GamesInProgress.java +++ b/src/com/watabou/pixeldungeon/GamesInProgress.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -51,10 +51,11 @@ public static Info check( HeroClass cl ) { } } - 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 ); } @@ -69,5 +70,6 @@ public static void delete( HeroClass cl ) { public static class Info { public int depth; public int level; + public boolean challenges; } } diff --git a/src/com/watabou/pixeldungeon/Journal.java b/src/com/watabou/pixeldungeon/Journal.java index 3edf2b4188..d1e636f73b 100644 --- a/src/com/watabou/pixeldungeon/Journal.java +++ b/src/com/watabou/pixeldungeon/Journal.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/LightMap.java b/src/com/watabou/pixeldungeon/LightMap.java new file mode 100644 index 0000000000..950ac09ba0 --- /dev/null +++ b/src/com/watabou/pixeldungeon/LightMap.java @@ -0,0 +1,83 @@ +package com.watabou.pixeldungeon; + +import android.graphics.Bitmap; + +import com.watabou.gltextures.SmartTexture; +import com.watabou.gltextures.TextureCache; +import com.watabou.glwrap.Texture; +import com.watabou.noosa.Image; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.utils.Random; + +public class LightMap extends Image { + + private int[] pixels; + + private int pWidth; + private int pHeight; + + private int width2; + private int height2; + + public LightMap( int mapWidth, int mapHeight ) { + + super(); + + pWidth = mapWidth; + pHeight = mapHeight; + + width2 = 1; + while (width2 < pWidth) { + width2 <<= 1; + } + + height2 = 1; + while (height2 < pHeight) { + height2 <<= 1; + } + + float size = DungeonTilemap.SIZE; + width = width2 * size; + height = height2 * size; + + texture( new FogTexture() ); + + scale.set( + DungeonTilemap.SIZE, + DungeonTilemap.SIZE ); + + updateVisibility(); + } + + public void updateVisibility() { + + if (pixels == null) { + pixels = new int[width2 * height2]; + } + + for (int i=0; i < pixels.length; i++) { + if (Level.water[i]) { + pixels[i] = 0x00000000; + } else { + pixels[i] = (Random.Int( 0x22 ) + (Level.solid[i] ? 0x44 : 0x00)) << 24; + } + } + + texture.pixels( width2, height2, pixels ); + } + + private class FogTexture extends SmartTexture { + + public FogTexture() { + super( Bitmap.createBitmap( width2, height2, Bitmap.Config.ARGB_8888 ) ); + filter( Texture.LINEAR, Texture.LINEAR ); + TextureCache.add( LightMap.class, this ); + } + + @Override + public void reload() { + super.reload(); + updateVisibility(); + } + } +} diff --git a/src/com/watabou/pixeldungeon/PixelDungeon.java b/src/com/watabou/pixeldungeon/PixelDungeon.java index 030650aad3..752e71678a 100644 --- a/src/com/watabou/pixeldungeon/PixelDungeon.java +++ b/src/com/watabou/pixeldungeon/PixelDungeon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -92,6 +92,20 @@ public PixelDungeon() { com.watabou.utils.Bundle.addAlias( com.watabou.pixeldungeon.plants.Dreamweed.Seed.class, "com.watabou.pixeldungeon.plants.Blindweed$Seed" ); + // 1.7.4 + com.watabou.utils.Bundle.addAlias( + com.watabou.pixeldungeon.items.weapon.enchantments.Shock.class, + "com.watabou.pixeldungeon.items.weapon.enchantments.Piercing" ); + com.watabou.utils.Bundle.addAlias( + com.watabou.pixeldungeon.items.weapon.enchantments.Shock.class, + "com.watabou.pixeldungeon.items.weapon.enchantments.Swing" ); + com.watabou.utils.Bundle.addAlias( + com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment.class, + "com.watabou.pixeldungeon.items.scrolls.ScrollOfWeaponUpgrade" ); + // 1.7.5 + com.watabou.utils.Bundle.addAlias( + com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment.class, + "com.watabou.pixeldungeon.items.Stylus" ); } @Override @@ -110,6 +124,55 @@ protected void onCreate( Bundle savedInstanceState ) { 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 @@ -172,16 +235,21 @@ public void onSurfaceChanged( GL10 gl, int width, int height ) { @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 ); + } } } @@ -273,7 +341,7 @@ public static boolean intro() { * <--- 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 diff --git a/src/com/watabou/pixeldungeon/Preferences.java b/src/com/watabou/pixeldungeon/Preferences.java index 5b5764eb72..d10edec1dd 100644 --- a/src/com/watabou/pixeldungeon/Preferences.java +++ b/src/com/watabou/pixeldungeon/Preferences.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -27,6 +27,7 @@ enum Preferences { public static final String KEY_LANDSCAPE = "landscape"; public static final String KEY_IMMERSIVE = "immersive"; + public static final String KEY_GOOGLE_PLAY = "google_play"; public static final String KEY_SCALE_UP = "scaleup"; public static final String KEY_MUSIC = "music"; public static final String KEY_SOUND_FX = "soundfx"; diff --git a/src/com/watabou/pixeldungeon/Rankings.java b/src/com/watabou/pixeldungeon/Rankings.java index 638de2c67e..47083db862 100644 --- a/src/com/watabou/pixeldungeon/Rankings.java +++ b/src/com/watabou/pixeldungeon/Rankings.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -43,6 +43,7 @@ public enum Rankings { public ArrayList records; public int lastRecord; public int totalNumber; + public int wonNumber; public void submit( boolean win ) { @@ -86,6 +87,9 @@ public void submit( boolean win ) { } totalNumber++; + if (win) { + wonNumber++; + } Badges.validateGamesPlayed(); @@ -99,12 +103,14 @@ private int score( boolean win ) { 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 ); @@ -137,6 +143,15 @@ public void load() { totalNumber = records.size(); } + wonNumber = bundle.getInt( WON ); + if (wonNumber == 0) { + for (Record rec : records) { + if (rec.win) { + wonNumber++; + } + } + } + } catch (Exception e) { } } diff --git a/src/com/watabou/pixeldungeon/ResultDescriptions.java b/src/com/watabou/pixeldungeon/ResultDescriptions.java index 27248a0826..a244ce4c29 100644 --- a/src/com/watabou/pixeldungeon/ResultDescriptions.java +++ b/src/com/watabou/pixeldungeon/ResultDescriptions.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ScrollOfDebugging.java b/src/com/watabou/pixeldungeon/ScrollOfDebugging.java new file mode 100644 index 0000000000..8773e3021d --- /dev/null +++ b/src/com/watabou/pixeldungeon/ScrollOfDebugging.java @@ -0,0 +1,47 @@ +package com.watabou.pixeldungeon; + +import java.util.ArrayList; + +import com.watabou.pixeldungeon.actors.hero.Hero; +import com.watabou.pixeldungeon.items.Item; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment; + +public class ScrollOfDebugging extends Item { + + { + name = "Scroll of Debugging"; + image = 40; + } + + public static final String AC_READ = "READ"; + + @Override + public ArrayList actions( Hero hero ) { + ArrayList actions = super.actions( hero ); + actions.add( AC_READ ); + return actions; + } + + @Override + public void execute( Hero hero, String action ) { + if (action.equals( AC_READ )) { + + new ScrollOfEnchantment().collect(); + + } else { + + super.execute( hero, action ); + + } + } + + @Override + public boolean isUpgradable() { + return false; + } + + @Override + public boolean isIdentified() { + return true; + } +} diff --git a/src/com/watabou/pixeldungeon/Statistics.java b/src/com/watabou/pixeldungeon/Statistics.java index 2b74531774..69c79bc373 100644 --- a/src/com/watabou/pixeldungeon/Statistics.java +++ b/src/com/watabou/pixeldungeon/Statistics.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/Actor.java b/src/com/watabou/pixeldungeon/actors/Actor.java index e7c80faced..2f91dd22a1 100644 --- a/src/com/watabou/pixeldungeon/actors/Actor.java +++ b/src/com/watabou/pixeldungeon/actors/Actor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -20,6 +20,8 @@ import java.util.Arrays; import java.util.HashSet; +import android.util.SparseArray; + import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.actors.blobs.Blob; @@ -35,6 +37,8 @@ public abstract class Actor implements Bundlable { private float time; + private int id = 0; + protected abstract boolean act(); protected void spend( float time ) { @@ -59,16 +63,33 @@ protected void onAdd() {} protected void onRemove() {} - private static final String TIME = "time"; + private static final String TIME = "time"; + private static final String ID = "id"; @Override public void storeInBundle( Bundle bundle ) { bundle.put( TIME, time ); + bundle.put( ID, id ); } @Override public void restoreFromBundle( Bundle bundle ) { time = bundle.getFloat( TIME ); + id = bundle.getInt( ID ); + } + + public int id() { + if (id > 0) { + return id; + } else { + int max = 0; + for (Actor a : all) { + if (a.id > max) { + max = a.id; + } + } + return (id = max + 1); + } } // ********************** @@ -77,6 +98,8 @@ public void restoreFromBundle( Bundle bundle ) { private static HashSet all = new HashSet(); private static Actor current; + private static SparseArray ids = new SparseArray(); + private static float now = 0; private static Char[] chars = new Char[Level.LENGTH]; @@ -87,6 +110,8 @@ public static void clear() { Arrays.fill( chars, null ); all.clear(); + + ids.clear(); } public static void fixTime() { @@ -197,8 +222,12 @@ private static void add( Actor actor, float time ) { return; } + if (actor.id > 0) { + ids.put( actor.id, actor ); + } + all.add( actor ); - actor.time += time; // (+=) => (=) ? + actor.time += time; actor.onAdd(); if (actor instanceof Char) { @@ -216,6 +245,10 @@ public static void remove( Actor actor ) { if (actor != null) { all.remove( actor ); actor.onRemove(); + + if (actor.id > 0) { + ids.remove( actor.id ); + } } } @@ -223,6 +256,10 @@ public static Char findChar( int pos ) { return chars[pos]; } + public static Actor findById( int id ) { + return ids.get( id ); + } + public static HashSet all() { return all; } diff --git a/src/com/watabou/pixeldungeon/actors/Char.java b/src/com/watabou/pixeldungeon/actors/Char.java index 60001604ca..65bb59224b 100644 --- a/src/com/watabou/pixeldungeon/actors/Char.java +++ b/src/com/watabou/pixeldungeon/actors/Char.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,9 +17,9 @@ */ package com.watabou.pixeldungeon.actors; -import java.util.ArrayList; import java.util.HashSet; +import com.watabou.noosa.Camera; import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Dungeon; @@ -28,6 +28,7 @@ import com.watabou.pixeldungeon.actors.buffs.Bleeding; import com.watabou.pixeldungeon.actors.buffs.Buff; import com.watabou.pixeldungeon.actors.buffs.Burning; +import com.watabou.pixeldungeon.actors.buffs.Charm; import com.watabou.pixeldungeon.actors.buffs.Vertigo; import com.watabou.pixeldungeon.actors.buffs.Cripple; import com.watabou.pixeldungeon.actors.buffs.Frost; @@ -56,6 +57,7 @@ import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; +import com.watabou.utils.GameMath; import com.watabou.utils.Random; public abstract class Char extends Actor { @@ -81,7 +83,6 @@ public abstract class Char extends Actor { protected float baseSpeed = 1; public boolean paralysed = false; - public boolean pacified = false; public boolean rooted = false; public boolean flying = false; public int invisible = 0; @@ -143,7 +144,7 @@ public boolean attack( Char enemy ) { Random.IntRange( 0, enemy.dr() ); int dmg = damageRoll(); - int effectiveDamage = Math.max( dmg - dr, 0 );; + int effectiveDamage = Math.max( dmg - dr, 0 ); effectiveDamage = attackProc( enemy, effectiveDamage ); effectiveDamage = enemy.defenseProc( this, effectiveDamage ); @@ -155,6 +156,9 @@ public boolean attack( Char enemy ) { if (enemy == Dungeon.hero) { Dungeon.hero.interrupt(); + if (effectiveDamage > enemy.HT / 4) { + Camera.main.shake( GameMath.gate( 1, effectiveDamage / (enemy.HT / 4), 5), 0.3f ); + } } enemy.sprite.bloodBurstA( sprite.center(), effectiveDamage ); @@ -165,11 +169,12 @@ public boolean attack( Char enemy ) { if (Dungeon.hero.killerGlyph != null) { - Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, Dungeon.hero.killerGlyph.name(), Dungeon.depth ) ); - GLog.n( TXT_KILL, Dungeon.hero.killerGlyph.name() ); + // FIXME + // Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, Dungeon.hero.killerGlyph.name(), Dungeon.depth ) ); + // GLog.n( TXT_KILL, Dungeon.hero.killerGlyph.name() ); } else { - if (Bestiary.isUnique( this )) { + if (Bestiary.isBoss( this )) { Dungeon.fail( Utils.format( ResultDescriptions.BOSS, name, Dungeon.depth ) ); } else { Dungeon.fail( Utils.format( ResultDescriptions.MOB, @@ -333,6 +338,15 @@ public T buff( Class c ) { return null; } + public boolean isCharmedBy( Char ch ) { + int chID = ch.id(); + for (Buff b : buffs) { + if (b instanceof Charm && ((Charm)b).object == chID) { + return true; + } + } + return false; + } public void add( Buff buff ) { @@ -426,6 +440,8 @@ public void remove( Class buffClass ) { } } + + @Override protected void onRemove() { for (Buff buff : buffs.toArray( new Buff[0] )) { @@ -457,16 +473,11 @@ public int stealth() { public void move( int step ) { - if (buff( Vertigo.class ) != null) { - ArrayList candidates = new ArrayList(); - for (int dir : Level.NEIGHBOURS8) { - int p = pos + dir; - if ((Level.passable[p] || Level.avoid[p]) && Actor.findChar( p ) == null) { - candidates.add( p ); - } + if (Level.adjacent( step, pos ) && buff( Vertigo.class ) != null) { + step = pos + Level.NEIGHBOURS8[Random.Int( 8 )]; + if (!(Level.passable[step] || Level.avoid[step]) || Actor.findChar( step ) != null) { + return; } - - step = Random.element( candidates ); } if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) { diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Alchemy.java b/src/com/watabou/pixeldungeon/actors/blobs/Alchemy.java index fc02374af6..14a11541e1 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Alchemy.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Alchemy.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Blob.java b/src/com/watabou/pixeldungeon/actors/blobs/Blob.java index f92db95370..d53cbdec9e 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Blob.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Blob.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/ConfusionGas.java b/src/com/watabou/pixeldungeon/actors/blobs/ConfusionGas.java index 49e03d1bfe..4e35baf341 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/ConfusionGas.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/ConfusionGas.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Fire.java b/src/com/watabou/pixeldungeon/actors/blobs/Fire.java index 79fe55a98e..7d5fc266fa 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Fire.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Fire.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Foliage.java b/src/com/watabou/pixeldungeon/actors/blobs/Foliage.java index f6099c31a3..5f7b47772a 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Foliage.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Foliage.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Freezing.java b/src/com/watabou/pixeldungeon/actors/blobs/Freezing.java index 9ec2aeccbd..2b52332e25 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Freezing.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Freezing.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -28,10 +28,9 @@ import com.watabou.utils.Random; public class Freezing { - - // It's not really a blob... - public static void affect( int cell, Fire fire ) { + // Returns true, if this cell is visible + public static boolean affect( int cell, Fire fire ) { Char ch = Actor.findChar( cell ); if (ch != null) { @@ -49,8 +48,9 @@ public static void affect( int cell, Fire fire ) { if (Dungeon.visible[cell]) { CellEmitter.get( cell ).start( SnowParticle.FACTORY, 0.2f, 6 ); + return true; + } else { + return false; } - - } } diff --git a/src/com/watabou/pixeldungeon/actors/blobs/ParalyticGas.java b/src/com/watabou/pixeldungeon/actors/blobs/ParalyticGas.java index cae7c22381..0e4c9f45d7 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/ParalyticGas.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/ParalyticGas.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Regrowth.java b/src/com/watabou/pixeldungeon/actors/blobs/Regrowth.java index 794c0248ac..9752adb620 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Regrowth.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Regrowth.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/ToxicGas.java b/src/com/watabou/pixeldungeon/actors/blobs/ToxicGas.java index e9e7dcfec6..9f9d1c7aca 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/ToxicGas.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/ToxicGas.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfAwareness.java b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfAwareness.java index 4a589a3ce3..7c5a5d0476 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfAwareness.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfAwareness.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfHealth.java b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfHealth.java index 0710151e02..c01860a1ae 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfHealth.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfHealth.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfTransmutation.java b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfTransmutation.java index 07c82c348d..96d229385d 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/WaterOfTransmutation.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/WaterOfTransmutation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -30,9 +30,8 @@ import com.watabou.pixeldungeon.items.rings.Ring; import com.watabou.pixeldungeon.items.scrolls.Scroll; import com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade; -import com.watabou.pixeldungeon.items.scrolls.ScrollOfWeaponUpgrade; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment; import com.watabou.pixeldungeon.items.wands.Wand; -import com.watabou.pixeldungeon.items.weapon.Weapon.Enchantment; import com.watabou.pixeldungeon.items.weapon.melee.*; import com.watabou.pixeldungeon.plants.Plant; @@ -41,38 +40,27 @@ public class WaterOfTransmutation extends WellWater { @Override protected Item affectItem( Item item ) { - if (item instanceof MeleeWeapon) { - - return changeWeapon( (MeleeWeapon)item ); - - } else if (item instanceof Scroll) { - - Journal.remove( Feature.WELL_OF_TRANSMUTATION ); - return changeScroll( (Scroll)item ); - + if (item instanceof MeleeWeapon) { + item = changeWeapon( (MeleeWeapon)item ); + } else if (item instanceof Scroll) { + item = changeScroll( (Scroll)item ); } else if (item instanceof Potion) { - - Journal.remove( Feature.WELL_OF_TRANSMUTATION ); - return changePotion( (Potion)item ); - + item = changePotion( (Potion)item ); } else if (item instanceof Ring) { - - Journal.remove( Feature.WELL_OF_TRANSMUTATION ); - return changeRing( (Ring)item ); - + item = changeRing( (Ring)item ); } else if (item instanceof Wand) { - - Journal.remove( Feature.WELL_OF_TRANSMUTATION ); - return changeWand( (Wand)item ); - + item = changeWand( (Wand)item ); } else if (item instanceof Plant.Seed) { - - Journal.remove( Feature.WELL_OF_TRANSMUTATION ); - return changeSeed( (Plant.Seed)item ); - + item = changeSeed( (Plant.Seed)item ); } else { - return null; + item = null; } + + if (item != null) { + Journal.remove( Feature.WELL_OF_TRANSMUTATION ); + } + + return item; } @Override @@ -125,7 +113,7 @@ else if (w instanceof Glaive) { } if (w.isEnchanted()) { - n.enchant( Enchantment.random() ); + n.enchant(); } n.levelKnown = w.levelKnown; @@ -193,9 +181,9 @@ private Plant.Seed changeSeed( Plant.Seed s ) { private Scroll changeScroll( Scroll s ) { if (s instanceof ScrollOfUpgrade) { - return new ScrollOfWeaponUpgrade(); + return new ScrollOfEnchantment(); - } else if (s instanceof ScrollOfWeaponUpgrade) { + } else if (s instanceof ScrollOfEnchantment) { return new ScrollOfUpgrade(); diff --git a/src/com/watabou/pixeldungeon/actors/blobs/Web.java b/src/com/watabou/pixeldungeon/actors/blobs/Web.java index 00695bbf36..c2a3db1cfb 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/Web.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/Web.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/blobs/WellWater.java b/src/com/watabou/pixeldungeon/actors/blobs/WellWater.java index d59956d6a8..83eb745433 100644 --- a/src/com/watabou/pixeldungeon/actors/blobs/WellWater.java +++ b/src/com/watabou/pixeldungeon/actors/blobs/WellWater.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Amok.java b/src/com/watabou/pixeldungeon/actors/buffs/Amok.java index 48a260a46e..fa965e0685 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Amok.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Amok.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Awareness.java b/src/com/watabou/pixeldungeon/actors/buffs/Awareness.java index 252e901e6f..f8a13dd7c8 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Awareness.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Awareness.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Barkskin.java b/src/com/watabou/pixeldungeon/actors/buffs/Barkskin.java index d61cdd3f31..af757297f5 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Barkskin.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Barkskin.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java b/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java index 32f8d9f07d..480cbb042a 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Blindness.java b/src/com/watabou/pixeldungeon/actors/buffs/Blindness.java index a23f3437cf..242119366a 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Blindness.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Blindness.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -21,7 +21,7 @@ import com.watabou.pixeldungeon.ui.BuffIndicator; public class Blindness extends FlavourBuff { - + @Override public void detach() { super.detach(); diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Buff.java b/src/com/watabou/pixeldungeon/actors/buffs/Buff.java index 0b5aa1632e..3d481d04c2 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Buff.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Buff.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -22,7 +22,7 @@ import com.watabou.pixeldungeon.ui.BuffIndicator; public class Buff extends Actor { - + public Char target; public boolean attachTo( Char target ) { @@ -51,18 +51,28 @@ public int icon() { return BuffIndicator.NONE; } + public static T append( Char target, Class buffClass ) { + try { + T buff = buffClass.newInstance(); + buff.attachTo( target ); + return buff; + } catch (Exception e) { + return null; + } + } + + public static T append( Char target, Class buffClass, float duration ) { + T buff = append( target, buffClass ); + buff.spend( duration ); + return buff; + } + public static T affect( Char target, Class buffClass ) { T buff = target.buff( buffClass ); if (buff != null) { return buff; } else { - try { - buff = buffClass.newInstance(); - buff.attachTo( target ); - return buff; - } catch (Exception e) { - return null; - } + return append( target, buffClass ); } } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Burning.java b/src/com/watabou/pixeldungeon/actors/buffs/Burning.java index e88687b2bd..e166a2bdbc 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Burning.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Burning.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -71,7 +71,7 @@ public boolean act() { if (target instanceof Hero) { Buff.prolong( target, Light.class, TICK * 1.01f ); } - + target.damage( Random.Int( 1, 5 ), this ); if (target instanceof Hero) { @@ -120,7 +120,7 @@ public boolean act() { detach(); } - + return true; } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Charm.java b/src/com/watabou/pixeldungeon/actors/buffs/Charm.java index d363accfc1..42a19bde4c 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Charm.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Charm.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -20,23 +20,25 @@ import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.items.rings.RingOfElements.Resistance; import com.watabou.pixeldungeon.ui.BuffIndicator; +import com.watabou.utils.Bundle; public class Charm extends FlavourBuff { + public int object = 0; + + private static final String OBJECT = "object"; + @Override - public boolean attachTo( Char target ) { - if (super.attachTo( target )) { - target.pacified = true; - return true; - } else { - return false; - } + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( OBJECT, object ); + } @Override - public void detach() { - target.pacified = false; - super.detach(); + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle( bundle ); + object = bundle.getInt( OBJECT ); } @Override diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Combo.java b/src/com/watabou/pixeldungeon/actors/buffs/Combo.java index 9956f47c85..696acbd3a6 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Combo.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Combo.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Cripple.java b/src/com/watabou/pixeldungeon/actors/buffs/Cripple.java index c50c3b418d..f5267e2baa 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Cripple.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Cripple.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/FlavourBuff.java b/src/com/watabou/pixeldungeon/actors/buffs/FlavourBuff.java index 452c15b163..d653eb17a5 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/FlavourBuff.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/FlavourBuff.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,7 +17,6 @@ */ package com.watabou.pixeldungeon.actors.buffs; -//Special kind of buff, that doesn't perform any kind actions public class FlavourBuff extends Buff { @Override diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Frost.java b/src/com/watabou/pixeldungeon/actors/buffs/Frost.java index 18546ce811..61e2c7e69d 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Frost.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Frost.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -58,8 +58,8 @@ public boolean attachTo( Char target ) { @Override public void detach() { - target.paralysed = false; super.detach(); + Paralysis.unfreeze( target ); } @Override diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Fury.java b/src/com/watabou/pixeldungeon/actors/buffs/Fury.java index fb2777a471..8325afcdcf 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Fury.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Fury.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/GasesImmunity.java b/src/com/watabou/pixeldungeon/actors/buffs/GasesImmunity.java index fab1d89fb9..f5fadacc2a 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/GasesImmunity.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/GasesImmunity.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -40,5 +40,6 @@ public String toString() { static { IMMUNITIES.add( Paralysis.class ); IMMUNITIES.add( ToxicGas.class ); + IMMUNITIES.add( Vertigo.class ); } } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java b/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java index 4e4ea63c88..8c662e778c 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -63,7 +63,6 @@ public boolean act() { Hero hero = (Hero)target; if (isStarving()) { - if (Random.Float() < 0.3f && (target.HP > 1 || !target.paralysed)) { GLog.n( TXT_STARVING ); @@ -109,7 +108,7 @@ public boolean act() { diactivate(); } - + return true; } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Invisibility.java b/src/com/watabou/pixeldungeon/actors/buffs/Invisibility.java index cf44544e3c..635d1c3900 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Invisibility.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Invisibility.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Levitation.java b/src/com/watabou/pixeldungeon/actors/buffs/Levitation.java index c3d64c850e..4c0fd56885 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Levitation.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Levitation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Light.java b/src/com/watabou/pixeldungeon/actors/buffs/Light.java index 7f2baa4381..3b0cf4b34b 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Light.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Light.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -29,7 +29,6 @@ public class Light extends FlavourBuff { @Override public boolean attachTo( Char target ) { if (super.attachTo( target )) { - // When a level is loading, do nothing if (Dungeon.level != null) { target.viewDistance = Math.max( Dungeon.level.viewDistance, DISTANCE ); Dungeon.observe(); diff --git a/src/com/watabou/pixeldungeon/actors/buffs/MindVision.java b/src/com/watabou/pixeldungeon/actors/buffs/MindVision.java index 4032e60ef6..1c7e2857f0 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/MindVision.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/MindVision.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Ooze.java b/src/com/watabou/pixeldungeon/actors/buffs/Ooze.java index 564e46d4dd..61fecc1eea 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Ooze.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Ooze.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Paralysis.java b/src/com/watabou/pixeldungeon/actors/buffs/Paralysis.java index ed6935934a..2d9da3efba 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Paralysis.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Paralysis.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -37,8 +37,8 @@ public boolean attachTo( Char target ) { @Override public void detach() { - target.paralysed = false; super.detach(); + unfreeze( target ); } @Override @@ -55,4 +55,12 @@ public static float duration( Char ch ) { Resistance r = ch.buff( Resistance.class ); return r != null ? r.durationFactor() * DURATION : DURATION; } + + public static void unfreeze( Char ch ) { + if (ch.buff( Paralysis.class ) == null && + ch.buff( Frost.class ) == null) { + + ch.paralysed = false; + } + } } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Poison.java b/src/com/watabou/pixeldungeon/actors/buffs/Poison.java index 83ac4498ab..d3e0d71cfd 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Poison.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Poison.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -77,7 +77,7 @@ public boolean act() { detach(); } - + return true; } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Regeneration.java b/src/com/watabou/pixeldungeon/actors/buffs/Regeneration.java index fd1a028e6e..27949cd5ae 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Regeneration.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Regeneration.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -27,7 +27,7 @@ public class Regeneration extends Buff { @Override public boolean act() { if (target.isAlive()) { - + if (target.HP < target.HT && !((Hero)target).isStarving()) { target.HP += 1; } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Roots.java b/src/com/watabou/pixeldungeon/actors/buffs/Roots.java index 932dfbbcea..19aff10f25 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Roots.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Roots.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Shadows.java b/src/com/watabou/pixeldungeon/actors/buffs/Shadows.java index ae6e4fc928..be4abf66a9 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Shadows.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Shadows.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -75,7 +75,7 @@ public boolean act() { detach(); } - + return true; } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Sleep.java b/src/com/watabou/pixeldungeon/actors/buffs/Sleep.java index 7ffff90e13..e3d47074f4 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Sleep.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Sleep.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Slow.java b/src/com/watabou/pixeldungeon/actors/buffs/Slow.java index 80f3b7f4ba..5f3f1e9a38 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Slow.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Slow.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -34,7 +34,7 @@ public int icon() { public String toString() { return "Slowed"; } - + public static float duration( Char ch ) { Resistance r = ch.buff( Resistance.class ); return r != null ? r.durationFactor() * DURATION : DURATION; diff --git a/src/com/watabou/pixeldungeon/actors/buffs/SnipersMark.java b/src/com/watabou/pixeldungeon/actors/buffs/SnipersMark.java index 01ca64f758..5460eff61c 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/SnipersMark.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/SnipersMark.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,9 +18,27 @@ package com.watabou.pixeldungeon.actors.buffs; import com.watabou.pixeldungeon.ui.BuffIndicator; +import com.watabou.utils.Bundle; public class SnipersMark extends FlavourBuff { +public int object = 0; + + private static final String OBJECT = "object"; + + @Override + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( OBJECT, object ); + + } + + @Override + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle( bundle ); + object = bundle.getInt( OBJECT ); + } + @Override public int icon() { return BuffIndicator.MARK; @@ -28,6 +46,6 @@ public int icon() { @Override public String toString() { - return "Sniper's mark"; + return "Zeroed in"; } } diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Speed.java b/src/com/watabou/pixeldungeon/actors/buffs/Speed.java index cccdc6950c..d6a7e18bcb 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Speed.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Speed.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Terror.java b/src/com/watabou/pixeldungeon/actors/buffs/Terror.java index d905e2d81d..8e762b66ef 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Terror.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Terror.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,7 +17,6 @@ */ package com.watabou.pixeldungeon.actors.buffs; -import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.ui.BuffIndicator; import com.watabou.utils.Bundle; @@ -25,18 +24,27 @@ public class Terror extends FlavourBuff { public static final float DURATION = 10f; - public Char source; + + public int object = 0; + + private static final String OBJECT = "object"; @Override - public int icon() { - return BuffIndicator.TERROR; + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( OBJECT, object ); + } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - // It's not really correct... - source = Dungeon.hero; + object = bundle.getInt( OBJECT ); + } + + @Override + public int icon() { + return BuffIndicator.TERROR; } @Override diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Vertigo.java b/src/com/watabou/pixeldungeon/actors/buffs/Vertigo.java index 6afd048f53..3775970e69 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Vertigo.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Vertigo.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/buffs/Weakness.java b/src/com/watabou/pixeldungeon/actors/buffs/Weakness.java index 52df8f84b8..cda851f128 100644 --- a/src/com/watabou/pixeldungeon/actors/buffs/Weakness.java +++ b/src/com/watabou/pixeldungeon/actors/buffs/Weakness.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/hero/Belongings.java b/src/com/watabou/pixeldungeon/actors/hero/Belongings.java index 0f87d74fa8..5c252e1303 100644 --- a/src/com/watabou/pixeldungeon/actors/hero/Belongings.java +++ b/src/com/watabou/pixeldungeon/actors/hero/Belongings.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -166,14 +166,13 @@ public Item randomUnequipped() { } public void resurrect( int depth ) { - for (Item item : backpack.items.toArray( new Item[0])) { if (item instanceof Key) { if (((Key)item).depth == depth) { item.detachAll( backpack ); } } else if (item.unique) { - + // Keep unique items } else if (!item.isEquipped( owner )) { item.detachAll( backpack ); } diff --git a/src/com/watabou/pixeldungeon/actors/hero/Hero.java b/src/com/watabou/pixeldungeon/actors/hero/Hero.java index 3c9f3effbb..8aae3b26ae 100644 --- a/src/com/watabou/pixeldungeon/actors/hero/Hero.java +++ b/src/com/watabou/pixeldungeon/actors/hero/Hero.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,6 +18,7 @@ package com.watabou.pixeldungeon.actors.hero; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import com.watabou.noosa.Camera; @@ -70,6 +71,8 @@ import com.watabou.pixeldungeon.items.keys.Key; import com.watabou.pixeldungeon.items.keys.SkeletonKey; import com.watabou.pixeldungeon.items.keys.IronKey; +import com.watabou.pixeldungeon.items.potions.Potion; +import com.watabou.pixeldungeon.items.potions.PotionOfMight; import com.watabou.pixeldungeon.items.potions.PotionOfStrength; import com.watabou.pixeldungeon.items.rings.RingOfAccuracy; import com.watabou.pixeldungeon.items.rings.RingOfDetection; @@ -78,9 +81,11 @@ import com.watabou.pixeldungeon.items.rings.RingOfHaste; import com.watabou.pixeldungeon.items.rings.RingOfShadows; import com.watabou.pixeldungeon.items.rings.RingOfThorns; +import com.watabou.pixeldungeon.items.scrolls.Scroll; import com.watabou.pixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.watabou.pixeldungeon.items.scrolls.ScrollOfRecharging; import com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment; import com.watabou.pixeldungeon.items.wands.Wand; import com.watabou.pixeldungeon.items.weapon.melee.MeleeWeapon; import com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon; @@ -88,6 +93,7 @@ import com.watabou.pixeldungeon.levels.Terrain; import com.watabou.pixeldungeon.levels.features.AlchemyPot; import com.watabou.pixeldungeon.levels.features.Chasm; +import com.watabou.pixeldungeon.levels.features.Sign; import com.watabou.pixeldungeon.plants.Earthroot; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.pixeldungeon.scenes.InterlevelScene; @@ -96,7 +102,6 @@ import com.watabou.pixeldungeon.sprites.HeroSprite; import com.watabou.pixeldungeon.ui.AttackIndicator; import com.watabou.pixeldungeon.ui.BuffIndicator; -import com.watabou.pixeldungeon.ui.QuickSlot; import com.watabou.pixeldungeon.utils.GLog; import com.watabou.pixeldungeon.windows.WndMessage; import com.watabou.pixeldungeon.windows.WndResurrect; @@ -134,7 +139,9 @@ public class Hero extends Char { private int attackSkill = 10; private int defenseSkill = 5; + public boolean ready = false; + public HeroAction curAction = null; public HeroAction lastAction = null; @@ -464,7 +471,7 @@ private void ready() { } public void interrupt() { - if (curAction != null && curAction.dst != pos) { + if (isAlive() && curAction != null && curAction.dst != pos) { lastAction = curAction; } curAction = null; @@ -484,9 +491,10 @@ private boolean actMove( HeroAction.Move action ) { } else { if (Dungeon.level.map[pos] == Terrain.SIGN) { - GameScene.show( new WndMessage( Dungeon.tip() ) ); + Sign.read( pos ); } ready(); + return false; } } @@ -567,10 +575,12 @@ private boolean actPickUp( HeroAction.PickUp action ) { if (item.doPickUp( this )) { if (item instanceof Dewdrop) { - + // Do nothing } else { - if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade)item).isKnown()) || - (item instanceof PotionOfStrength && ((PotionOfStrength)item).isKnown())) { + boolean important = + ((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll)item).isKnown()) || + ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion)item).isKnown()); + if (important) { GLog.p( TXT_YOU_NOW_HAVE, item.name() ); } else { GLog.i( TXT_YOU_NOW_HAVE, item.name() ); @@ -606,9 +616,7 @@ private boolean actOpenChest( HeroAction.OpenChest action ) { if (Level.adjacent( pos, dst ) || pos == dst) { Heap heap = Dungeon.level.heaps.get( dst ); - if (heap != null && - (heap.type == Type.CHEST || heap.type == Type.TOMB || heap.type == Type.SKELETON || - heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST)) { + if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) { theKey = null; @@ -764,7 +772,7 @@ private boolean actAttack( HeroAction.Attack action ) { enemy = action.target; - if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !pacified) { + if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !isCharmedBy( enemy )) { spend( attackDelay() ); sprite.attack( enemy.pos ); @@ -809,12 +817,14 @@ public int attackProc( Char enemy, int damage ) { case BATTLEMAGE: if (wep instanceof Wand) { Wand wand = (Wand)wep; - if (wand.curCharges < wand.maxCharges && damage > 0) { + if (wand.curCharges >= wand.maxCharges) { + + wand.use(); + + } else if (damage > 0) { wand.curCharges++; - if (Dungeon.quickslot == wand) { - QuickSlot.refresh(); - } + wand.updateQuickslot(); ScrollOfRecharging.charge( this ); } @@ -822,7 +832,7 @@ public int attackProc( Char enemy, int damage ) { } case SNIPER: if (rangedWeapon != null) { - Buff.prolong( enemy, SnipersMark.class, attackDelay() * 1.1f ); + Buff.prolong( this, SnipersMark.class, attackDelay() * 1.1f ).object = enemy.id(); } break; default: @@ -898,6 +908,7 @@ public Mob visibleEnemy( int index ) { private boolean getCloser( final int target ) { if (rooted) { + Camera.main.shake( 1, 1f ); return false; } @@ -960,8 +971,7 @@ public boolean handle( int cell ) { curAction = new HeroAction.Cook( cell ); - } else - if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) { + } else if (Level.fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) { if (ch instanceof NPC) { curAction = new HeroAction.Interact( (NPC)ch ); @@ -969,7 +979,7 @@ public boolean handle( int cell ) { curAction = new HeroAction.Attack( ch ); } - } else if ((heap = Dungeon.level.heaps.get( cell )) != null) { + } else if (Level.fieldOfView[cell] && (heap = Dungeon.level.heaps.get( cell )) != null) { switch (heap.type) { case HEAP: @@ -1181,6 +1191,28 @@ public static void reallyDie( Object cause ) { Dungeon.hero.belongings.identify(); + int pos = Dungeon.hero.pos; + + ArrayList passable = new ArrayList(); + for (Integer ofs : Level.NEIGHBOURS8) { + int cell = pos + ofs; + if ((Level.passable[cell] || Level.avoid[cell]) && Dungeon.level.heaps.get( cell ) == null) { + passable.add( cell ); + } + } + Collections.shuffle( passable ); + + ArrayList items = new ArrayList( Dungeon.hero.belongings.backpack.items ); + for (Integer cell : passable) { + if (items.isEmpty()) { + break; + } + + Item item = Random.element( items ); + Dungeon.level.drop( item, cell ).sprite.drop( pos ); + items.remove( item ); + } + GameScene.gameOver(); if (cause instanceof Hero.Doom) { @@ -1315,11 +1347,11 @@ public boolean search( boolean intentional ) { int oldValue = Dungeon.level.map[p]; GameScene.discoverTile( p, oldValue ); - + Level.set( p, Terrain.discover( oldValue ) ); - + GameScene.updateMap( p ); - + ScrollOfMagicMapping.discover( p ); smthFound = true; @@ -1372,6 +1404,11 @@ public HashSet> immunities() { return buff == null ? super.immunities() : GasesImmunity.IMMUNITIES; } + @Override + public void next() { + super.next(); + } + public static interface Doom { public void onDeath(); } diff --git a/src/com/watabou/pixeldungeon/actors/hero/HeroAction.java b/src/com/watabou/pixeldungeon/actors/hero/HeroAction.java index 717e13145a..9a1467ef4a 100644 --- a/src/com/watabou/pixeldungeon/actors/hero/HeroAction.java +++ b/src/com/watabou/pixeldungeon/actors/hero/HeroAction.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java b/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java index d0094730ab..6698821568 100644 --- a/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java +++ b/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,9 +19,9 @@ import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Badges; -import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.items.TomeOfMastery; import com.watabou.pixeldungeon.items.armor.ClothArmor; +import com.watabou.pixeldungeon.items.bags.Keyring; import com.watabou.pixeldungeon.items.food.Food; import com.watabou.pixeldungeon.items.potions.PotionOfStrength; import com.watabou.pixeldungeon.items.rings.RingOfShadows; @@ -33,6 +33,7 @@ import com.watabou.pixeldungeon.items.weapon.melee.ShortSword; import com.watabou.pixeldungeon.items.weapon.missiles.Dart; import com.watabou.pixeldungeon.items.weapon.missiles.Boomerang; +import com.watabou.pixeldungeon.ui.QuickSlot; import com.watabou.utils.Bundle; public enum HeroClass { @@ -73,7 +74,7 @@ private HeroClass( String title ) { public static final String[] HUN_PERKS = { "Huntresses start with 15 points of Health.", "Huntresses start with a unique upgradeable boomerang.", - "Huntresses are proficient with missile weapons and get damage bonus for excessive strength when using them.", + "Huntresses are proficient with missile weapons and get a damage bonus for excessive strength when using them.", "Huntresses gain more health from dewdrops.", "Huntresses sense neighbouring monsters even if they are hidden behind obstacles." }; @@ -112,6 +113,7 @@ public void initHero( Hero hero ) { private static void initCommon( Hero hero ) { (hero.belongings.armor = new ClothArmor()).identify(); new Food().identify().collect(); + new Keyring().collect(); } public Badges.Badge masteryBadge() { @@ -134,7 +136,7 @@ private static void initWarrior( Hero hero ) { (hero.belongings.weapon = new ShortSword()).identify(); new Dart( 8 ).identify().collect(); - Dungeon.quickslot = Dart.class; + QuickSlot.primaryValue = Dart.class; new PotionOfStrength().setKnown(); } @@ -145,7 +147,7 @@ private static void initMage( Hero hero ) { WandOfMagicMissile wand = new WandOfMagicMissile(); wand.identify().collect(); - Dungeon.quickslot = wand; + QuickSlot.primaryValue = wand; new ScrollOfIdentify().setKnown(); } @@ -157,7 +159,7 @@ private static void initRogue( Hero hero ) { hero.belongings.ring1.activate( hero ); - Dungeon.quickslot = Dart.class; + QuickSlot.primaryValue = Dart.class; new ScrollOfMagicMapping().setKnown(); } @@ -170,7 +172,7 @@ private static void initHuntress( Hero hero ) { Boomerang boomerang = new Boomerang(); boomerang.identify().collect(); - Dungeon.quickslot = boomerang; + QuickSlot.primaryValue = boomerang; } public String title() { diff --git a/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java b/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java index 99f932abfd..ff05430cf2 100644 --- a/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java +++ b/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -25,7 +25,7 @@ public enum HeroSubClass { GLADIATOR( "gladiator", "A successful attack with a melee weapon allows the _Gladiator_ to start a combo, " + - "in which every next successful hit inflicts more damage." ), + "in which every next successful hit inflicts more damage." ), BERSERKER( "berserker", "When severely wounded, the _Berserker_ enters a state of wild fury " + "significantly increasing his damage output." ), diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Acidic.java b/src/com/watabou/pixeldungeon/actors/mobs/Acidic.java index 82f73399df..6793cef281 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Acidic.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Acidic.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Albino.java b/src/com/watabou/pixeldungeon/actors/mobs/Albino.java index 8dd19bb723..cb27f52daf 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Albino.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Albino.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Bandit.java b/src/com/watabou/pixeldungeon/actors/mobs/Bandit.java index 5245bfadbd..0e6833a557 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Bandit.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Bandit.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -39,7 +39,7 @@ public class Bandit extends Thief { protected boolean steal( Hero hero ) { if (super.steal( hero )) { - Buff.prolong( enemy, Blindness.class, Random.Int( 5, 12 ) ); + Buff.prolong( hero, Blindness.class, Random.Int( 5, 12 ) ); Dungeon.observe(); return true; diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Bat.java b/src/com/watabou/pixeldungeon/actors/mobs/Bat.java index 4da00ce09c..387d147df8 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Bat.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Bat.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Bestiary.java b/src/com/watabou/pixeldungeon/actors/mobs/Bestiary.java index ce0824109b..984ecd70bf 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Bestiary.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Bestiary.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -177,7 +177,7 @@ private static Class mobClass( int depth ) { return classes[ Random.chances( chances )]; } - public static boolean isUnique( Char mob ) { + public static boolean isBoss( Char mob ) { return mob instanceof Goo || mob instanceof Tengu || mob instanceof DM300 || mob instanceof King || mob instanceof Yog; } } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Brute.java b/src/com/watabou/pixeldungeon/actors/mobs/Brute.java index acc104c513..5af37de432 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Brute.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Brute.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Crab.java b/src/com/watabou/pixeldungeon/actors/mobs/Crab.java index 53ccd7ce29..85c50e8a30 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Crab.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Crab.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/DM300.java b/src/com/watabou/pixeldungeon/actors/mobs/DM300.java index a1f63e66bd..480c776cdf 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/DM300.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/DM300.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -24,6 +24,7 @@ import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.blobs.Blob; @@ -47,7 +48,7 @@ public class DM300 extends Mob { { - name = "DM-300"; + name = Dungeon.depth == Statistics.deepestFloor ? "DM-300" : "DM-350"; spriteClass = DM300Sprite.class; HP = HT = 200; @@ -75,16 +76,14 @@ public int dr() { @Override public boolean act() { - GameScene.add( Blob.seed( pos, 30, ToxicGas.class ) ); - return super.act(); } @Override public void move( int step ) { super.move( step ); - + if (Dungeon.level.map[step] == Terrain.INACTIVE_TRAP && HP < HT) { HP += Random.Int( 1, HT - HP ); @@ -108,7 +107,7 @@ public void move( int step ) { CellEmitter.get( cell ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 ); Camera.main.shake( 3, 0.7f ); Sample.INSTANCE.play( Assets.SND_ROCKS ); - + if (Level.water[cell]) { GameScene.ripple( cell ); } else if (Dungeon.level.map[cell] == Terrain.EMPTY) { diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Elemental.java b/src/com/watabou/pixeldungeon/actors/mobs/Elemental.java index 6954ce9d1b..0e4be083c7 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Elemental.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Elemental.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Eye.java b/src/com/watabou/pixeldungeon/actors/mobs/Eye.java index 79c24982a5..996c3c99e6 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Eye.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Eye.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -70,7 +70,7 @@ public int dr() { protected boolean canAttack( Char enemy ) { hitCell = Ballistica.cast( pos, enemy.pos, true, false ); - + for (int i=1; i < Ballistica.distance; i++) { if (Ballistica.trace[i] == enemy.pos) { return true; diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Gnoll.java b/src/com/watabou/pixeldungeon/actors/mobs/Gnoll.java index caa13a4708..55602a5412 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Gnoll.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Gnoll.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Golem.java b/src/com/watabou/pixeldungeon/actors/mobs/Golem.java index f1e633a2b7..a55539d6ff 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Golem.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Golem.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Goo.java b/src/com/watabou/pixeldungeon/actors/mobs/Goo.java index 9f1fcfc84d..3b8159e58c 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Goo.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Goo.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,9 +19,9 @@ import java.util.HashSet; -import com.watabou.noosa.Camera; import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.blobs.ToxicGas; import com.watabou.pixeldungeon.actors.buffs.Buff; @@ -33,10 +33,12 @@ import com.watabou.pixeldungeon.items.weapon.enchantments.Death; import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.levels.SewerBossLevel; +import com.watabou.pixeldungeon.mechanics.Ballistica; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.pixeldungeon.sprites.CharSprite; import com.watabou.pixeldungeon.sprites.GooSprite; import com.watabou.pixeldungeon.utils.GLog; +import com.watabou.utils.Callback; import com.watabou.utils.Random; public class Goo extends Mob { @@ -44,7 +46,8 @@ public class Goo extends Mob { private static final float PUMP_UP_DELAY = 2f; { - name = "Goo"; + name = Dungeon.depth == Statistics.deepestFloor ? "Goo" : "spawn of Goo"; + HP = HT = 80; EXP = 10; defenseSkill = 12; @@ -54,7 +57,8 @@ public class Goo extends Mob { lootChance = 0.333f; } - private boolean pumpedUp = false; + private boolean pumpedUp = false; + private boolean jumped = false; @Override public int damageRoll() { @@ -67,7 +71,7 @@ public int damageRoll() { @Override public int attackSkill( Char target ) { - return pumpedUp ? 30 : 15; + return pumpedUp && !jumped ? 30 : 15; } @Override @@ -88,7 +92,7 @@ public boolean act() { @Override protected boolean canAttack( Char enemy ) { - return pumpedUp ? distance( enemy ) <= 2 : super.canAttack(enemy); + return pumpedUp ? distance( enemy ) <= 2 : super.canAttack( enemy ); } @Override @@ -98,21 +102,62 @@ public int attackProc( Char enemy, int damage ) { enemy.sprite.burst( 0x000000, 5 ); } - if (pumpedUp) { - Camera.main.shake( 3, 0.2f ); - } - return damage; } @Override - protected boolean doAttack( Char enemy ) { - if (pumpedUp || Random.Int( 3 ) > 0) { + protected boolean doAttack( final Char enemy ) { + if (pumpedUp) { + + if (Level.adjacent( pos, enemy.pos )) { + + // Pumped up attack WITHOUT accuracy penalty + jumped = false; + return super.doAttack( enemy ); + + } else { + + // Pumped up attack WITH accuracy penalty + jumped = true; + if (Ballistica.cast( pos, enemy.pos, false, true ) == enemy.pos) { + final int dest = Ballistica.trace[Ballistica.distance - 2]; + + Callback afterJump = new Callback() { + @Override + public void call() { + move( dest ); + Dungeon.level.mobPress( Goo.this ); + Goo.super.doAttack( enemy ); + } + }; + + if (Dungeon.visible[pos] || Dungeon.visible[dest]) { + + sprite.jump( pos, dest, afterJump ); + return false; + + } else { + + afterJump.call(); + return true; + + } + } else { + + sprite.idle(); + pumpedUp = false; + return true; + } + } + + } else if (Random.Int( 3 ) > 0) { + // Normal attack return super.doAttack( enemy ); } else { + // Pumping up pumpedUp = true; spend( PUMP_UP_DELAY ); diff --git a/src/com/watabou/pixeldungeon/actors/mobs/King.java b/src/com/watabou/pixeldungeon/actors/mobs/King.java index ff9b060ec7..22979d48d8 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/King.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/King.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -23,11 +23,13 @@ import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.blobs.ToxicGas; import com.watabou.pixeldungeon.actors.buffs.Buff; import com.watabou.pixeldungeon.actors.buffs.Paralysis; +import com.watabou.pixeldungeon.actors.buffs.Vertigo; import com.watabou.pixeldungeon.effects.Flare; import com.watabou.pixeldungeon.effects.Speck; import com.watabou.pixeldungeon.items.ArmorKit; @@ -50,7 +52,7 @@ public class King extends Mob { private static final int MAX_ARMY_SIZE = 5; { - name = "King of Dwarves"; + name = Dungeon.depth == Statistics.deepestFloor ? "King of Dwarves" : "undead King of Dwarves"; spriteClass = KingSprite.class; HP = HT = 300; @@ -162,9 +164,8 @@ private void summon() { passable[((Char)actor).pos] = false; } } - - int undeadsToSummon = maxArmySize() - Undead.count; + int undeadsToSummon = maxArmySize() - Undead.count; PathFinder.buildDistanceMap( pos, passable, undeadsToSummon ); PathFinder.distance[pos] = Integer.MAX_VALUE; int dist = 1; @@ -174,14 +175,14 @@ private void summon() { do { for (int j=0; j < Level.LENGTH; j++) { if (PathFinder.distance[j] == dist) { - + Undead undead = new Undead(); undead.pos = j; GameScene.add( undead ); - + WandOfBlink.appear( undead, j ); new Flare( 3, 32 ).color( 0x000000, false ).show( undead.sprite, 2f ) ; - + PathFinder.distance[j] = Integer.MAX_VALUE; continue undeadLabel; @@ -225,6 +226,7 @@ public HashSet> resistances() { private static final HashSet> IMMUNITIES = new HashSet>(); static { IMMUNITIES.add( Paralysis.class ); + IMMUNITIES.add( Vertigo.class ); } @Override @@ -233,7 +235,7 @@ public HashSet> immunities() { } public static class Undead extends Mob { - + public static int count = 0; { diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Mimic.java b/src/com/watabou/pixeldungeon/actors/mobs/Mimic.java new file mode 100644 index 0000000000..0cfdf5146a --- /dev/null +++ b/src/com/watabou/pixeldungeon/actors/mobs/Mimic.java @@ -0,0 +1,181 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.actors.mobs; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +import com.watabou.noosa.audio.Sample; +import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.actors.Actor; +import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.effects.CellEmitter; +import com.watabou.pixeldungeon.effects.Pushing; +import com.watabou.pixeldungeon.effects.Speck; +import com.watabou.pixeldungeon.items.Gold; +import com.watabou.pixeldungeon.items.Item; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfPsionicBlast; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.scenes.GameScene; +import com.watabou.pixeldungeon.sprites.MimicSprite; +import com.watabou.utils.Bundle; +import com.watabou.utils.Random; + +public class Mimic extends Mob { + + private int level; + + { + name = "mimic"; + spriteClass = MimicSprite.class; + } + + public ArrayList items; + + private static final String LEVEL = "level"; + private static final String ITEMS = "items"; + + @Override + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( ITEMS, items ); + bundle.put( LEVEL, level ); + } + + @SuppressWarnings("unchecked") + @Override + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle( bundle ); + items = new ArrayList( (Collection) bundle.getCollection( ITEMS ) ); + adjustStats( bundle.getInt( LEVEL ) ); + } + + @Override + public int damageRoll() { + return Random.NormalIntRange( HT / 10, HT / 4 ); + } + + @Override + public int attackSkill( Char target ) { + return 9 + level; + } + + @Override + public int attackProc( Char enemy, int damage ) { + if (enemy == Dungeon.hero && Random.Int( 3 ) == 0) { + Gold gold = new Gold( Random.Int( Dungeon.gold / 10, Dungeon.gold / 2 ) ); + if (gold.quantity() > 0) { + Dungeon.gold -= gold.quantity(); + Dungeon.level.drop( gold, Dungeon.hero.pos ).sprite.drop(); + } + } + return super.attackProc( enemy, damage ); + } + + public void adjustStats( int level ) { + this.level = level; + + HT = (3 + level) * 4; + EXP = 2 + 2 * (level - 1) / 5; + defenseSkill = attackSkill( null ) / 2; + + enemySeen = true; + } + + @Override + public void die( Object cause ) { + + super.die( cause ); + + if (items != null) { + for (Item item : items) { + Dungeon.level.drop( item, pos ).sprite.drop(); + } + } + } + + @Override + public boolean reset() { + state = WANDERING; + return true; + } + + @Override + public String description() { + return + "Mimics are magical creatures which can take any shape they wish. In dungeons they almost always " + + "choose a shape of a treasure chest, because they know how to beckon an adventurer."; + } + + public static Mimic spawnAt( int pos, List items ) { + Char ch = Actor.findChar( pos ); + if (ch != null) { + ArrayList candidates = new ArrayList(); + for (int n : Level.NEIGHBOURS8) { + int cell = pos + n; + if ((Level.passable[cell] || Level.avoid[cell]) && Actor.findChar( cell ) == null) { + candidates.add( cell ); + } + } + if (candidates.size() > 0) { + int newPos = Random.element( candidates ); + Actor.addDelayed( new Pushing( ch, ch.pos, newPos ), -1 ); + + ch.pos = newPos; + // FIXME + if (ch instanceof Mob) { + Dungeon.level.mobPress( (Mob)ch ); + } else { + Dungeon.level.press( newPos, ch ); + } + } else { + return null; + } + } + + Mimic m = new Mimic(); + m.items = new ArrayList( items ); + m.adjustStats( Dungeon.depth ); + m.HP = m.HT; + m.pos = pos; + m.state = m.HUNTING; + GameScene.add( m, 1 ); + + m.sprite.turnTo( pos, Dungeon.hero.pos ); + + if (Dungeon.visible[m.pos]) { + CellEmitter.get( pos ).burst( Speck.factory( Speck.STAR ), 10 ); + Sample.INSTANCE.play( Assets.SND_MIMIC ); + } + + return m; + } + + private static final HashSet> IMMUNITIES = new HashSet>(); + static { + IMMUNITIES.add( ScrollOfPsionicBlast.class ); + } + + @Override + public HashSet> immunities() { + return IMMUNITIES; + } +} diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Mob.java b/src/com/watabou/pixeldungeon/actors/mobs/Mob.java index e8aab718dc..f4dc20f30b 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Mob.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Mob.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -23,6 +23,7 @@ import com.watabou.pixeldungeon.Challenges; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.Statistics; +import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.buffs.Amok; import com.watabou.pixeldungeon.actors.buffs.Buff; @@ -37,6 +38,7 @@ import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.sprites.CharSprite; import com.watabou.pixeldungeon.utils.GLog; +import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -44,6 +46,8 @@ public abstract class Mob extends Char { private static final String TXT_DIED = "You hear something died in the distance"; + protected static final String TXT_ECHO = "echo of "; + protected static final String TXT_NOTICE1 = "?!"; protected static final String TXT_RAGE = "#$%^"; protected static final String TXT_EXP = "%+dEXP"; @@ -72,13 +76,6 @@ public abstract class Mob extends Char { public boolean hostile = true; - // Unreachable target - public static final Mob DUMMY = new Mob() { - { - pos = -1; - } - }; - private static final String STATE = "state"; private static final String TARGET = "target"; @@ -149,7 +146,9 @@ protected boolean act() { enemy = chooseEnemy(); - boolean enemyInFOV = enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0; + boolean enemyInFOV = + enemy != null && enemy.isAlive() && + Level.fieldOfView[enemy.pos] && enemy.invisible <= 0; return state.act( enemyInFOV, justAlerted ); } @@ -169,17 +168,18 @@ protected Char chooseEnemy() { return Random.element( enemies ); } - } else { - return enemy; } } Terror terror = (Terror)buff( Terror.class ); if (terror != null) { - return terror.source; + Char source = (Char)Actor.findById( terror.object ); + if (source != null) { + return source; + } } - - return Dungeon.hero; + + return enemy != null && enemy.isAlive() ? enemy : Dungeon.hero; } protected boolean moveSprite( int from, int to ) { @@ -222,7 +222,7 @@ public void remove( Buff buff ) { } protected boolean canAttack( Char enemy ) { - return Level.adjacent( pos, enemy.pos ) && !pacified; + return Level.adjacent( pos, enemy.pos ) && !isCharmedBy( enemy ); } protected boolean getCloser( int target ) { @@ -302,6 +302,10 @@ public int defenseProc( Char enemy, int damage ) { return damage; } + public void aggro( Char ch ) { + enemy = ch; + } + @Override public void damage( int dmg, Object src ) { @@ -324,7 +328,7 @@ public void destroy() { Dungeon.level.mobs.remove( this ); if (Dungeon.hero.isAlive()) { - + if (hostile) { Statistics.enemiesSlain++; Badges.validateMonstersSlain(); @@ -337,7 +341,7 @@ public void destroy() { } Badges.validateNightHunter(); } - + if (Dungeon.hero.lvl <= maxLvl && EXP > 0) { Dungeon.hero.sprite.showStatus( CharSprite.POSITIVE, TXT_EXP, EXP ); Dungeon.hero.earnExp( EXP ); @@ -349,11 +353,11 @@ public void destroy() { public void die( Object cause ) { super.die( cause ); - + if (Dungeon.hero.lvl <= maxLvl + 2) { dropLoot(); } - + if (Dungeon.hero.isAlive() && !Dungeon.visible[pos]) { GLog.i( TXT_DIED ); } @@ -450,7 +454,7 @@ public boolean act( boolean enemyInFOV, boolean justAlerted ) { @Override public String status() { - return String.format( "This %s is sleeping", name ); + return Utils.format( "This %s is sleeping", name ); } } @@ -487,7 +491,7 @@ public boolean act( boolean enemyInFOV, boolean justAlerted ) { @Override public String status() { - return String.format( "This %s is wandering", name ); + return Utils.format( "This %s is wandering", name ); } } @@ -526,7 +530,7 @@ public boolean act( boolean enemyInFOV, boolean justAlerted ) { @Override public String status() { - return String.format( "This %s is hunting", name ); + return Utils.format( "This %s is hunting", name ); } } @@ -561,7 +565,7 @@ protected void nowhereToRun() { @Override public String status() { - return String.format( "This %s is fleeing", name ); + return Utils.format( "This %s is fleeing", name ); } } @@ -578,7 +582,7 @@ public boolean act( boolean enemyInFOV, boolean justAlerted ) { @Override public String status() { - return String.format( "This %s is passive", name ); + return Utils.format( "This %s is passive", name ); } } } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Monk.java b/src/com/watabou/pixeldungeon/actors/mobs/Monk.java index f3697acafd..83680907f6 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Monk.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Monk.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Piranha.java b/src/com/watabou/pixeldungeon/actors/mobs/Piranha.java index 551f5be1b6..8d806552bf 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Piranha.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Piranha.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Rat.java b/src/com/watabou/pixeldungeon/actors/mobs/Rat.java index cb06ea288a..575bf0c9c1 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Rat.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Rat.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Scorpio.java b/src/com/watabou/pixeldungeon/actors/mobs/Scorpio.java index 86bc08b4b0..f5b0da6960 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Scorpio.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Scorpio.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Senior.java b/src/com/watabou/pixeldungeon/actors/mobs/Senior.java index 4f1e2cc113..fef59ec39a 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Senior.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Senior.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Shaman.java b/src/com/watabou/pixeldungeon/actors/mobs/Shaman.java index 97515f9990..8c9b708435 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Shaman.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Shaman.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Shielded.java b/src/com/watabou/pixeldungeon/actors/mobs/Shielded.java index c4e4329d09..393c46a6b0 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Shielded.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Shielded.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Skeleton.java b/src/com/watabou/pixeldungeon/actors/mobs/Skeleton.java index 4c9b3a3582..8ba0f9910c 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Skeleton.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Skeleton.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Spinner.java b/src/com/watabou/pixeldungeon/actors/mobs/Spinner.java index b68fa39939..748a8ed1b0 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Spinner.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Spinner.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -68,10 +68,10 @@ public int dr() { protected boolean act() { boolean result = super.act(); - if (state == FLEEING && buff( Terror.class ) == null && - enemySeen && enemy.buff( Poison.class ) == null) { - - state = HUNTING; + if (state == FLEEING && buff( Terror.class ) == null) { + if (enemy != null && enemySeen && enemy.buff( Poison.class ) == null) { + state = HUNTING; + } } return result; } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Statue.java b/src/com/watabou/pixeldungeon/actors/mobs/Statue.java index e5ecd878cf..c59f8cad57 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Statue.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Statue.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -27,7 +27,6 @@ import com.watabou.pixeldungeon.items.Generator; import com.watabou.pixeldungeon.items.scrolls.ScrollOfPsionicBlast; import com.watabou.pixeldungeon.items.weapon.Weapon; -import com.watabou.pixeldungeon.items.weapon.Weapon.Enchantment; import com.watabou.pixeldungeon.items.weapon.enchantments.Death; import com.watabou.pixeldungeon.items.weapon.enchantments.Leech; import com.watabou.pixeldungeon.items.weapon.melee.MeleeWeapon; @@ -55,7 +54,7 @@ public Statue() { } while (!(weapon instanceof MeleeWeapon) || weapon.level < 0); weapon.identify(); - weapon.enchant( Enchantment.random() ); + weapon.enchant(); HP = HT = 15 + Dungeon.depth * 5; defenseSkill = 4 + Dungeon.depth; @@ -121,6 +120,7 @@ public int attackProc( Char enemy, int damage ) { @Override public void beckon( int cell ) { + // Do nothing } @Override diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Succubus.java b/src/com/watabou/pixeldungeon/actors/mobs/Succubus.java index 764c593241..114cb4d4c8 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Succubus.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Succubus.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -66,7 +66,7 @@ public int damageRoll() { public int attackProc( Char enemy, int damage ) { if (Random.Int( 3 ) == 0) { - Buff.affect( enemy, Charm.class, Charm.durationFactor( enemy ) * Random.IntRange( 2, 5 ) ); + Buff.affect( enemy, Charm.class, Charm.durationFactor( enemy ) * Random.IntRange( 3, 7 ) ).object = id(); enemy.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 ); Sample.INSTANCE.play( Assets.SND_CHARMS ); } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java b/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java index afbe3dafc2..a8b87c48f1 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Tengu.java b/src/com/watabou/pixeldungeon/actors/mobs/Tengu.java index 8bdd93b2a3..ae88b78429 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Tengu.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Tengu.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -22,6 +22,7 @@ import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Badges; +import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.Badges.Badge; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.Actor; @@ -47,7 +48,7 @@ public class Tengu extends Mob { private static final int JUMP_DELAY = 5; { - name = "Tengu"; + name = Dungeon.depth == Statistics.deepestFloor ? "Tengu" : "memory of Tengu"; spriteClass = TenguSprite.class; HP = HT = 120; @@ -151,7 +152,7 @@ private void jump() { } while ( !Level.fieldOfView[newPos] || !Level.passable[newPos] || - Level.adjacent( newPos, enemy.pos ) || + (enemy != null && Level.adjacent( newPos, enemy.pos )) || Actor.findChar( newPos ) != null); sprite.move( pos, newPos ); diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Thief.java b/src/com/watabou/pixeldungeon/actors/mobs/Thief.java index 46e06aaba2..02b34de7a7 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Thief.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Thief.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Warlock.java b/src/com/watabou/pixeldungeon/actors/mobs/Warlock.java index de3e863339..d1b5d1584e 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Warlock.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Warlock.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java b/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java index 4f54bc8090..f015a7b21c 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/Yog.java b/src/com/watabou/pixeldungeon/actors/mobs/Yog.java index 8168d20864..2ade52f8b1 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/Yog.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/Yog.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -22,6 +22,7 @@ import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.ResultDescriptions; +import com.watabou.pixeldungeon.Statistics; import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.blobs.Blob; @@ -35,6 +36,7 @@ import com.watabou.pixeldungeon.actors.buffs.Poison; import com.watabou.pixeldungeon.actors.buffs.Sleep; import com.watabou.pixeldungeon.actors.buffs.Terror; +import com.watabou.pixeldungeon.actors.buffs.Vertigo; import com.watabou.pixeldungeon.effects.Pushing; import com.watabou.pixeldungeon.effects.particles.ShadowParticle; import com.watabou.pixeldungeon.items.keys.SkeletonKey; @@ -55,7 +57,7 @@ public class Yog extends Mob { { - name = "Yog-Dzewa"; + name = Dungeon.depth == Statistics.deepestFloor ? "Yog-Dzewa" : "echo of Yog-Dzewa"; spriteClass = YogSprite.class; HP = HT = 300; @@ -267,6 +269,7 @@ public HashSet> resistances() { IMMUNITIES.add( Sleep.class ); IMMUNITIES.add( Terror.class ); IMMUNITIES.add( Poison.class ); + IMMUNITIES.add( Vertigo.class ); } @Override @@ -352,7 +355,6 @@ public boolean attack( Char enemy ) { @Override public boolean act() { - for (int i=0; i < Level.NEIGHBOURS9.length; i++) { GameScene.add( Blob.seed( pos + Level.NEIGHBOURS9[i], 2, Fire.class ) ); } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Bee.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Bee.java new file mode 100644 index 0000000000..4e5d757861 --- /dev/null +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Bee.java @@ -0,0 +1,182 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.actors.mobs.npcs; + +import java.util.HashSet; + +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.actors.buffs.Poison; +import com.watabou.pixeldungeon.actors.mobs.Mob; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.sprites.BeeSprite; +import com.watabou.pixeldungeon.utils.Utils; +import com.watabou.utils.Bundle; +import com.watabou.utils.Random; + +public class Bee extends NPC { + + { + name = "golden bee"; + spriteClass = BeeSprite.class; + + viewDistance = 4; + + WANDERING = new Wandering(); + + flying = true; + state = WANDERING; + } + + private int level; + + private static final String LEVEL = "level"; + + @Override + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( LEVEL, level ); + } + + @Override + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle( bundle ); + spawn( bundle.getInt( LEVEL ) ); + } + + public void spawn( int level ) { + this.level = level; + + HT = (3 + level) * 5; + defenseSkill = 9 + level; + } + + @Override + public int attackSkill( Char target ) { + return defenseSkill; + } + + @Override + public int damageRoll() { + return Random.NormalIntRange( HT / 10, HT / 4 ); + } + + @Override + public int attackProc( Char enemy, int damage ) { + if (enemy instanceof Mob) { + ((Mob)enemy).aggro( this ); + } + return damage; + } + + @Override + protected boolean act() { + HP--; + if (HP <= 0) { + die( null ); + return true; + } else { + return super.act(); + } + } + + protected Char chooseEnemy() { + + if (enemy == null || !enemy.isAlive()) { + HashSet enemies = new HashSet(); + for (Mob mob:Dungeon.level.mobs) { + if (mob.hostile && Level.fieldOfView[mob.pos]) { + enemies.add( mob ); + } + } + + return enemies.size() > 0 ? Random.element( enemies ) : null; + + } else { + + return enemy; + + } + } + + @Override + public String description() { + return + "Despite their small size, golden bees tend " + + "to protect their master fiercely. They don't live long though."; + } + + @Override + public void interact() { + + int curPos = pos; + + moveSprite( pos, Dungeon.hero.pos ); + move( Dungeon.hero.pos ); + + Dungeon.hero.sprite.move( Dungeon.hero.pos, curPos ); + Dungeon.hero.move( curPos ); + + Dungeon.hero.spend( 1 / Dungeon.hero.speed() ); + Dungeon.hero.busy(); + } + + private static final HashSet> IMMUNITIES = new HashSet>(); + static { + IMMUNITIES.add( Poison.class ); + } + + @Override + public HashSet> immunities() { + return IMMUNITIES; + } + + private class Wandering implements AiState { + + @Override + public boolean act( boolean enemyInFOV, boolean justAlerted ) { + if (enemyInFOV) { + + enemySeen = true; + + notice(); + state = HUNTING; + target = enemy.pos; + + } else { + + enemySeen = false; + + int oldPos = pos; + if (getCloser( Dungeon.hero.pos )) { + spend( 1 / speed() ); + return moveSprite( oldPos, pos ); + } else { + spend( TICK ); + } + + } + return true; + } + + @Override + public String status() { + return Utils.format( "This %s is wandering", name ); + } + } +} \ No newline at end of file diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java index cebcb2be2b..1111349362 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -204,7 +204,7 @@ public static void upgrade( Item item1, Item item2 ) { Sample.INSTANCE.play( Assets.SND_EVOKE ); ScrollOfUpgrade.upgrade( Dungeon.hero ); Item.evoke( Dungeon.hero ); - + if (first.isEquipped( Dungeon.hero )) { ((EquipableItem)first).doUnequip( Dungeon.hero, true ); } @@ -212,12 +212,12 @@ public static void upgrade( Item item1, Item item2 ) { GLog.p( TXT_LOOKS_BETTER, first.name() ); Dungeon.hero.spendAndNext( 2f ); Badges.validateItemLevelAquired( first ); - + if (second.isEquipped( Dungeon.hero )) { ((EquipableItem)second).doUnequip( Dungeon.hero, false ); } second.detachAll( Dungeon.hero.belongings.backpack ); - + Quest.reforged = true; Journal.remove( Journal.Feature.TROLL ); diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java index eee7709fb4..57fc34e812 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -102,7 +102,7 @@ public float speed() { @Override protected Char chooseEnemy() { - return DUMMY; + return null; } @Override @@ -133,7 +133,7 @@ public void interact() { GameScene.show( new WndSadGhost( this, item ) ); } else { GameScene.show( new WndQuest( this, Quest.alternative ? TXT_RAT2 : TXT_ROSE2 ) ); - + int newPos = -1; for (int i=0; i < 10; i++) { newPos = Dungeon.level.randomRespawnCell(); @@ -179,11 +179,11 @@ public HashSet> immunities() { } public static class Quest { - + private static boolean spawned; - + private static boolean alternative; - + private static boolean given; private static boolean processed; @@ -279,29 +279,29 @@ public static void spawn( SewerLevel level ) { processed = false; depth = Dungeon.depth; - do { - weapon = (Weapon)Generator.random( Generator.Category.WEAPON ); - } while (weapon instanceof MissileWeapon); - - if (Dungeon.isChallenged( Challenges.NO_ARMOR )) { - armor = (Armor)new ClothArmor().degrade(); - } else { - armor = (Armor)Generator.random( Generator.Category.ARMOR ); - } - - for (int i=0; i < 3; i++) { + for (int i=0; i < 4; i++) { Item another; do { - another = Generator.random( Generator.Category.WEAPON ); + another = (Weapon)Generator.random( Generator.Category.WEAPON ); } while (another instanceof MissileWeapon); - if (another.level > weapon.level) { + + if (weapon == null || another.level > weapon.level) { weapon = (Weapon)another; } - another = Generator.random( Generator.Category.ARMOR ); - if (another.level > armor.level) { - armor = (Armor)another; + } + + if (Dungeon.isChallenged( Challenges.NO_ARMOR )) { + armor = (Armor)new ClothArmor().degrade(); + } else { + armor = (Armor)Generator.random( Generator.Category.ARMOR ); + for (int i=0; i < 3; i++) { + Item another = Generator.random( Generator.Category.ARMOR ); + if (another.level > armor.level) { + armor = (Armor)another; + } } } + weapon.identify(); armor.identify(); } diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java index 330d46bcf3..40eb42dd73 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -47,7 +47,7 @@ public class Imp extends NPC { private static final String TXT_GOLEMS1 = "Are you an adventurer? I love adventurers! You can always rely on them " + - "if something needs to be killed. Am I right? For bounty of course ;)\n" + + "if something needs to be killed. Am I right? For a bounty, of course ;)\n" + "In my case this is _golems_ who need to be killed. You see, I'm going to start a " + "little business here, but these stupid golems are bad for business! " + "It's very hard to negotiate with wandering lumps of granite, damn them! " + @@ -55,7 +55,7 @@ public class Imp extends NPC { private static final String TXT_MONKS1 = "Are you an adventurer? I love adventurers! You can always rely on them " + - "if something needs to be killed. Am I right? For bounty of course ;)\n" + + "if something needs to be killed. Am I right? For a bounty, of course ;)\n" + "In my case this is _monks_ who need to be killed. You see, I'm going to start a " + "little business here, but these lunatics don't buy anything themselves and " + "will scare away other customers. " + diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/ImpShopkeeper.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/ImpShopkeeper.java index eed5255bec..03287d5457 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/ImpShopkeeper.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/ImpShopkeeper.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java index 0cc3434252..865b389606 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -38,8 +38,6 @@ public class MirrorImage extends NPC { spriteClass = MirrorSprite.class; state = HUNTING; - - enemy = DUMMY; } public int tier; @@ -95,7 +93,7 @@ public int attackProc( Char enemy, int damage ) { protected Char chooseEnemy() { - if (enemy == DUMMY || !enemy.isAlive()) { + if (enemy == null || !enemy.isAlive()) { HashSet enemies = new HashSet(); for (Mob mob:Dungeon.level.mobs) { if (mob.hostile && Level.fieldOfView[mob.pos]) { @@ -103,7 +101,7 @@ protected Char chooseEnemy() { } } - enemy = enemies.size() > 0 ? Random.element( enemies ) : DUMMY; + return enemies.size() > 0 ? Random.element( enemies ) : null; } return enemy; diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/NPC.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/NPC.java index fadb76d397..8d0a2ce4ab 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/NPC.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/NPC.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/RatKing.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/RatKing.java index a9e9be8243..de3e0a7efe 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/RatKing.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/RatKing.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -44,7 +44,7 @@ public float speed() { @Override protected Char chooseEnemy() { - return DUMMY; + return null; } @Override diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Shopkeeper.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Shopkeeper.java index 5bcd01b647..170feeb2cc 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Shopkeeper.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Shopkeeper.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java index d91fb0196e..e452527c2f 100644 --- a/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/BadgeBanner.java b/src/com/watabou/pixeldungeon/effects/BadgeBanner.java index 4ae696dfe9..68f5af51b6 100644 --- a/src/com/watabou/pixeldungeon/effects/BadgeBanner.java +++ b/src/com/watabou/pixeldungeon/effects/BadgeBanner.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/BannerSprites.java b/src/com/watabou/pixeldungeon/effects/BannerSprites.java index c7e347e837..06667b20f9 100644 --- a/src/com/watabou/pixeldungeon/effects/BannerSprites.java +++ b/src/com/watabou/pixeldungeon/effects/BannerSprites.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -26,7 +26,8 @@ public enum Type { PIXEL_DUNGEON, BOSS_SLAIN, GAME_OVER, - SELECT_YOUR_HERO + SELECT_YOUR_HERO, + PIXEL_DUNGEON_SIGNS }; public static Image get( Type type ) { @@ -44,6 +45,9 @@ public static Image get( Type type ) { case SELECT_YOUR_HERO: icon.frame( icon.texture.uvRect( 0, 140, 128, 161 ) ); break; + case PIXEL_DUNGEON_SIGNS: + icon.frame( icon.texture.uvRect( 0, 161, 128, 218 ) ); + break; } return icon; } diff --git a/src/com/watabou/pixeldungeon/effects/BlobEmitter.java b/src/com/watabou/pixeldungeon/effects/BlobEmitter.java index 2e142195cc..2cac1588e5 100644 --- a/src/com/watabou/pixeldungeon/effects/BlobEmitter.java +++ b/src/com/watabou/pixeldungeon/effects/BlobEmitter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/CellEmitter.java b/src/com/watabou/pixeldungeon/effects/CellEmitter.java index bb2751e290..248042ed63 100644 --- a/src/com/watabou/pixeldungeon/effects/CellEmitter.java +++ b/src/com/watabou/pixeldungeon/effects/CellEmitter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/CheckedCell.java b/src/com/watabou/pixeldungeon/effects/CheckedCell.java index 154000b42f..5a55ba0020 100644 --- a/src/com/watabou/pixeldungeon/effects/CheckedCell.java +++ b/src/com/watabou/pixeldungeon/effects/CheckedCell.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/DeathRay.java b/src/com/watabou/pixeldungeon/effects/DeathRay.java index f504b10483..0b18587980 100644 --- a/src/com/watabou/pixeldungeon/effects/DeathRay.java +++ b/src/com/watabou/pixeldungeon/effects/DeathRay.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -28,7 +28,7 @@ import com.watabou.utils.PointF; public class DeathRay extends Image { - + private static final double A = 180 / Math.PI; private static final float DURATION = 0.5f; diff --git a/src/com/watabou/pixeldungeon/effects/Degradation.java b/src/com/watabou/pixeldungeon/effects/Degradation.java new file mode 100644 index 0000000000..845e3a9069 --- /dev/null +++ b/src/com/watabou/pixeldungeon/effects/Degradation.java @@ -0,0 +1,156 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.effects; + +import javax.microedition.khronos.opengles.GL10; + +import android.opengl.GLES20; + +import com.watabou.noosa.Group; +import com.watabou.noosa.particles.PixelParticle; +import com.watabou.utils.PointF; +import com.watabou.utils.Random; + +public class Degradation extends Group { + + private static int[] WEAPON = { + +2, -2, + +1, -1, + 0, 0, + -1, +1, + -2, +2, + -2, 0, + 0, +2 + }; + + private static int[] ARMOR = { + -2, -1, + -1, -1, + +1, -1, + +2, -1, + -2, 0, + -1, 0, + 0, 0, + +1, 0, + +2, 0, + -1, +1, + +1, +1, + -1, +2, + 0, +2, + +1, +2 + }; + + private static int[] RING = { + 0, -1, + -1, 0, + 0, 0, + +1, 0, + -1, +1, + +1, +1, + -1, +2, + 0, +2, + +1, +2 + }; + + private static int[] WAND = { + +2, -2, + +1, -1, + 0, 0, + -1, +1, + -2, +2, + +1, -2, + +2, -1 + }; + + public static Degradation weapon( PointF p ) { + return new Degradation( p, WEAPON ); + } + + public static Degradation armor( PointF p ) { + return new Degradation( p, ARMOR ); + } + + public static Degradation ring( PointF p ) { + return new Degradation( p, RING ); + } + + public static Degradation wand( PointF p ) { + return new Degradation( p, WAND ); + } + + private Degradation( PointF p, int[] matrix ) { + + for (int i=0; i < matrix.length; i += 2) { + add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) ); + add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) ); + } + } + + @Override + public void update() { + super.update(); + if (countLiving() == 0) { + killAndErase(); + } + } + + @Override + public void draw() { + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + super.draw(); + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + } + + public static class Speck extends PixelParticle { + + private static final int COLOR = 0xFF4422; + private static final int SIZE = 3; + + public Speck( float x0, float y0, int mx, int my ) { + + super(); + color( COLOR ); + + float x1 = x0 + mx * SIZE; + float y1 = y0 + my * SIZE; + + PointF p = new PointF().polar( Random.Float( 2 * PointF.PI ), 8 ); + x0 += p.x; + y0 += p.y; + + float dx = x1 - x0; + float dy = y1 - y0; + + x = x0; + y = y0; + speed.set( dx, dy ); + acc.set( -dx / 4, -dy / 4 ); + + left = lifespan = 2f; + } + + @Override + public void update() { + super.update(); + + am = 1 - Math.abs( left / lifespan - 0.5f ) * 2; + am *= am; + size( am * SIZE ); + } + } +} diff --git a/src/com/watabou/pixeldungeon/effects/Effects.java b/src/com/watabou/pixeldungeon/effects/Effects.java index 744961ce08..feed6bf1e8 100644 --- a/src/com/watabou/pixeldungeon/effects/Effects.java +++ b/src/com/watabou/pixeldungeon/effects/Effects.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/EmoIcon.java b/src/com/watabou/pixeldungeon/effects/EmoIcon.java index f7601c1976..52f7a1e0fa 100644 --- a/src/com/watabou/pixeldungeon/effects/EmoIcon.java +++ b/src/com/watabou/pixeldungeon/effects/EmoIcon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Fireball.java b/src/com/watabou/pixeldungeon/effects/Fireball.java index 70b366cbd6..8d8cb25be6 100644 --- a/src/com/watabou/pixeldungeon/effects/Fireball.java +++ b/src/com/watabou/pixeldungeon/effects/Fireball.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Flare.java b/src/com/watabou/pixeldungeon/effects/Flare.java index ae8595c5af..749a1cbcd0 100644 --- a/src/com/watabou/pixeldungeon/effects/Flare.java +++ b/src/com/watabou/pixeldungeon/effects/Flare.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -53,10 +53,6 @@ public Flare( int nRays, float radius ) { super( 0, 0, 0, 0 ); - // FIXME - // Texture is incorrectly created every time we need - // to show the effect, it must be refactored - int gradient[] = {0xFFFFFFFF, 0x00FFFFFF}; texture = new Gradient( gradient ); diff --git a/src/com/watabou/pixeldungeon/effects/FloatingText.java b/src/com/watabou/pixeldungeon/effects/FloatingText.java index 86f05d4487..5f554399b5 100644 --- a/src/com/watabou/pixeldungeon/effects/FloatingText.java +++ b/src/com/watabou/pixeldungeon/effects/FloatingText.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -20,6 +20,7 @@ import java.util.ArrayList; import com.watabou.noosa.BitmapText; +import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.pixeldungeon.DungeonTilemap; import com.watabou.pixeldungeon.scenes.GameScene; @@ -35,16 +36,12 @@ public class FloatingText extends BitmapText { private int key = -1; + private float cameraZoom = -1; + private static SparseArray> stacks = new SparseArray>(); public FloatingText() { - super(); - - PixelScene.chooseFont( 9 ); - font = PixelScene.font; - scale.set( PixelScene.scale ); - speed.y = - DISTANCE / LIFESPAN; } @@ -80,6 +77,13 @@ public void destroy() { public void reset( float x, float y, String text, int color ) { revive(); + + if (cameraZoom != Camera.main.zoom) { + cameraZoom = Camera.main.zoom; + PixelScene.chooseFont( 9, cameraZoom ); + font = PixelScene.font; + scale.set( PixelScene.scale ); + } text( text ); hardlight( color ); diff --git a/src/com/watabou/pixeldungeon/effects/Halo.java b/src/com/watabou/pixeldungeon/effects/Halo.java index a9f42da1a7..2d8fbd0c6c 100644 --- a/src/com/watabou/pixeldungeon/effects/Halo.java +++ b/src/com/watabou/pixeldungeon/effects/Halo.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/IceBlock.java b/src/com/watabou/pixeldungeon/effects/IceBlock.java index 24c69b568b..2a79ac791c 100644 --- a/src/com/watabou/pixeldungeon/effects/IceBlock.java +++ b/src/com/watabou/pixeldungeon/effects/IceBlock.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Identification.java b/src/com/watabou/pixeldungeon/effects/Identification.java index cb91bcb5dd..a706eba4cf 100644 --- a/src/com/watabou/pixeldungeon/effects/Identification.java +++ b/src/com/watabou/pixeldungeon/effects/Identification.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -66,13 +66,16 @@ public void draw() { public static class Speck extends PixelParticle { + private static final int COLOR = 0x4488CC; + private static final int SIZE = 3; + public Speck( float x0, float y0, int mx, int my ) { super(); - color( 0x4488CC ); + color( COLOR ); - float x1 = x0 + mx * 3; - float y1 = y0 + my * 3; + float x1 = x0 + mx * SIZE; + float y1 = y0 + my * SIZE; PointF p = new PointF().polar( Random.Float( 2 * PointF.PI ), 8 ); x0 += p.x; @@ -95,7 +98,7 @@ public void update() { am = 1 - Math.abs( left / lifespan - 0.5f ) * 2; am *= am; - size( am * 2 ); + size( am * SIZE ); } } } diff --git a/src/com/watabou/pixeldungeon/effects/Lightning.java b/src/com/watabou/pixeldungeon/effects/Lightning.java index f1ab3a1259..3b717c025a 100644 --- a/src/com/watabou/pixeldungeon/effects/Lightning.java +++ b/src/com/watabou/pixeldungeon/effects/Lightning.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/MagicMissile.java b/src/com/watabou/pixeldungeon/effects/MagicMissile.java index 9e938140e5..3707a7e4d1 100644 --- a/src/com/watabou/pixeldungeon/effects/MagicMissile.java +++ b/src/com/watabou/pixeldungeon/effects/MagicMissile.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Pushing.java b/src/com/watabou/pixeldungeon/effects/Pushing.java index 7dfbb8406d..e7a63f828e 100644 --- a/src/com/watabou/pixeldungeon/effects/Pushing.java +++ b/src/com/watabou/pixeldungeon/effects/Pushing.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Ripple.java b/src/com/watabou/pixeldungeon/effects/Ripple.java index d45c8df266..118fe4b3fe 100644 --- a/src/com/watabou/pixeldungeon/effects/Ripple.java +++ b/src/com/watabou/pixeldungeon/effects/Ripple.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/ShadowBox.java b/src/com/watabou/pixeldungeon/effects/ShadowBox.java new file mode 100644 index 0000000000..6f751d3c74 --- /dev/null +++ b/src/com/watabou/pixeldungeon/effects/ShadowBox.java @@ -0,0 +1,46 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.effects; + +import com.watabou.gltextures.SmartTexture; +import com.watabou.noosa.NinePatch; +import com.watabou.pixeldungeon.Assets; + +public class ShadowBox extends NinePatch { + + public static final float SIZE = 16; + + public ShadowBox() { + super( Assets.SHADOW, 1 ); + + texture.filter( SmartTexture.LINEAR, SmartTexture.LINEAR ); + + scale.set( SIZE, SIZE ); + } + + @Override + public void size(float width, float height) { + super.size( width / SIZE, height / SIZE ); + } + + public void boxRect( float x, float y, float width, float height ) { + this.x = x - SIZE; + this.y = y - SIZE; + size( width + SIZE * 2, height + SIZE * 2 ); + } +} diff --git a/src/com/watabou/pixeldungeon/effects/Speck.java b/src/com/watabou/pixeldungeon/effects/Speck.java index c6844cdc64..7b7fc82626 100644 --- a/src/com/watabou/pixeldungeon/effects/Speck.java +++ b/src/com/watabou/pixeldungeon/effects/Speck.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -134,7 +134,7 @@ public void reset( int index, float x, float y, int type ) { break; case FORGE: - speed.polar( Random.Float( -3.1415926f, 0 ), Random.Float( 64 ) ); + speed.polar( -Random.Float( 3.1415926f ), Random.Float( 64 ) ); acc.set( 0, 128 ); angle = Random.Float( 360 ); angularSpeed = Random.Float( -360, +360 ); @@ -142,7 +142,7 @@ public void reset( int index, float x, float y, int type ) { break; case EVOKE: - speed.polar( Random.Float( -3.1415926f, 0 ), 50 ); + speed.polar( -Random.Float( 3.1415926f ), 50 ); acc.set( 0, 50 ); angle = Random.Float( 360 ); angularSpeed = Random.Float( -180, +180 ); diff --git a/src/com/watabou/pixeldungeon/effects/SpellSprite.java b/src/com/watabou/pixeldungeon/effects/SpellSprite.java index f27e1786f7..9303b2c40a 100644 --- a/src/com/watabou/pixeldungeon/effects/SpellSprite.java +++ b/src/com/watabou/pixeldungeon/effects/SpellSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Splash.java b/src/com/watabou/pixeldungeon/effects/Splash.java index cf2d9ea821..ed56c3cb88 100644 --- a/src/com/watabou/pixeldungeon/effects/Splash.java +++ b/src/com/watabou/pixeldungeon/effects/Splash.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/TorchHalo.java b/src/com/watabou/pixeldungeon/effects/TorchHalo.java index fe89081e63..c0391282ef 100644 --- a/src/com/watabou/pixeldungeon/effects/TorchHalo.java +++ b/src/com/watabou/pixeldungeon/effects/TorchHalo.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/Wound.java b/src/com/watabou/pixeldungeon/effects/Wound.java index 6e4c60306d..253d9d1c7d 100644 --- a/src/com/watabou/pixeldungeon/effects/Wound.java +++ b/src/com/watabou/pixeldungeon/effects/Wound.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/BlastParticle.java b/src/com/watabou/pixeldungeon/effects/particles/BlastParticle.java new file mode 100644 index 0000000000..689c4bb500 --- /dev/null +++ b/src/com/watabou/pixeldungeon/effects/particles/BlastParticle.java @@ -0,0 +1,62 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.effects.particles; + +import com.watabou.noosa.particles.Emitter; +import com.watabou.noosa.particles.PixelParticle; +import com.watabou.noosa.particles.Emitter.Factory; +import com.watabou.utils.Random; + +public class BlastParticle extends PixelParticle.Shrinking { + + public static final Emitter.Factory FACTORY = new Factory() { + @Override + public void emit( Emitter emitter, int index, float x, float y ) { + ((BlastParticle)emitter.recycle( BlastParticle.class )).reset( x, y ); + } + @Override + public boolean lightMode() { + return true; + }; + }; + + public BlastParticle() { + super(); + + color( 0xEE7722 ); + acc.set( 0, +50 ); + } + + public void reset( float x, float y ) { + revive(); + + this.x = x; + this.y = y; + + left = lifespan = Random.Float(); + + size = 8; + speed.polar( -Random.Float( 3.1415926f ), Random.Float( 32, 64 ) ); + } + + @Override + public void update() { + super.update(); + am = left > 0.8f ? (1 - left) * 5 : 1; + } +} \ No newline at end of file diff --git a/src/com/watabou/pixeldungeon/effects/particles/BloodParticle.java b/src/com/watabou/pixeldungeon/effects/particles/BloodParticle.java index 33b91e5c7d..f7407ed93e 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/BloodParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/BloodParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/EarthParticle.java b/src/com/watabou/pixeldungeon/effects/particles/EarthParticle.java index 1d1cb4a706..d145cd35db 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/EarthParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/EarthParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/ElmoParticle.java b/src/com/watabou/pixeldungeon/effects/particles/ElmoParticle.java index d87cf01125..5d0890305d 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/ElmoParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/ElmoParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/EnergyParticle.java b/src/com/watabou/pixeldungeon/effects/particles/EnergyParticle.java index 31c97d5c61..051eb47477 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/EnergyParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/EnergyParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -42,7 +42,7 @@ public EnergyParticle() { lifespan = 1f; color( 0xFFFFAA ); - speed.polar( Random.Float( 2 * PointF.PI ), Random.Float( 24, 32 ) ); + speed.polar( Random.Float( PointF.PI2 ), Random.Float( 24, 32 ) ); } public void reset( float x, float y ) { diff --git a/src/com/watabou/pixeldungeon/effects/particles/FlameParticle.java b/src/com/watabou/pixeldungeon/effects/particles/FlameParticle.java index ae344f5d46..b1fd6e7115 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/FlameParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/FlameParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/FlowParticle.java b/src/com/watabou/pixeldungeon/effects/particles/FlowParticle.java index e62780075e..62e527481d 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/FlowParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/FlowParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/LeafParticle.java b/src/com/watabou/pixeldungeon/effects/particles/LeafParticle.java index a0112a417b..3c0123e56b 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/LeafParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/LeafParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/PoisonParticle.java b/src/com/watabou/pixeldungeon/effects/particles/PoisonParticle.java index 16554f67a0..d5550d53de 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/PoisonParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/PoisonParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -63,7 +63,7 @@ public void resetMissile( float x, float y ) { left = lifespan; - speed.polar( Random.Float( 3.1415926f ), Random.Float( 6 ) ); + speed.polar( -Random.Float( 3.1415926f ), Random.Float( 6 ) ); } public void resetSplash( float x, float y ) { diff --git a/src/com/watabou/pixeldungeon/effects/particles/PurpleParticle.java b/src/com/watabou/pixeldungeon/effects/particles/PurpleParticle.java index ca378fe525..fe8be5239b 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/PurpleParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/PurpleParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -21,6 +21,7 @@ import com.watabou.noosa.particles.PixelParticle; import com.watabou.noosa.particles.Emitter.Factory; import com.watabou.utils.ColorMath; +import com.watabou.utils.PointF; import com.watabou.utils.Random; public class PurpleParticle extends PixelParticle { @@ -66,7 +67,7 @@ public void resetBurst( float x, float y ) { this.x = x; this.y = y; - speed.polar( Random.Float( 360 ), Random.Float( 16, 32 ) ); + speed.polar( Random.Float( PointF.PI2 ), Random.Float( 16, 32 ) ); left = lifespan; } diff --git a/src/com/watabou/pixeldungeon/effects/particles/ShadowParticle.java b/src/com/watabou/pixeldungeon/effects/particles/ShadowParticle.java index 0df72649a2..64c1614ff4 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/ShadowParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/ShadowParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -65,7 +65,7 @@ public void resetCurse( float x, float y ) { size = 8; left = lifespan = 0.5f; - speed.polar( Random.Float( 2 * PointF.PI ), Random.Float( 16, 32 ) ); + speed.polar( Random.Float( PointF.PI2 ), Random.Float( 16, 32 ) ); this.x = x - speed.x * lifespan; this.y = y - speed.y * lifespan; } diff --git a/src/com/watabou/pixeldungeon/effects/particles/ShaftParticle.java b/src/com/watabou/pixeldungeon/effects/particles/ShaftParticle.java index ba4c2769d5..f63eaffd3a 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/ShaftParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/ShaftParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/SmokeParticle.java b/src/com/watabou/pixeldungeon/effects/particles/SmokeParticle.java new file mode 100644 index 0000000000..6fb90a22b1 --- /dev/null +++ b/src/com/watabou/pixeldungeon/effects/particles/SmokeParticle.java @@ -0,0 +1,60 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.effects.particles; + +import com.watabou.noosa.particles.Emitter; +import com.watabou.noosa.particles.PixelParticle; +import com.watabou.noosa.particles.Emitter.Factory; +import com.watabou.utils.Random; + +public class SmokeParticle extends PixelParticle { + + public static final Emitter.Factory FACTORY = new Factory() { + @Override + public void emit( Emitter emitter, int index, float x, float y ) { + ((SmokeParticle)emitter.recycle( SmokeParticle.class )).reset( x, y ); + } + }; + + public SmokeParticle() { + super(); + + color( 0x222222 ); + + acc.set( 0, -40 ); + } + + public void reset( float x, float y ) { + revive(); + + this.x = x; + this.y = y; + + left = lifespan = Random.Float( 0.6f, 1f ); + speed.set( Random.Float( -4, +4 ), Random.Float( -8, +8 ) ); + } + + @Override + public void update() { + super.update(); + + float p = left / lifespan; + am = p > 0.8f ? 2 - 2*p : p * 0.5f; + size( 16 - p * 8 ); + } +} \ No newline at end of file diff --git a/src/com/watabou/pixeldungeon/effects/particles/SnowParticle.java b/src/com/watabou/pixeldungeon/effects/particles/SnowParticle.java index 8b4b809ca7..70a117e3d9 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/SnowParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/SnowParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/SparkParticle.java b/src/com/watabou/pixeldungeon/effects/particles/SparkParticle.java index f817e432bb..45b19f41d7 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/SparkParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/SparkParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -51,7 +51,7 @@ public void reset( float x, float y ) { left = lifespan = Random.Float( 0.5f, 1.0f ); - speed.polar( Random.Float( 3.1415926f ), Random.Float( 20, 40 ) ); + speed.polar( -Random.Float( 3.1415926f ), Random.Float( 20, 40 ) ); } @Override diff --git a/src/com/watabou/pixeldungeon/effects/particles/WebParticle.java b/src/com/watabou/pixeldungeon/effects/particles/WebParticle.java index 4b9ef61bb5..833749c1e9 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/WebParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/WebParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/effects/particles/WindParticle.java b/src/com/watabou/pixeldungeon/effects/particles/WindParticle.java index 676fd29e53..39d6811fb8 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/WindParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/WindParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -36,7 +36,7 @@ public void emit( Emitter emitter, int index, float x, float y ) { } }; - private static float angle = Random.Float( PointF.PI * 2 ); + private static float angle = Random.Float( PointF.PI2 ); private static PointF speed = new PointF().polar( angle, 5 ); private float size; diff --git a/src/com/watabou/pixeldungeon/effects/particles/WoolParticle.java b/src/com/watabou/pixeldungeon/effects/particles/WoolParticle.java index 1361d962aa..174948c87d 100644 --- a/src/com/watabou/pixeldungeon/effects/particles/WoolParticle.java +++ b/src/com/watabou/pixeldungeon/effects/particles/WoolParticle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Amulet.java b/src/com/watabou/pixeldungeon/items/Amulet.java index 8e2ef18a32..4856a89bc5 100644 --- a/src/com/watabou/pixeldungeon/items/Amulet.java +++ b/src/com/watabou/pixeldungeon/items/Amulet.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Ankh.java b/src/com/watabou/pixeldungeon/items/Ankh.java index d7e94f08a1..adc12fad07 100644 --- a/src/com/watabou/pixeldungeon/items/Ankh.java +++ b/src/com/watabou/pixeldungeon/items/Ankh.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/ArmorKit.java b/src/com/watabou/pixeldungeon/items/ArmorKit.java index 487de42bc1..5d380d5343 100644 --- a/src/com/watabou/pixeldungeon/items/ArmorKit.java +++ b/src/com/watabou/pixeldungeon/items/ArmorKit.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Bomb.java b/src/com/watabou/pixeldungeon/items/Bomb.java new file mode 100644 index 0000000000..5516838e25 --- /dev/null +++ b/src/com/watabou/pixeldungeon/items/Bomb.java @@ -0,0 +1,115 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.items; + +import com.watabou.noosa.audio.Sample; +import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.actors.Actor; +import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.actors.buffs.Buff; +import com.watabou.pixeldungeon.actors.buffs.Paralysis; +import com.watabou.pixeldungeon.effects.CellEmitter; +import com.watabou.pixeldungeon.effects.particles.BlastParticle; +import com.watabou.pixeldungeon.effects.particles.SmokeParticle; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.levels.Terrain; +import com.watabou.pixeldungeon.scenes.GameScene; +import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; +import com.watabou.utils.Random; + +public class Bomb extends Item { + + { + name = "bomb"; + image = ItemSpriteSheet.BOMB; + defaultAction = AC_THROW; + stackable = true; + } + + @Override + protected void onThrow( int cell ) { + if (Level.pit[cell]) { + super.onThrow( cell ); + } else { + Sample.INSTANCE.play( Assets.SND_BLAST, 2 ); + + if (Dungeon.visible[cell]) { + CellEmitter.center( cell ).burst( BlastParticle.FACTORY, 30 ); + } + + boolean terrainAffected = false; + for (int n : Level.NEIGHBOURS9) { + int c = cell + n; + if (c >= 0 && c < Level.LENGTH) { + if (Dungeon.visible[c]) { + CellEmitter.get( c ).burst( SmokeParticle.FACTORY, 4 ); + } + + if (Level.flamable[c]) { + Level.set( c, Terrain.EMBERS ); + GameScene.updateMap( c ); + terrainAffected = true; + } + + Char ch = Actor.findChar( c ); + if (ch != null) { + int dmg = Random.Int( 1 + Dungeon.depth, 10 + Dungeon.depth * 2 ) - Random.Int( ch.dr() ); + if (dmg > 0) { + ch.damage( dmg, this ); + if (ch.isAlive()) { + Buff.prolong( ch, Paralysis.class, 2 ); + } + } + } + } + } + + if (terrainAffected) { + Dungeon.observe(); + } + } + } + + @Override + public boolean isUpgradable() { + return false; + } + + @Override + public boolean isIdentified() { + return true; + } + + @Override + public Item random() { + quantity = Random.IntRange( 1, 3 ); + return this; + } + + @Override + public int price() { + return 10 * quantity; + } + + @Override + public String info() { + return + "This is a relatively small bomb, filled with black powder. Conveniently, its fuse is lit automatically when the bomb is thrown."; + } +} diff --git a/src/com/watabou/pixeldungeon/items/DewVial.java b/src/com/watabou/pixeldungeon/items/DewVial.java index 57763345c8..5114afa109 100644 --- a/src/com/watabou/pixeldungeon/items/DewVial.java +++ b/src/com/watabou/pixeldungeon/items/DewVial.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Dewdrop.java b/src/com/watabou/pixeldungeon/items/Dewdrop.java index 6bcc6f4e45..40d04a9da4 100644 --- a/src/com/watabou/pixeldungeon/items/Dewdrop.java +++ b/src/com/watabou/pixeldungeon/items/Dewdrop.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/EquipableItem.java b/src/com/watabou/pixeldungeon/items/EquipableItem.java index 3481ce6f6e..c5245550c0 100644 --- a/src/com/watabou/pixeldungeon/items/EquipableItem.java +++ b/src/com/watabou/pixeldungeon/items/EquipableItem.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -92,7 +92,7 @@ public boolean doUnequip( Hero hero, boolean collect, boolean single ) { return true; } - public boolean doUnequip( Hero hero, boolean collect ) { + public final boolean doUnequip( Hero hero, boolean collect ) { return doUnequip( hero, collect, true ); } } diff --git a/src/com/watabou/pixeldungeon/items/Generator.java b/src/com/watabou/pixeldungeon/items/Generator.java index 4e60e67a90..41f9a1cbcb 100644 --- a/src/com/watabou/pixeldungeon/items/Generator.java +++ b/src/com/watabou/pixeldungeon/items/Generator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -48,7 +48,8 @@ public static enum Category { RING ( 2, Ring.class ), SEED ( 5, Plant.Seed.class ), FOOD ( 0, Food.class ), - GOLD ( 50, Gold.class ); + GOLD ( 50, Gold.class ), + MISC ( 5, Item.class ); public Class[] classes; public float[] probs; @@ -84,16 +85,16 @@ public static int order( Item item ) { ScrollOfIdentify.class, ScrollOfTeleportation.class, ScrollOfRemoveCurse.class, - ScrollOfUpgrade.class, ScrollOfRecharging.class, ScrollOfMagicMapping.class, ScrollOfChallenge.class, ScrollOfTerror.class, ScrollOfLullaby.class, - ScrollOfWeaponUpgrade.class, ScrollOfPsionicBlast.class, - ScrollOfMirrorImage.class }; - Category.SCROLL.probs = new float[]{ 30, 10, 15, 0, 10, 15, 12, 8, 8, 0, 4, 6 }; + ScrollOfMirrorImage.class, + ScrollOfUpgrade.class, + ScrollOfEnchantment.class }; + Category.SCROLL.probs = new float[]{ 30, 10, 15, 10, 15, 12, 8, 8, 4, 6, 0, 1 }; Category.POTION.classes = new Class[]{ PotionOfHealing.class, @@ -186,6 +187,11 @@ public static int order( Item item ) { Fadeleaf.Seed.class, Rotberry.Seed.class }; Category.SEED.probs = new float[]{ 1, 1, 1, 1, 1, 1, 1, 0 }; + + Category.MISC.classes = new Class[]{ + Bomb.class, + Honeypot.class}; + Category.MISC.probs = new float[]{ 2, 1 }; } public static void reset() { diff --git a/src/com/watabou/pixeldungeon/items/Gold.java b/src/com/watabou/pixeldungeon/items/Gold.java index 26ea0f86bc..4968fba3ce 100644 --- a/src/com/watabou/pixeldungeon/items/Gold.java +++ b/src/com/watabou/pixeldungeon/items/Gold.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Heap.java b/src/com/watabou/pixeldungeon/items/Heap.java index 04feb32f8a..70c9d8c6ef 100644 --- a/src/com/watabou/pixeldungeon/items/Heap.java +++ b/src/com/watabou/pixeldungeon/items/Heap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -25,12 +25,17 @@ import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.Statistics; +import com.watabou.pixeldungeon.actors.buffs.Buff; +import com.watabou.pixeldungeon.actors.buffs.Burning; +import com.watabou.pixeldungeon.actors.buffs.Frost; import com.watabou.pixeldungeon.actors.hero.Hero; +import com.watabou.pixeldungeon.actors.mobs.Mimic; import com.watabou.pixeldungeon.actors.mobs.Wraith; import com.watabou.pixeldungeon.effects.CellEmitter; import com.watabou.pixeldungeon.effects.Speck; import com.watabou.pixeldungeon.effects.Splash; import com.watabou.pixeldungeon.effects.particles.ElmoParticle; +import com.watabou.pixeldungeon.effects.particles.FlameParticle; import com.watabou.pixeldungeon.effects.particles.ShadowParticle; import com.watabou.pixeldungeon.items.food.ChargrilledMeat; import com.watabou.pixeldungeon.items.food.FrozenCarpaccio; @@ -39,12 +44,15 @@ import com.watabou.pixeldungeon.plants.Plant.Seed; import com.watabou.pixeldungeon.sprites.ItemSprite; import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; +import com.watabou.pixeldungeon.utils.GLog; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Random; public class Heap implements Bundlable { + private static final String TXT_MIMIC = "This is a mimic!"; + private static final int SEEDS_TO_POTION = 3; public enum Type { @@ -54,7 +62,8 @@ public enum Type { LOCKED_CHEST, CRYSTAL_CHEST, TOMB, - SKELETON + SKELETON, + MIMIC } public Type type = Type.HEAP; @@ -62,7 +71,7 @@ public enum Type { public ItemSprite sprite; - protected LinkedList items = new LinkedList(); + public LinkedList items = new LinkedList(); public int image() { switch (type) { @@ -70,6 +79,7 @@ public int image() { case FOR_SALE: return size() > 0 ? items.peek().image() : 0; case CHEST: + case MIMIC: return ItemSpriteSheet.CHEST; case LOCKED_CHEST: return ItemSpriteSheet.LOCKED_CHEST; @@ -90,6 +100,14 @@ public ItemSprite.Glowing glowing() { public void open( Hero hero ) { switch (type) { + case MIMIC: + if (Mimic.spawnAt( pos, items ) != null) { + GLog.n( TXT_MIMIC ); + destroy(); + } else { + type = Type.CHEST; + } + break; case TOMB: Wraith.spawnAround( hero.pos ); break; @@ -109,9 +127,11 @@ public void open( Hero hero ) { default: } - type = Type.HEAP; - sprite.link(); - sprite.drop(); + if (type != Type.MIMIC) { + type = Type.HEAP; + sprite.link(); + sprite.drop(); + } } public int size() { @@ -171,6 +191,14 @@ public void replace( Item a, Item b ) { public void burn() { + if (type == Type.MIMIC) { + Mimic m = Mimic.spawnAt( pos, items ); + if (m != null) { + Buff.affect( m, Burning.class ).reignite( m ); + m.sprite.emitter().burst( FlameParticle.FACTORY, 5 ); + destroy(); + } + } if (type != Type.HEAP) { return; } @@ -212,6 +240,13 @@ public void burn() { public void freeze() { + if (type == Type.MIMIC) { + Mimic m = Mimic.spawnAt( pos, items ); + if (m != null) { + Buff.prolong( m, Frost.class, Frost.duration( m ) * Random.Float( 1.0f, 1.5f ) ); + destroy(); + } + } if (type != Type.HEAP) { return; } diff --git a/src/com/watabou/pixeldungeon/items/Honeypot.java b/src/com/watabou/pixeldungeon/items/Honeypot.java new file mode 100644 index 0000000000..c0efb9cd96 --- /dev/null +++ b/src/com/watabou/pixeldungeon/items/Honeypot.java @@ -0,0 +1,136 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.items; + +import java.util.ArrayList; + +import com.watabou.noosa.audio.Sample; +import com.watabou.noosa.tweeners.AlphaTweener; +import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.actors.Actor; +import com.watabou.pixeldungeon.actors.hero.Hero; +import com.watabou.pixeldungeon.actors.mobs.npcs.Bee; +import com.watabou.pixeldungeon.effects.Pushing; +import com.watabou.pixeldungeon.effects.Splash; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.scenes.GameScene; +import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; +import com.watabou.utils.Random; + +public class Honeypot extends Item { + + public static final String AC_SHATTER = "SHATTER"; + + { + name = "honeypot"; + image = ItemSpriteSheet.HONEYPOT; + defaultAction = AC_THROW; + stackable = true; + } + + @Override + public ArrayList actions( Hero hero ) { + ArrayList actions = super.actions( hero ); + actions.add( AC_SHATTER ); + return actions; + } + + @Override + public void execute( final Hero hero, String action ) { + if (action.equals( AC_SHATTER )) { + + hero.sprite.zap( hero.pos ); + shatter( hero.pos ); + + detach( hero.belongings.backpack ); + hero.spendAndNext( TIME_TO_THROW ); + + } else { + super.execute( hero, action ); + } + } + + @Override + protected void onThrow( int cell ) { + if (Level.pit[cell]) { + super.onThrow( cell ); + } else { + shatter( cell ); + } + } + + private void shatter( int pos ) { + Sample.INSTANCE.play( Assets.SND_SHATTER ); + + if (Dungeon.visible[pos]) { + Splash.at( pos, 0xffd500, 5 ); + } + + int newPos = pos; + if (Actor.findChar( pos ) != null) { + ArrayList candidates = new ArrayList(); + boolean[] passable = Level.passable; + + for (int n : Level.NEIGHBOURS4) { + int c = pos + n; + if (passable[c] && Actor.findChar( c ) == null) { + candidates.add( c ); + } + } + + newPos = candidates.size() > 0 ? Random.element( candidates ) : -1; + } + + if (newPos != -1) { + Bee bee = new Bee(); + bee.spawn( Dungeon.depth ); + bee.HP = bee.HT; + bee.pos = newPos; + + GameScene.add( bee ); + Actor.addDelayed( new Pushing( bee, pos, newPos ), -1 ); + + bee.sprite.alpha( 0 ); + bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) ); + + Sample.INSTANCE.play( Assets.SND_BEE ); + } + } + + @Override + public boolean isUpgradable() { + return false; + } + + @Override + public boolean isIdentified() { + return true; + } + + @Override + public int price() { + return 50 * quantity; + } + + @Override + public String info() { + return + "There is not much honey in this small honeypot, but there is a golden bee there and it doesn't want to leave it."; + } +} diff --git a/src/com/watabou/pixeldungeon/items/Item.java b/src/com/watabou/pixeldungeon/items/Item.java index 5a7d0097bd..cd06a03ab8 100644 --- a/src/com/watabou/pixeldungeon/items/Item.java +++ b/src/com/watabou/pixeldungeon/items/Item.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -29,12 +29,18 @@ import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.buffs.SnipersMark; import com.watabou.pixeldungeon.actors.hero.Hero; +import com.watabou.pixeldungeon.effects.Degradation; import com.watabou.pixeldungeon.effects.Speck; +import com.watabou.pixeldungeon.items.armor.Armor; import com.watabou.pixeldungeon.items.bags.Bag; +import com.watabou.pixeldungeon.items.rings.Ring; +import com.watabou.pixeldungeon.items.wands.Wand; +import com.watabou.pixeldungeon.items.weapon.Weapon; import com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon; import com.watabou.pixeldungeon.mechanics.Ballistica; import com.watabou.pixeldungeon.scenes.CellSelector; import com.watabou.pixeldungeon.scenes.GameScene; +import com.watabou.pixeldungeon.sprites.CharSprite; import com.watabou.pixeldungeon.sprites.ItemSprite; import com.watabou.pixeldungeon.sprites.MissileSprite; import com.watabou.pixeldungeon.ui.QuickSlot; @@ -43,16 +49,22 @@ import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Callback; +import com.watabou.utils.PointF; public class Item implements Bundlable { - private static final String TXT_PACK_FULL = "Your pack is too full for the %s"; + private static final String TXT_PACK_FULL = "Your pack is too full for the %s"; + + private static final String TXT_DEGRADED = "Because of frequent use, your %s has degraded."; + private static final String TXT_GONNA_DEGRADE = "Because of frequent use, your %s is going to degrade soon."; private static final String TXT_TO_STRING = "%s"; private static final String TXT_TO_STRING_X = "%s x%d"; private static final String TXT_TO_STRING_LVL = "%s%+d"; private static final String TXT_TO_STRING_LVL_X = "%s%+d x%d"; + private static final float DURABILITY_WARNING_LEVEL = 1/6f; + protected static final float TIME_TO_THROW = 1.0f; protected static final float TIME_TO_PICK_UP = 1.0f; protected static final float TIME_TO_DROP = 0.5f; @@ -65,16 +77,17 @@ public class Item implements Bundlable { protected String name = "smth"; protected int image = 0; + public boolean stackable = false; protected int quantity = 1; public int level = 0; public boolean levelKnown = false; + private int durability = maxDurability(); public boolean cursed; public boolean cursedKnown; - // Unique items persist through revival public boolean unique = false; private static Comparator itemComparator = new Comparator() { @@ -132,7 +145,7 @@ public void execute( Hero hero, String action ) { public void execute( Hero hero ) { execute( hero, defaultAction ); } - + protected void onThrow( int cell ) { Heap heap = Dungeon.level.drop( this, cell ); if (!heap.isEmpty()) { @@ -241,12 +254,14 @@ public Item upgrade() { cursed = false; cursedKnown = true; - this.level++; + + level++; + fix(); return this; } - public Item upgrade( int n ) { + final public Item upgrade( int n ) { for (int i=0; i < n; i++) { upgrade(); } @@ -256,12 +271,13 @@ public Item upgrade( int n ) { public Item degrade() { - this.level--; + this.level--; + fix(); return this; } - public Item degrade( int n ) { + final public Item degrade( int n ) { for (int i=0; i < n; i++) { degrade(); } @@ -269,6 +285,57 @@ public Item degrade( int n ) { return this; } + public void use() { + if (level > 0) { + int threshold = (int)(maxDurability() * DURABILITY_WARNING_LEVEL); + if (durability-- >= threshold && threshold > durability) { + GLog.w( TXT_GONNA_DEGRADE, name() ); + } + if (durability <= 0) { + degrade(); + if (levelKnown) { + GLog.n( TXT_DEGRADED, name() ); + Dungeon.hero.interrupt(); + + CharSprite sprite = Dungeon.hero.sprite; + PointF point = sprite.center().offset( 0, -16 ); + if (this instanceof Weapon) { + sprite.parent.add( Degradation.weapon( point ) ); + } else if (this instanceof Armor) { + sprite.parent.add( Degradation.armor( point ) ); + } else if (this instanceof Ring) { + sprite.parent.add( Degradation.ring( point ) ); + } else if (this instanceof Wand) { + sprite.parent.add( Degradation.wand( point ) ); + } + Sample.INSTANCE.play( Assets.SND_DEGRADE ); + } + } + } + } + + public void fix() { + durability = maxDurability(); + } + + public void polish() { + if (durability < maxDurability()) { + durability++; + } + } + + public int durability() { + return durability; + } + + public int maxDurability( int lvl ) { + return 1; + } + + final public int maxDurability() { + return maxDurability( level ); + } + public int visiblyUpgraded() { return levelKnown ? level : 0; } @@ -376,7 +443,13 @@ public String status() { } public void updateQuickslot() { - if ((stackable && Dungeon.quickslot == getClass()) || Dungeon.quickslot == this) { + + if (stackable) { + Class cl = getClass(); + if (QuickSlot.primaryValue == cl || QuickSlot.secondaryValue == cl) { + QuickSlot.refresh(); + } + } else if (QuickSlot.primaryValue == this || QuickSlot.secondaryValue == this) { QuickSlot.refresh(); } } @@ -386,7 +459,7 @@ public void updateQuickslot() { private static final String LEVEL_KNOWN = "levelKnown"; private static final String CURSED = "cursed"; private static final String CURSED_KNOWN = "cursedKnown"; - private static final String QUICKSLOT = "quickslot"; + private static final String DURABILITY = "durability"; @Override public void storeInBundle( Bundle bundle ) { @@ -395,9 +468,10 @@ public void storeInBundle( Bundle bundle ) { bundle.put( LEVEL_KNOWN, levelKnown ); bundle.put( CURSED, cursed ); bundle.put( CURSED_KNOWN, cursedKnown ); - if (this == Dungeon.quickslot) { - bundle.put( QUICKSLOT, true ); + if (isUpgradable()) { + bundle.put( DURABILITY, durability ); } + QuickSlot.save( bundle, this ); } @Override @@ -415,9 +489,14 @@ public void restoreFromBundle( Bundle bundle ) { cursed = bundle.getBoolean( CURSED ); - if (bundle.getBoolean( QUICKSLOT )) { - Dungeon.quickslot = this; + if (isUpgradable()) { + durability = bundle.getInt( DURABILITY ); + } + if (durability <= 0) { + durability = maxDurability( level ); } + + QuickSlot.restore( bundle, this ); } public void cast( final Hero user, int dst ) { @@ -426,16 +505,23 @@ public void cast( final Hero user, int dst ) { user.sprite.zap( cell ); user.busy(); + Sample.INSTANCE.play( Assets.SND_MISS, 0.6f, 0.6f, 1.5f ); + Char enemy = Actor.findChar( cell ); QuickSlot.target( this, enemy ); + // FIXME!!! float delay = TIME_TO_THROW; if (this instanceof MissileWeapon) { - - // FIXME delay *= ((MissileWeapon)this).speedFactor( user ); - if (enemy != null && enemy.buff( SnipersMark.class ) != null) { - delay *= 0.5f; + if (enemy != null) { + SnipersMark mark = user.buff( SnipersMark.class ); + if (mark != null) { + if (mark.object == enemy.id()) { + delay *= 0.5f; + } + user.remove( mark ); + } } } final float finalDelay = delay; diff --git a/src/com/watabou/pixeldungeon/items/ItemStatusHandler.java b/src/com/watabou/pixeldungeon/items/ItemStatusHandler.java index ca3e41cd46..c5687d16f0 100644 --- a/src/com/watabou/pixeldungeon/items/ItemStatusHandler.java +++ b/src/com/watabou/pixeldungeon/items/ItemStatusHandler.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/KindOfWeapon.java b/src/com/watabou/pixeldungeon/items/KindOfWeapon.java index 2dc90a2939..e4b192d7f8 100644 --- a/src/com/watabou/pixeldungeon/items/KindOfWeapon.java +++ b/src/com/watabou/pixeldungeon/items/KindOfWeapon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/LloydsBeacon.java b/src/com/watabou/pixeldungeon/items/LloydsBeacon.java index 5be193943f..f045dc6cbe 100644 --- a/src/com/watabou/pixeldungeon/items/LloydsBeacon.java +++ b/src/com/watabou/pixeldungeon/items/LloydsBeacon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Stylus.java b/src/com/watabou/pixeldungeon/items/Stylus.java deleted file mode 100644 index 2ad363ff7f..0000000000 --- a/src/com/watabou/pixeldungeon/items/Stylus.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya - * - * 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.watabou.pixeldungeon.items; - -import java.util.ArrayList; - -import com.watabou.noosa.audio.Sample; -import com.watabou.pixeldungeon.Assets; -import com.watabou.pixeldungeon.actors.hero.Hero; -import com.watabou.pixeldungeon.effects.particles.PurpleParticle; -import com.watabou.pixeldungeon.items.armor.Armor; -import com.watabou.pixeldungeon.scenes.GameScene; -import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; -import com.watabou.pixeldungeon.utils.GLog; -import com.watabou.pixeldungeon.windows.WndBag; - -public class Stylus extends Item { - - private static final String TXT_SELECT_ARMOR = "Select an armor to inscribe on"; - private static final String TXT_INSCRIBED = "you inscribed the %s on your %s"; - - private static final float TIME_TO_INSCRIBE = 2; - - private static final String AC_INSCRIBE = "INSCRIBE"; - - { - name = "arcane stylus"; - image = ItemSpriteSheet.STYLUS; - - stackable = true; - } - - @Override - public ArrayList actions( Hero hero ) { - ArrayList actions = super.actions( hero ); - actions.add( AC_INSCRIBE ); - return actions; - } - - @Override - public void execute( Hero hero, String action ) { - if (action == AC_INSCRIBE) { - - curUser = hero; - GameScene.selectItem( itemSelector, WndBag.Mode.ARMOR, TXT_SELECT_ARMOR ); - - } else { - - super.execute( hero, action ); - - } - } - - @Override - public boolean isUpgradable() { - return false; - } - - @Override - public boolean isIdentified() { - return true; - } - - private void inscribe( Armor armor ) { - - detach( curUser.belongings.backpack ); - - Class oldGlyphClass = armor.glyph != null ? armor.glyph.getClass() : null; - Armor.Glyph glyph = Armor.Glyph.random(); - while (glyph.getClass() == oldGlyphClass) { - glyph = Armor.Glyph.random(); - } - - GLog.w( TXT_INSCRIBED, glyph.name(), armor.name() ); - - armor.inscribe( glyph ); - - curUser.sprite.operate( curUser.pos ); - curUser.sprite.centerEmitter().start( PurpleParticle.BURST, 0.05f, 10 ); - Sample.INSTANCE.play( Assets.SND_BURNING ); - - curUser.spend( TIME_TO_INSCRIBE ); - curUser.busy(); - } - - @Override - public int price() { - return 50 * quantity; - } - - @Override - public String info() { - return - "This arcane stylus is made of some dark, very hard stone. Using it you can inscribe " + - "a magical glyph on your armor, but you have no power over choosing what glyph it will be, " + - "the stylus will decide it for you."; - } - - private final WndBag.Listener itemSelector = new WndBag.Listener() { - @Override - public void onSelect( Item item ) { - if (item != null) { - Stylus.this.inscribe( (Armor)item ); - } - } - }; -} diff --git a/src/com/watabou/pixeldungeon/items/TomeOfMastery.java b/src/com/watabou/pixeldungeon/items/TomeOfMastery.java index 6b27c0ba18..8ddd3c3bbc 100644 --- a/src/com/watabou/pixeldungeon/items/TomeOfMastery.java +++ b/src/com/watabou/pixeldungeon/items/TomeOfMastery.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Torch.java b/src/com/watabou/pixeldungeon/items/Torch.java index d4b2104a21..556d81a2a6 100644 --- a/src/com/watabou/pixeldungeon/items/Torch.java +++ b/src/com/watabou/pixeldungeon/items/Torch.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/Weightstone.java b/src/com/watabou/pixeldungeon/items/Weightstone.java index 784575a004..6fb30fa311 100644 --- a/src/com/watabou/pixeldungeon/items/Weightstone.java +++ b/src/com/watabou/pixeldungeon/items/Weightstone.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -86,6 +86,7 @@ private void apply( Weapon weapon, boolean forSpeed ) { detach( curUser.belongings.backpack ); + weapon.fix(); if (forSpeed) { weapon.imbue = Weapon.Imbue.SPEED; GLog.p( TXT_FAST, weapon.name() ); diff --git a/src/com/watabou/pixeldungeon/items/armor/Armor.java b/src/com/watabou/pixeldungeon/items/armor/Armor.java index ad32aff8aa..fac4e4a6cd 100644 --- a/src/com/watabou/pixeldungeon/items/armor/Armor.java +++ b/src/com/watabou/pixeldungeon/items/armor/Armor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -36,6 +36,8 @@ public class Armor extends EquipableItem { + private static final int HITS_TO_KNOW = 10; + private static final String TXT_EQUIP_CURSED = "your %s constricts around you painfully"; private static final String TXT_IDENTIFY = "you are now familiar enough with your %s to identify it. It is %s."; @@ -50,7 +52,7 @@ public class Armor extends EquipableItem { public int STR; public int DR; - private int hitsToKnow = 10; + private int hitsToKnow = HITS_TO_KNOW; public Glyph glyph; @@ -62,18 +64,23 @@ public Armor( int tier ) { DR = typicalDR(); } - private static final String GLYPH = "glyph"; + private static final String UNFAMILIRIARITY = "unfamiliarity"; + private static final String GLYPH = "glyph"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); + bundle.put( UNFAMILIRIARITY, hitsToKnow ); bundle.put( GLYPH, glyph ); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - glyph = (Glyph)bundle.get( GLYPH ); + if ((hitsToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) { + hitsToKnow = HITS_TO_KNOW; + } + inscribe( (Glyph)bundle.get( GLYPH ) ); } @Override @@ -100,7 +107,7 @@ public boolean doEquip( Hero hero ) { ((HeroSprite)hero.sprite).updateArmor(); - hero.spendAndNext( 2 * time2equip( hero ) ); + hero.spendAndNext( time2equip( hero ) ); return true; } else { @@ -113,7 +120,7 @@ public boolean doEquip( Hero hero ) { @Override protected float time2equip( Hero hero ) { - return hero.speed(); + return 2 / hero.speed(); } @Override @@ -151,7 +158,7 @@ public Item upgrade( boolean inscribe ) { } } else { if (inscribe) { - inscribe( Glyph.random() ); + inscribe(); } }; @@ -173,6 +180,11 @@ public Item degrade() { return super.degrade(); } + @Override + public int maxDurability( int lvl ) { + return 6 * (lvl < 16 ? 16 - lvl : 1); + } + public int proc( Char attacker, Char defender, int damage ) { if (glyph != null) { @@ -187,6 +199,8 @@ public int proc( Char attacker, Char defender, int damage ) { } } + use(); + return damage; } @@ -233,7 +247,7 @@ public String info() { } if (glyph != null) { - info.append( "It is inscribed." ); + info.append( "It is enchanted." ); } if (isEquipped( Dungeon.hero )) { @@ -267,7 +281,7 @@ public Item random() { } if (Random.Int( 10 ) == 0) { - inscribe( Glyph.random() ); + inscribe(); } return this; @@ -316,6 +330,17 @@ public Armor inscribe( Glyph glyph ) { return this; } + public Armor inscribe() { + + Class oldGlyphClass = glyph != null ? glyph.getClass() : null; + Glyph gl = Glyph.random(); + while (gl.getClass() == oldGlyphClass) { + gl = Armor.Glyph.random(); + } + + return inscribe( gl ); + } + public boolean isInscribed() { return glyph != null; } @@ -336,10 +361,6 @@ public static abstract class Glyph implements Bundlable { public abstract int proc( Armor armor, Char attacker, Char defender, int damage ); - public String name() { - return name( "glyph" ); - } - public String name( String armorName ) { return armorName; } diff --git a/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java b/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java index 58c720c614..9811f1475a 100644 --- a/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/ClothArmor.java b/src/com/watabou/pixeldungeon/items/armor/ClothArmor.java index 182bb0d42e..8a23212d73 100644 --- a/src/com/watabou/pixeldungeon/items/armor/ClothArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/ClothArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/HuntressArmor.java b/src/com/watabou/pixeldungeon/items/armor/HuntressArmor.java index cc3ec8d6a7..279bc5095d 100644 --- a/src/com/watabou/pixeldungeon/items/armor/HuntressArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/HuntressArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/LeatherArmor.java b/src/com/watabou/pixeldungeon/items/armor/LeatherArmor.java index e4e53437ec..9744ba2d8d 100644 --- a/src/com/watabou/pixeldungeon/items/armor/LeatherArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/LeatherArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/MageArmor.java b/src/com/watabou/pixeldungeon/items/armor/MageArmor.java index 7e2f5a2142..cab2b449d3 100644 --- a/src/com/watabou/pixeldungeon/items/armor/MageArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/MageArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/MailArmor.java b/src/com/watabou/pixeldungeon/items/armor/MailArmor.java index 1039c5fff9..bd97baa49c 100644 --- a/src/com/watabou/pixeldungeon/items/armor/MailArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/MailArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/PlateArmor.java b/src/com/watabou/pixeldungeon/items/armor/PlateArmor.java index c69822b61c..13c717e612 100644 --- a/src/com/watabou/pixeldungeon/items/armor/PlateArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/PlateArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/RogueArmor.java b/src/com/watabou/pixeldungeon/items/armor/RogueArmor.java index d38a490379..39f57e74a3 100644 --- a/src/com/watabou/pixeldungeon/items/armor/RogueArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/RogueArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/ScaleArmor.java b/src/com/watabou/pixeldungeon/items/armor/ScaleArmor.java index 5d46e31c96..1cd391de01 100644 --- a/src/com/watabou/pixeldungeon/items/armor/ScaleArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/ScaleArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/WarriorArmor.java b/src/com/watabou/pixeldungeon/items/armor/WarriorArmor.java index f285c7a37c..97fa2ab837 100644 --- a/src/com/watabou/pixeldungeon/items/armor/WarriorArmor.java +++ b/src/com/watabou/pixeldungeon/items/armor/WarriorArmor.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -34,7 +34,6 @@ import com.watabou.pixeldungeon.mechanics.Ballistica; import com.watabou.pixeldungeon.scenes.CellSelector; import com.watabou.pixeldungeon.scenes.GameScene; -import com.watabou.pixeldungeon.sprites.HeroSprite; import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; import com.watabou.pixeldungeon.utils.GLog; import com.watabou.utils.Callback; @@ -100,7 +99,7 @@ public void onSelect( Integer target ) { final int dest = cell; curUser.busy(); - ((HeroSprite)curUser.sprite).jump( curUser.pos, cell, new Callback() { + curUser.sprite.jump( curUser.pos, cell, new Callback() { @Override public void call() { curUser.move( dest ); diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Affection.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Affection.java index 7e62d96538..1566148e8c 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Affection.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Affection.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -42,12 +42,14 @@ public int proc( Armor armor, Char attacker, Char defender, int damage) { if (Level.adjacent( attacker.pos, defender.pos ) && Random.Int( level / 2 + 5 ) >= 4) { - int duration = Random.IntRange( 2, 5 ); + int duration = Random.IntRange( 3, 7 ); - Buff.affect( attacker, Charm.class, Charm.durationFactor( attacker ) * duration ); + Buff.affect( attacker, Charm.class, Charm.durationFactor( attacker ) * duration ).object = defender.id(); attacker.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 ); - Buff.affect( defender, Charm.class, Random.Float( Charm.durationFactor( defender ) * duration / 2, duration ) ); + duration *= Random.Float( 0.5f, 1 ); + + Buff.affect( defender, Charm.class, Charm.durationFactor( defender ) * duration ).object = attacker.id(); defender.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 ); } diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/AntiEntropy.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/AntiEntropy.java index 86a4283a15..dc0836c52d 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/AntiEntropy.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/AntiEntropy.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Bounce.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Bounce.java index 050fed14e8..ac868950f8 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Bounce.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Bounce.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Displacement.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Displacement.java index 6174244272..bf634d5a6c 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Displacement.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Displacement.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Entanglement.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Entanglement.java index e41652b354..219ebc5b18 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Entanglement.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Entanglement.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Metabolism.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Metabolism.java index 20e6c6a6cb..ab65dc4a52 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Metabolism.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Metabolism.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -41,13 +41,12 @@ public int proc( Armor armor, Char attacker, Char defender, int damage) { if (Random.Int( level / 2 + 5 ) >= 4) { int healing = Math.min( defender.HT - defender.HP, Random.Int( 1, defender.HT / 5 ) ); - if (healing > 0) { Hunger hunger = defender.buff( Hunger.class ); - + if (hunger != null && !hunger.isStarving()) { - + hunger.satisfy( -Hunger.STARVING / 10 ); BuffIndicator.refreshHero(); diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Multiplicity.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Multiplicity.java index 9ce857fc73..0938de389f 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Multiplicity.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Multiplicity.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -60,7 +60,7 @@ public int proc( Armor armor, Char attacker, Char defender, int damage) { GameScene.add( mob ); WandOfBlink.appear( mob, Random.element( respawnPoints ) ); - defender.damage( Random.IntRange( 1, defender.HT / 6 ), /*attacker*/ this ); + defender.damage( Random.IntRange( 1, defender.HT / 6 ), this ); checkOwner( defender ); } diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Potential.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Potential.java index 331cfb5492..6e7e15572d 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Potential.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Potential.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Stench.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Stench.java index af2e29a938..6c41b3da58 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Stench.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Stench.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java b/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java index 5f688c4e65..2a86c893b2 100644 --- a/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java +++ b/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -126,9 +126,8 @@ public boolean act() { target.damage( 1, this ); if (target == Dungeon.hero && !target.isAlive()) { // FIXME - Glyph glyph = new Viscosity(); - Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, glyph.name(), Dungeon.depth ) ); - GLog.n( "%s killed you...", glyph.name() ); + Dungeon.fail( Utils.format( ResultDescriptions.GLYPH, "enchantment of viscosity", Dungeon.depth ) ); + GLog.n( "The enchantment of viscosity killed you..." ); Badges.validateDeathFromGlyph(); } @@ -143,7 +142,6 @@ public boolean act() { detach(); } - return true; } } diff --git a/src/com/watabou/pixeldungeon/items/bags/Bag.java b/src/com/watabou/pixeldungeon/items/bags/Bag.java index de91ca9e29..8ceb036d7e 100644 --- a/src/com/watabou/pixeldungeon/items/bags/Bag.java +++ b/src/com/watabou/pixeldungeon/items/bags/Bag.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/bags/Keyring.java b/src/com/watabou/pixeldungeon/items/bags/Keyring.java new file mode 100644 index 0000000000..5912d2c5a4 --- /dev/null +++ b/src/com/watabou/pixeldungeon/items/bags/Keyring.java @@ -0,0 +1,49 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.items.bags; + +import com.watabou.pixeldungeon.items.Item; +import com.watabou.pixeldungeon.items.keys.Key; +import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; + +public class Keyring extends Bag { + + { + name = "key ring"; + image = ItemSpriteSheet.KEYRING; + + size = 12; + } + + @Override + public boolean grab( Item item ) { + return item instanceof Key; + } + + @Override + public int price() { + return 50; + } + + @Override + public String info() { + return + "This is a copper key ring, that lets you keep all your keys " + + "separately from the rest of your belongings."; + } +} diff --git a/src/com/watabou/pixeldungeon/items/bags/ScrollHolder.java b/src/com/watabou/pixeldungeon/items/bags/ScrollHolder.java index 0bef891de0..e5b2ad2ae6 100644 --- a/src/com/watabou/pixeldungeon/items/bags/ScrollHolder.java +++ b/src/com/watabou/pixeldungeon/items/bags/ScrollHolder.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/bags/SeedPouch.java b/src/com/watabou/pixeldungeon/items/bags/SeedPouch.java index b3515d3f5a..4fc725baf1 100644 --- a/src/com/watabou/pixeldungeon/items/bags/SeedPouch.java +++ b/src/com/watabou/pixeldungeon/items/bags/SeedPouch.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/bags/WandHolster.java b/src/com/watabou/pixeldungeon/items/bags/WandHolster.java index 7339c66bf8..678b2350bd 100644 --- a/src/com/watabou/pixeldungeon/items/bags/WandHolster.java +++ b/src/com/watabou/pixeldungeon/items/bags/WandHolster.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/ChargrilledMeat.java b/src/com/watabou/pixeldungeon/items/food/ChargrilledMeat.java index 67ffbdea87..cf1c6ed18d 100644 --- a/src/com/watabou/pixeldungeon/items/food/ChargrilledMeat.java +++ b/src/com/watabou/pixeldungeon/items/food/ChargrilledMeat.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/Food.java b/src/com/watabou/pixeldungeon/items/food/Food.java index 00e7fbf177..b75ed42d41 100644 --- a/src/com/watabou/pixeldungeon/items/food/Food.java +++ b/src/com/watabou/pixeldungeon/items/food/Food.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/FrozenCarpaccio.java b/src/com/watabou/pixeldungeon/items/food/FrozenCarpaccio.java index a280076025..5169faf09c 100644 --- a/src/com/watabou/pixeldungeon/items/food/FrozenCarpaccio.java +++ b/src/com/watabou/pixeldungeon/items/food/FrozenCarpaccio.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/MysteryMeat.java b/src/com/watabou/pixeldungeon/items/food/MysteryMeat.java index 6b3a181fe9..ee5b6b3437 100644 --- a/src/com/watabou/pixeldungeon/items/food/MysteryMeat.java +++ b/src/com/watabou/pixeldungeon/items/food/MysteryMeat.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/OverpricedRation.java b/src/com/watabou/pixeldungeon/items/food/OverpricedRation.java index 4e33d64cef..b5f18253e8 100644 --- a/src/com/watabou/pixeldungeon/items/food/OverpricedRation.java +++ b/src/com/watabou/pixeldungeon/items/food/OverpricedRation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/food/Pasty.java b/src/com/watabou/pixeldungeon/items/food/Pasty.java index af0706d841..a77db845bf 100644 --- a/src/com/watabou/pixeldungeon/items/food/Pasty.java +++ b/src/com/watabou/pixeldungeon/items/food/Pasty.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/keys/GoldenKey.java b/src/com/watabou/pixeldungeon/items/keys/GoldenKey.java index 40048bccb4..669cdcaeae 100644 --- a/src/com/watabou/pixeldungeon/items/keys/GoldenKey.java +++ b/src/com/watabou/pixeldungeon/items/keys/GoldenKey.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/keys/IronKey.java b/src/com/watabou/pixeldungeon/items/keys/IronKey.java index a04d8a805f..5fc4cfc856 100644 --- a/src/com/watabou/pixeldungeon/items/keys/IronKey.java +++ b/src/com/watabou/pixeldungeon/items/keys/IronKey.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/keys/Key.java b/src/com/watabou/pixeldungeon/items/keys/Key.java index 38bda0fd6b..64615c5c25 100644 --- a/src/com/watabou/pixeldungeon/items/keys/Key.java +++ b/src/com/watabou/pixeldungeon/items/keys/Key.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -62,6 +62,6 @@ public boolean isIdentified() { @Override public String status() { - return depth + "*"; + return depth + "\u007F"; } } diff --git a/src/com/watabou/pixeldungeon/items/keys/SkeletonKey.java b/src/com/watabou/pixeldungeon/items/keys/SkeletonKey.java index 7843271309..8d26827938 100644 --- a/src/com/watabou/pixeldungeon/items/keys/SkeletonKey.java +++ b/src/com/watabou/pixeldungeon/items/keys/SkeletonKey.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/Potion.java b/src/com/watabou/pixeldungeon/items/potions/Potion.java index 07ed50a741..f5b1f27749 100644 --- a/src/com/watabou/pixeldungeon/items/potions/Potion.java +++ b/src/com/watabou/pixeldungeon/items/potions/Potion.java @@ -1,6 +1,7 @@ + /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -14,8 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see - */ -package com.watabou.pixeldungeon.items.potions; + */package com.watabou.pixeldungeon.items.potions; import java.util.ArrayList; import java.util.HashSet; @@ -212,10 +212,12 @@ protected void apply( Hero hero ) { shatter( hero.pos ); } - protected void shatter( int cell ) { - GLog.i( "The flask shatters and " + color() + " liquid splashes harmlessly" ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); - splash( cell ); + public void shatter( int cell ) { + if (Dungeon.visible[cell]) { + GLog.i( "The flask shatters and " + color() + " liquid splashes harmlessly" ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + splash( cell ); + } } public boolean isKnown() { diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfExperience.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfExperience.java index 2288619331..dfd0f7bf1a 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfExperience.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfExperience.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfFrost.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfFrost.java index 408b918221..6db964547f 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfFrost.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfFrost.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -35,29 +35,32 @@ public class PotionOfFrost extends Potion { } @Override - protected void shatter( int cell ) { + public void shatter( int cell ) { PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE ); Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class ); + boolean visible = false; for (int i=0; i < Level.LENGTH; i++) { if (PathFinder.distance[i] < Integer.MAX_VALUE) { - Freezing.affect( i, fire ); + visible = Freezing.affect( i, fire ) || visible; } } - splash( cell ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); - - setKnown(); + if (visible) { + splash( cell ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + + setKnown(); + } } @Override public String desc() { return - "Upon exposure to open air this chemical will evaporate into a freezing cloud, causing " + - "any creature that contacts it to be frozen in place unable to act and move."; + "Upon exposure to open air, this chemical will evaporate into a freezing cloud, causing " + + "any creature that contacts it to be frozen in place, unable to act and move."; } @Override diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfHealing.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfHealing.java index aa2e46a782..ed24b1b8cd 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfHealing.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfHealing.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfInvisibility.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfInvisibility.java index 5cd804f18b..adbed433a4 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfInvisibility.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfInvisibility.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfLevitation.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfLevitation.java index cc5e9d7bb4..1bdcaf52e7 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfLevitation.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfLevitation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfLiquidFlame.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfLiquidFlame.java index f728124592..97646283f4 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfLiquidFlame.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfLiquidFlame.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,6 +19,7 @@ import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.blobs.Blob; import com.watabou.pixeldungeon.actors.blobs.Fire; import com.watabou.pixeldungeon.scenes.GameScene; @@ -30,15 +31,16 @@ public class PotionOfLiquidFlame extends Potion { } @Override - protected void shatter( int cell ) { + public void shatter( int cell ) { - setKnown(); + if (Dungeon.visible[cell]) { + setKnown(); + + splash( cell ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + } - splash( cell ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); - - Fire fire = Blob.seed( cell, 2, Fire.class ); - GameScene.add( fire ); + GameScene.add( Blob.seed( cell, 2, Fire.class ) ); } @Override diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfMight.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfMight.java index d560a550e1..5ad47c4051 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfMight.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfMight.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,6 +17,7 @@ */ package com.watabou.pixeldungeon.items.potions; +import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.actors.hero.Hero; import com.watabou.pixeldungeon.sprites.CharSprite; import com.watabou.pixeldungeon.utils.GLog; @@ -36,6 +37,8 @@ protected void apply( Hero hero ) { hero.HP += 5; hero.sprite.showStatus( CharSprite.POSITIVE, "+1 str, +5 ht" ); GLog.p( "Newfound strength surges through your body." ); + + Badges.validateStrengthAttained(); } @Override diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfMindVision.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfMindVision.java index 7b155bb368..25e1830893 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfMindVision.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfMindVision.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfParalyticGas.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfParalyticGas.java index 7678bd2c7e..06589e4d9c 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfParalyticGas.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfParalyticGas.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,6 +19,7 @@ import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.blobs.Blob; import com.watabou.pixeldungeon.actors.blobs.ParalyticGas; import com.watabou.pixeldungeon.scenes.GameScene; @@ -30,12 +31,13 @@ public class PotionOfParalyticGas extends Potion { } @Override - protected void shatter( int cell ) { - - setKnown(); - - splash( cell ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); + public void shatter( int cell ) { + if (Dungeon.visible[cell]) { + setKnown(); + + splash( cell ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + } GameScene.add( Blob.seed( cell, 1000, ParalyticGas.class ) ); } diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfPurity.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfPurity.java index d0e04ff52f..ec284818a5 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfPurity.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfPurity.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -45,7 +45,7 @@ public class PotionOfPurity extends Potion { } @Override - protected void shatter( int cell ) { + public void shatter( int cell ) { PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE ); @@ -73,7 +73,9 @@ protected void shatter( int cell ) { blob.volume -= value; procd = true; - CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 1 ); + if (Dungeon.visible[i]) { + CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 1 ); + } } } @@ -84,8 +86,10 @@ protected void shatter( int cell ) { if (procd) { - splash( cell ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); + if (Dungeon.visible[cell]) { + splash( cell ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + } setKnown(); diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfStrength.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfStrength.java index 1e0b072b01..a97e87b821 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfStrength.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfStrength.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/potions/PotionOfToxicGas.java b/src/com/watabou/pixeldungeon/items/potions/PotionOfToxicGas.java index be8a32cab7..7a9c57013d 100644 --- a/src/com/watabou/pixeldungeon/items/potions/PotionOfToxicGas.java +++ b/src/com/watabou/pixeldungeon/items/potions/PotionOfToxicGas.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,7 +19,7 @@ import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; -import com.watabou.pixeldungeon.actors.Actor; +import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.blobs.Blob; import com.watabou.pixeldungeon.actors.blobs.ToxicGas; import com.watabou.pixeldungeon.scenes.GameScene; @@ -31,16 +31,15 @@ public class PotionOfToxicGas extends Potion { } @Override - protected void shatter( int cell ) { + public void shatter( int cell ) { + if (Dungeon.visible[cell]) { + setKnown(); + + splash( cell ); + Sample.INSTANCE.play( Assets.SND_SHATTER ); + } - setKnown(); - - splash( cell ); - Sample.INSTANCE.play( Assets.SND_SHATTER ); - - ToxicGas gas = Blob.seed( cell, 1000, ToxicGas.class ); - Actor.add( gas ); - GameScene.add( gas ); + GameScene.add( Blob.seed( cell, 1000, ToxicGas.class ) ); } @Override diff --git a/src/com/watabou/pixeldungeon/items/quest/CorpseDust.java b/src/com/watabou/pixeldungeon/items/quest/CorpseDust.java index be30f17477..d0a8342bc7 100644 --- a/src/com/watabou/pixeldungeon/items/quest/CorpseDust.java +++ b/src/com/watabou/pixeldungeon/items/quest/CorpseDust.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/quest/DarkGold.java b/src/com/watabou/pixeldungeon/items/quest/DarkGold.java index ef94c85a97..cd055fa86c 100644 --- a/src/com/watabou/pixeldungeon/items/quest/DarkGold.java +++ b/src/com/watabou/pixeldungeon/items/quest/DarkGold.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/quest/DriedRose.java b/src/com/watabou/pixeldungeon/items/quest/DriedRose.java index be751a5c2d..2a89685244 100644 --- a/src/com/watabou/pixeldungeon/items/quest/DriedRose.java +++ b/src/com/watabou/pixeldungeon/items/quest/DriedRose.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/quest/DwarfToken.java b/src/com/watabou/pixeldungeon/items/quest/DwarfToken.java index 3ab8873472..f9de9d9d01 100644 --- a/src/com/watabou/pixeldungeon/items/quest/DwarfToken.java +++ b/src/com/watabou/pixeldungeon/items/quest/DwarfToken.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java b/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java index 03caf593fa..3ff8658454 100644 --- a/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java +++ b/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/quest/RatSkull.java b/src/com/watabou/pixeldungeon/items/quest/RatSkull.java index 612e0af7fa..d28fae0818 100644 --- a/src/com/watabou/pixeldungeon/items/quest/RatSkull.java +++ b/src/com/watabou/pixeldungeon/items/quest/RatSkull.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/Ring.java b/src/com/watabou/pixeldungeon/items/rings/Ring.java index 38f90ce801..16cfcdd2a4 100644 --- a/src/com/watabou/pixeldungeon/items/rings/Ring.java +++ b/src/com/watabou/pixeldungeon/items/rings/Ring.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -21,6 +21,7 @@ import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.buffs.Buff; import com.watabou.pixeldungeon.actors.hero.Hero; @@ -30,16 +31,25 @@ import com.watabou.pixeldungeon.items.ItemStatusHandler; import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; import com.watabou.pixeldungeon.utils.GLog; +import com.watabou.pixeldungeon.utils.Utils; +import com.watabou.pixeldungeon.windows.WndOptions; import com.watabou.utils.Bundle; import com.watabou.utils.Random; public class Ring extends EquipableItem { + private static final int TICKS_TO_KNOW = 200; + private static final float TIME_TO_EQUIP = 1f; private static final String TXT_IDENTIFY = "you are now familiar enough with your %s to identify it. It is %s."; + private static final String TXT_UNEQUIP_TITLE = "Unequip one ring"; + private static final String TXT_UNEQUIP_MESSAGE = + "You can only wear two rings at a time. " + + "Unequip one of your equipped rings."; + protected Buff buff; private static final Class[] rings = { @@ -76,7 +86,7 @@ public class Ring extends EquipableItem { private String gem; - private int ticksToKnow = 200; + private int ticksToKnow = TICKS_TO_KNOW; @SuppressWarnings("unchecked") public static void initGems() { @@ -110,11 +120,32 @@ public ArrayList actions( Hero hero ) { } @Override - public boolean doEquip( Hero hero ) { + public boolean doEquip( final Hero hero ) { if (hero.belongings.ring1 != null && hero.belongings.ring2 != null) { - GLog.w( "you can only wear 2 rings at a time" ); + final Ring r1 = hero.belongings.ring1; + final Ring r2 = hero.belongings.ring2; + + PixelDungeon.scene().add( + new WndOptions( TXT_UNEQUIP_TITLE, TXT_UNEQUIP_MESSAGE, + Utils.capitalize( r1.toString() ), + Utils.capitalize( r2.toString() ) ) { + + @Override + protected void onSelect( int index ) { + + detach( hero.belongings.backpack ); + + Ring equipped = (index == 0 ? r1 : r2); + if (equipped.doUnequip( hero, true, false )) { + doEquip( hero ); + } else { + collect( hero.belongings.backpack ); + } + } + } ); + return false; } else { @@ -191,6 +222,32 @@ public Item upgrade() { return this; } + @Override + public Item degrade() { + + super.degrade(); + + if (buff != null) { + + Char owner = buff.target; + buff.detach(); + if ((buff = buff()) != null) { + buff.attachTo( owner ); + } + } + + return this; + } + + @Override + public int maxDurability( int lvl ) { + if (lvl <= 1) { + return Integer.MAX_VALUE; + } else { + return 80 * (lvl < 16 ? 16 - lvl : 1); + } + } + public boolean isKnown() { return handler.isKnown( this ); } @@ -246,10 +303,12 @@ public Item identify() { @Override public Item random() { - level = Random.Int( 1, 3 ); + int lvl = Random.Int( 1, 3 ); if (Random.Float() < 0.3f) { - level = -level; + degrade( lvl ); cursed = true; + } else { + upgrade( lvl ); } return this; } @@ -281,6 +340,22 @@ protected RingBuff buff() { return null; } + private static final String UNFAMILIRIARITY = "unfamiliarity"; + + @Override + public void storeInBundle( Bundle bundle ) { + super.storeInBundle( bundle ); + bundle.put( UNFAMILIRIARITY, ticksToKnow ); + } + + @Override + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle( bundle ); + if ((ticksToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) { + ticksToKnow = TICKS_TO_KNOW; + } + } + public class RingBuff extends Buff { private static final String TXT_KNOWN = "This is a %s"; @@ -312,6 +387,8 @@ public boolean act() { Badges.validateItemLevelAquired( Ring.this ); } + use(); + spend( TICK ); return true; diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfAccuracy.java b/src/com/watabou/pixeldungeon/items/rings/RingOfAccuracy.java index 1fd4799b8f..1524c188dd 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfAccuracy.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfAccuracy.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfDetection.java b/src/com/watabou/pixeldungeon/items/rings/RingOfDetection.java index 6f54dfa02c..2ecfef273f 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfDetection.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfDetection.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfElements.java b/src/com/watabou/pixeldungeon/items/rings/RingOfElements.java index bfc8ab1945..8431ab4dfb 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfElements.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfElements.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfEvasion.java b/src/com/watabou/pixeldungeon/items/rings/RingOfEvasion.java index bcdadbc459..37a0ae338f 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfEvasion.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfEvasion.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfHaggler.java b/src/com/watabou/pixeldungeon/items/rings/RingOfHaggler.java index 704641f31f..5cf64742d5 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfHaggler.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfHaggler.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -51,6 +51,10 @@ public boolean isUpgradable() { return false; } + @Override + public void use() { + // Do nothing (it can't degrade) + } @Override public String desc() { diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfHaste.java b/src/com/watabou/pixeldungeon/items/rings/RingOfHaste.java index 26c9afbdbf..b046f4a3be 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfHaste.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfHaste.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfHerbalism.java b/src/com/watabou/pixeldungeon/items/rings/RingOfHerbalism.java index 4ed07ec84d..b12ddf4dd9 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfHerbalism.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfHerbalism.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfMending.java b/src/com/watabou/pixeldungeon/items/rings/RingOfMending.java index f1a3490871..18a9a901b3 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfMending.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfMending.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfPower.java b/src/com/watabou/pixeldungeon/items/rings/RingOfPower.java index 372a300d1c..f93558b33e 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfPower.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfPower.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfSatiety.java b/src/com/watabou/pixeldungeon/items/rings/RingOfSatiety.java index c2adb20f94..08a47fa14b 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfSatiety.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfSatiety.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfShadows.java b/src/com/watabou/pixeldungeon/items/rings/RingOfShadows.java index 999f829f19..e06186adc8 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfShadows.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfShadows.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/rings/RingOfThorns.java b/src/com/watabou/pixeldungeon/items/rings/RingOfThorns.java index 43bd431fd8..e621d22f58 100644 --- a/src/com/watabou/pixeldungeon/items/rings/RingOfThorns.java +++ b/src/com/watabou/pixeldungeon/items/rings/RingOfThorns.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -51,6 +51,10 @@ public boolean isUpgradable() { return false; } + @Override + public void use() { + // Do nothing (it can't degrade) + } @Override public String desc() { diff --git a/src/com/watabou/pixeldungeon/items/scrolls/InventoryScroll.java b/src/com/watabou/pixeldungeon/items/scrolls/InventoryScroll.java index 340a762024..a0342d803b 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/InventoryScroll.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/InventoryScroll.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -72,7 +72,7 @@ protected void onSelect( int index ) { @Override public void onSelect( Item item ) { if (item != null) { - + ((InventoryScroll)curItem).onItemSelected( item ); curUser.spendAndNext( TIME_TO_READ ); @@ -84,7 +84,7 @@ public void onSelect( Item item ) { ((InventoryScroll)curItem).confirmCancelation(); } else { - + curItem.collect( curUser.belongings.backpack ); } diff --git a/src/com/watabou/pixeldungeon/items/scrolls/Scroll.java b/src/com/watabou/pixeldungeon/items/scrolls/Scroll.java index 711dac28d2..c88fad0013 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/Scroll.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/Scroll.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -43,13 +43,13 @@ public abstract class Scroll extends Item { ScrollOfRecharging.class, ScrollOfRemoveCurse.class, ScrollOfTeleportation.class, - ScrollOfUpgrade.class, ScrollOfChallenge.class, ScrollOfTerror.class, ScrollOfLullaby.class, - ScrollOfWeaponUpgrade.class, ScrollOfPsionicBlast.class, - ScrollOfMirrorImage.class + ScrollOfMirrorImage.class, + ScrollOfUpgrade.class, + ScrollOfEnchantment.class }; private static final String[] runes = {"KAUNAN", "SOWILO", "LAGUZ", "YNGVI", "GYFU", "RAIDO", "ISAZ", "MANNAZ", "NAUDIZ", "BERKANAN", "ODAL", "TIWAZ"}; diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfChallenge.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfChallenge.java index b15446ed05..e83a7a9e22 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfChallenge.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfChallenge.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -21,8 +21,10 @@ import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.buffs.Invisibility; +import com.watabou.pixeldungeon.actors.mobs.Mimic; import com.watabou.pixeldungeon.actors.mobs.Mob; import com.watabou.pixeldungeon.effects.Speck; +import com.watabou.pixeldungeon.items.Heap; import com.watabou.pixeldungeon.utils.GLog; public class ScrollOfChallenge extends Scroll { @@ -38,6 +40,17 @@ protected void doRead() { mob.beckon( curUser.pos ); } + + for (Heap heap : Dungeon.level.heaps.values()) { + if (heap.type == Heap.Type.MIMIC) { + Mimic m = Mimic.spawnAt( heap.pos, heap.items ); + if (m != null) { + m.beckon( curUser.pos ); + heap.destroy(); + } + } + } + GLog.w( "The scroll emits a challenging roar that echoes throughout the dungeon!" ); setKnown(); diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfWeaponUpgrade.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfEnchantment.java similarity index 55% rename from src/com/watabou/pixeldungeon/items/scrolls/ScrollOfWeaponUpgrade.java rename to src/com/watabou/pixeldungeon/items/scrolls/ScrollOfEnchantment.java index 2666c1f79a..2a9b3e5895 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfWeaponUpgrade.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfEnchantment.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,44 +17,49 @@ */ package com.watabou.pixeldungeon.items.scrolls; -import com.watabou.pixeldungeon.Badges; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.effects.Speck; import com.watabou.pixeldungeon.items.Item; +import com.watabou.pixeldungeon.items.armor.Armor; import com.watabou.pixeldungeon.items.weapon.Weapon; import com.watabou.pixeldungeon.utils.GLog; import com.watabou.pixeldungeon.windows.WndBag; -public class ScrollOfWeaponUpgrade extends InventoryScroll { +public class ScrollOfEnchantment extends InventoryScroll { - private static final String TXT_LOOKS_BETTER = "your %s certainly looks better now"; + private static final String TXT_GLOWS = "your %s glows in the dark"; { - name = "Scroll of Weapon Upgrade"; - inventoryTitle = "Select a weapon to upgrade"; - mode = WndBag.Mode.WEAPON; + name = "Scroll of Enchantment"; + inventoryTitle = "Select an enchantable item"; + mode = WndBag.Mode.ENCHANTABLE; } @Override protected void onItemSelected( Item item ) { + + ScrollOfRemoveCurse.uncurse( Dungeon.hero, item ); - Weapon weapon = (Weapon)item; - - ScrollOfRemoveCurse.uncurse( Dungeon.hero, weapon ); - weapon.upgrade( true ); + if (item instanceof Weapon) { + + ((Weapon)item).enchant(); + + } else { + + ((Armor)item).inscribe(); - GLog.p( TXT_LOOKS_BETTER, weapon.name() ); + } - Badges.validateItemLevelAquired( weapon ); + item.fix(); - curUser.sprite.emitter().start( Speck.factory( Speck.UP ), 0.2f, 3 ); + curUser.sprite.emitter().start( Speck.factory( Speck.LIGHT ), 0.1f, 5 ); + GLog.w( TXT_GLOWS, item.name() ); } @Override public String desc() { return - "This scroll will upgrade a melee weapon, improving its quality. In contrast to a regular Scroll of Upgrade, " + - "this specialized version will never destroy an enchantment on a weapon. On the contrary, it is able to imbue " + - "an unenchanted weapon with a random enchantment."; + "This scroll is able to imbue a weapon or an armor " + + "with a random enchantment, granting it a special power."; } } diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfIdentify.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfIdentify.java index b4c8929de2..280bb1d465 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfIdentify.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfIdentify.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfLullaby.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfLullaby.java index 439fd4d6f9..6499c4450d 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfLullaby.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfLullaby.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMagicMapping.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMagicMapping.java index 540139636a..5135cb9958 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMagicMapping.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMagicMapping.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -44,7 +44,7 @@ protected void doRead() { int[] map = Dungeon.level.map; boolean[] mapped = Dungeon.level.mapped; boolean[] discoverable = Level.discoverable; - + boolean noticed = false; for (int i=0; i < length; i++) { diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMirrorImage.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMirrorImage.java index 7048b5af1b..f70a219229 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMirrorImage.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfMirrorImage.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfPsionicBlast.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfPsionicBlast.java index 82c50cdd79..f1839a7a04 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfPsionicBlast.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfPsionicBlast.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRecharging.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRecharging.java index c20ca6effe..586a1a3529 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRecharging.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRecharging.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRemoveCurse.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRemoveCurse.java index 93cdd932cc..6a3c90c14d 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRemoveCurse.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfRemoveCurse.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTeleportation.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTeleportation.java index a0e7df6a21..50124253b0 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTeleportation.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTeleportation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTerror.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTerror.java index 71c1b7884a..880f880e8e 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTerror.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfTerror.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -45,8 +45,7 @@ protected void doRead() { Mob affected = null; for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) { if (Level.fieldOfView[mob.pos]) { - Terror terror = Buff.affect( mob, Terror.class, Terror.DURATION ); - terror.source = curUser; + Buff.affect( mob, Terror.class, Terror.DURATION ).object = curUser.id(); count++; affected = mob; diff --git a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfUpgrade.java b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfUpgrade.java index ae6bf8050a..352f3cc045 100644 --- a/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfUpgrade.java +++ b/src/com/watabou/pixeldungeon/items/scrolls/ScrollOfUpgrade.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -41,11 +41,10 @@ protected void onItemSelected( Item item ) { ScrollOfRemoveCurse.uncurse( Dungeon.hero, item ); item.upgrade(); + upgrade( curUser ); GLog.p( TXT_LOOKS_BETTER, item.name() ); Badges.validateItemLevelAquired( item ); - - upgrade( curUser ); } public static void upgrade( Hero hero ) { diff --git a/src/com/watabou/pixeldungeon/items/wands/Wand.java b/src/com/watabou/pixeldungeon/items/wands/Wand.java index c31dd69bb9..f4103a1a56 100644 --- a/src/com/watabou/pixeldungeon/items/wands/Wand.java +++ b/src/com/watabou/pixeldungeon/items/wands/Wand.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -47,6 +47,8 @@ public abstract class Wand extends KindOfWeapon { + private static final int USAGES_TO_KNOW = 40; + public static final String AC_ZAP = "ZAP"; private static final String TXT_WOOD = "This thin %s wand is warm to the touch. Who knows what it will do when used?"; @@ -56,6 +58,8 @@ public abstract class Wand extends KindOfWeapon { private static final String TXT_FIZZLES = "your wand fizzles; it must be out of charges for now"; private static final String TXT_SELF_TARGET = "You can't target yourself"; + private static final String TXT_IDENTIFY = "You are now familiar enough with your %s."; + private static final float TIME_TO_ZAP = 1f; public int maxCharges = initialCharges(); @@ -65,6 +69,8 @@ public abstract class Wand extends KindOfWeapon { private boolean curChargeKnown = false; + private int usagesToKnow = USAGES_TO_KNOW; + protected boolean hitChars = true; private static final Class[] wands = { @@ -146,9 +152,9 @@ public ArrayList actions( Hero hero ) { } @Override - public boolean doUnequip( Hero hero, boolean collect ) { + public boolean doUnequip( Hero hero, boolean collect, boolean single ) { onDetach(); - return super.doUnequip( hero, collect ); + return super.doUnequip( hero, collect, single ); } @Override @@ -186,7 +192,9 @@ public boolean collect( Bag container ) { }; public void charge( Char owner ) { - (charger = new Charger()).attachTo( owner ); + if (charger == null) { + (charger = new Charger()).attachTo( owner ); + } } @Override @@ -302,6 +310,11 @@ public Item degrade() { return this; } + @Override + public int maxDurability( int lvl ) { + return 5 * (lvl < 16 ? 16 - lvl : 1); + } + protected void updateLevel() { maxCharges = Math.min( initialCharges() + level, 9 ); curCharges = Math.min( curCharges, maxCharges ); @@ -325,8 +338,16 @@ protected void fx( int cell, Callback callback ) { } protected void wandUsed() { + curCharges--; - updateQuickslot(); + if (!isIdentified() && --usagesToKnow <= 0) { + identify(); + GLog.w( TXT_IDENTIFY, name() ); + } else { + updateQuickslot(); + } + + use(); curUser.spendAndNext( TIME_TO_ZAP ); } @@ -366,6 +387,7 @@ public int price() { return price; } + private static final String UNFAMILIRIARITY = "unfamiliarity"; private static final String MAX_CHARGES = "maxCharges"; private static final String CUR_CHARGES = "curCharges"; private static final String CUR_CHARGE_KNOWN = "curChargeKnown"; @@ -373,6 +395,7 @@ public int price() { @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); + bundle.put( UNFAMILIRIARITY, usagesToKnow ); bundle.put( MAX_CHARGES, maxCharges ); bundle.put( CUR_CHARGES, curCharges ); bundle.put( CUR_CHARGE_KNOWN, curChargeKnown ); @@ -381,6 +404,9 @@ public void storeInBundle( Bundle bundle ) { @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); + if ((usagesToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) { + usagesToKnow = USAGES_TO_KNOW; + } maxCharges = bundle.getInt( MAX_CHARGES ); curCharges = bundle.getInt( CUR_CHARGES ); curChargeKnown = bundle.getBoolean( CUR_CHARGE_KNOWN ); diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfAmok.java b/src/com/watabou/pixeldungeon/items/wands/WandOfAmok.java index 5e9eb99cc6..fbbcdd85cf 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfAmok.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfAmok.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfAvalanche.java b/src/com/watabou/pixeldungeon/items/wands/WandOfAvalanche.java index 45f98d5d03..1caf87638f 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfAvalanche.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfAvalanche.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfBlink.java b/src/com/watabou/pixeldungeon/items/wands/WandOfBlink.java index 1389f81f66..c6304b4ec6 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfBlink.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfBlink.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfDisintegration.java b/src/com/watabou/pixeldungeon/items/wands/WandOfDisintegration.java index de315f354e..795b53e837 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfDisintegration.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfDisintegration.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfFirebolt.java b/src/com/watabou/pixeldungeon/items/wands/WandOfFirebolt.java index f6b1841c5f..7b26abd095 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfFirebolt.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfFirebolt.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -62,7 +62,7 @@ protected void onZap( int cell ) { ch.damage( Random.Int( 1, 8 + level * level ), this ); Buff.affect( ch, Burning.class ).reignite( ch ); - + ch.sprite.emitter().burst( FlameParticle.FACTORY, 5 ); if (ch == curUser && !ch.isAlive()) { diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfFlock.java b/src/com/watabou/pixeldungeon/items/wands/WandOfFlock.java index 50fbbda76d..f7747b22a7 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfFlock.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfFlock.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfLightning.java b/src/com/watabou/pixeldungeon/items/wands/WandOfLightning.java index 5b32ecd62c..2381d4c141 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfLightning.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfLightning.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -48,7 +48,7 @@ public class WandOfLightning extends Wand { @Override protected void onZap( int cell ) { - + // Everything is processed in fx() method if (!curUser.isAlive()) { Dungeon.fail( Utils.format( ResultDescriptions.WAND, name, Dungeon.depth ) ); GLog.n( "You killed yourself with your own Wand of Lightning..." ); diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfMagicMissile.java b/src/com/watabou/pixeldungeon/items/wands/WandOfMagicMissile.java index 0858ce4e11..a063b36fa8 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfMagicMissile.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfMagicMissile.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -72,7 +72,6 @@ protected void onZap( int cell ) { int level = level(); ch.damage( Random.Int( 1, 6 + level * 2 ), this ); - ch.sprite.burst( 0xFF99CCFF, level / 2 + 2 ); if (ch == curUser && !ch.isAlive()) { diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfPoison.java b/src/com/watabou/pixeldungeon/items/wands/WandOfPoison.java index 333f794371..4db9d9422f 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfPoison.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfPoison.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfRegrowth.java b/src/com/watabou/pixeldungeon/items/wands/WandOfRegrowth.java index cedf5ab259..15f182a048 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfRegrowth.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfRegrowth.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfSlowness.java b/src/com/watabou/pixeldungeon/items/wands/WandOfSlowness.java index 80f1104aa5..49b19d6ca5 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfSlowness.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfSlowness.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfTelekinesis.java b/src/com/watabou/pixeldungeon/items/wands/WandOfTelekinesis.java index 84a299d986..2b6e70742c 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfTelekinesis.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfTelekinesis.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -28,9 +28,12 @@ import com.watabou.pixeldungeon.items.Dewdrop; import com.watabou.pixeldungeon.items.Heap; import com.watabou.pixeldungeon.items.Item; -import com.watabou.pixeldungeon.items.Heap.Type; +import com.watabou.pixeldungeon.items.potions.Potion; +import com.watabou.pixeldungeon.items.potions.PotionOfMight; import com.watabou.pixeldungeon.items.potions.PotionOfStrength; +import com.watabou.pixeldungeon.items.scrolls.Scroll; import com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment; import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.levels.Terrain; import com.watabou.pixeldungeon.mechanics.Ballistica; @@ -88,7 +91,7 @@ protected void onZap( int cell ) { } } else { - + ch.damage( maxDistance-1 - i, this ); } @@ -101,7 +104,8 @@ protected void onZap( int cell ) { transport( heap ); break; case CHEST: - open( heap ); + case MIMIC: + heap.open( curUser ); break; default: } @@ -134,11 +138,10 @@ private void transport( Heap heap ) { if (item.doPickUp( curUser )) { if (item instanceof Dewdrop) { - + // Do nothing } else { - - if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade)item).isKnown()) || - (item instanceof PotionOfStrength && ((PotionOfStrength)item).isKnown())) { + if (((item instanceof ScrollOfUpgrade || item instanceof ScrollOfEnchantment) && ((Scroll)item).isKnown()) || + ((item instanceof PotionOfStrength || item instanceof PotionOfMight) && ((Potion)item).isKnown())) { GLog.p( TXT_YOU_NOW_HAVE, item.name() ); } else { GLog.i( TXT_YOU_NOW_HAVE, item.name() ); @@ -150,12 +153,6 @@ private void transport( Heap heap ) { } } - private void open( Heap heap ) { - heap.type = Type.HEAP; - heap.sprite.link(); - heap.sprite.drop(); - } - protected void fx( int cell, Callback callback ) { MagicMissile.force( curUser.sprite.parent, curUser.pos, cell, callback ); Sample.INSTANCE.play( Assets.SND_ZAP ); diff --git a/src/com/watabou/pixeldungeon/items/wands/WandOfTeleportation.java b/src/com/watabou/pixeldungeon/items/wands/WandOfTeleportation.java index 889d637aa6..186a7bda34 100644 --- a/src/com/watabou/pixeldungeon/items/wands/WandOfTeleportation.java +++ b/src/com/watabou/pixeldungeon/items/wands/WandOfTeleportation.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/Weapon.java b/src/com/watabou/pixeldungeon/items/weapon/Weapon.java index 30bad09f89..8283e8df42 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/Weapon.java +++ b/src/com/watabou/pixeldungeon/items/weapon/Weapon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -34,6 +34,8 @@ public class Weapon extends KindOfWeapon { + private static final int HITS_TO_KNOW = 20; + private static final String TXT_IDENTIFY = "You are now familiar enough with your %s to identify it. It is %s."; private static final String TXT_INCOMPATIBLE = @@ -49,7 +51,7 @@ public enum Imbue { } public Imbue imbue = Imbue.NONE; - private int hitsToKnow = 20; + private int hitsToKnow = HITS_TO_KNOW; protected Enchantment enchantment; @@ -67,14 +69,18 @@ public void proc( Char attacker, Char defender, int damage ) { Badges.validateItemLevelAquired( this ); } } + + use(); } - private static final String ENCHANTMENT = "enchantment"; - private static final String IMBUE = "imbue"; + private static final String UNFAMILIRIARITY = "unfamiliarity"; + private static final String ENCHANTMENT = "enchantment"; + private static final String IMBUE = "imbue"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); + bundle.put( UNFAMILIRIARITY, hitsToKnow ); bundle.put( ENCHANTMENT, enchantment ); bundle.put( IMBUE, imbue ); } @@ -82,6 +88,9 @@ public void storeInBundle( Bundle bundle ) { @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); + if ((hitsToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) { + hitsToKnow = HITS_TO_KNOW; + } enchantment = (Enchantment)bundle.get( ENCHANTMENT ); imbue = bundle.getEnum( IMBUE, Imbue.class ); } @@ -144,13 +153,18 @@ public Item upgrade( boolean enchant ) { } } else { if (enchant) { - enchant( Enchantment.random() ); + enchant(); } } return super.upgrade(); } + @Override + public int maxDurability( int lvl ) { + return 4 * (lvl < 16 ? 16 - lvl : 1); + } + @Override public String toString() { return levelKnown ? Utils.format( TXT_TO_STRING, super.toString(), STR ) : super.toString(); @@ -182,10 +196,21 @@ public Item random() { } public Weapon enchant( Enchantment ench ) { - this.enchantment = ench; + enchantment = ench; return this; } + public Weapon enchant() { + + Class oldEnchantment = enchantment != null ? enchantment.getClass() : null; + Enchantment ench = Enchantment.random(); + while (ench.getClass() == oldEnchantment) { + ench = Enchantment.random(); + } + + return enchant( ench ); + } + public boolean isEnchanted() { return enchantment != null; } @@ -199,8 +224,9 @@ public static abstract class Enchantment implements Bundlable { private static final Class[] enchants = new Class[]{ Fire.class, Poison.class, Death.class, Paralysis.class, Leech.class, - Slow.class, Swing.class, Piercing.class, Instability.class, Horror.class, Luck.class }; - private static final float[] chances= new float[]{ 10, 10, 1, 2, 1, 2, 3, 3, 3, 2, 2 }; + Slow.class, Shock.class, Instability.class, Horror.class, Luck.class, + Tempering.class}; + private static final float[] chances= new float[]{ 10, 10, 1, 2, 1, 2, 6, 3, 2, 2, 3 }; public abstract boolean proc( Weapon weapon, Char attacker, Char defender, int damage ); diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Death.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Death.java index 4aad905ea8..77d3a886aa 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Death.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Death.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Fire.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Fire.java index 24184208bb..b9485985d9 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Fire.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Fire.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Horror.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Horror.java index db202c9317..08ec1eeb18 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Horror.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Horror.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -45,7 +45,7 @@ public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { if (defender == Dungeon.hero) { Buff.affect( defender, Vertigo.class, Vertigo.duration( defender ) ); } else { - Buff.affect( defender, Terror.class, Terror.DURATION ).source = attacker; + Buff.affect( defender, Terror.class, Terror.DURATION ).object = attacker.id(); } return true; diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Instability.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Instability.java index f728b44b31..6aba856949 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Instability.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Instability.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,8 +19,6 @@ import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.items.weapon.Weapon; -import com.watabou.pixeldungeon.items.weapon.Weapon.Enchantment; -import com.watabou.pixeldungeon.items.weapon.missiles.Boomerang; public class Instability extends Weapon.Enchantment { @@ -28,13 +26,7 @@ public class Instability extends Weapon.Enchantment { @Override public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - Enchantment ench = random(); - if (weapon instanceof Boomerang) { - while (ench instanceof Piercing || ench instanceof Swing) { - ench = Enchantment.random(); - } - } - return ench.proc( weapon, attacker, defender, damage ); + return random().proc( weapon, attacker, defender, damage ); } @Override diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Leech.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Leech.java index 9fca84de06..d04936e46e 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Leech.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Leech.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Luck.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Luck.java index 0d7e265ac9..c8f8423fbb 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Luck.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Luck.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Paralysis.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Paralysis.java index 5223a9610d..85b424fc91 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Paralysis.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Paralysis.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Piercing.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Piercing.java deleted file mode 100644 index 674ded334c..0000000000 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Piercing.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya - * - * 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.watabou.pixeldungeon.items.weapon.enchantments; - -import com.watabou.pixeldungeon.actors.Actor; -import com.watabou.pixeldungeon.actors.Char; -import com.watabou.pixeldungeon.items.weapon.Weapon; -import com.watabou.pixeldungeon.items.weapon.Weapon.Enchantment; -import com.watabou.pixeldungeon.levels.Level; -import com.watabou.utils.Random; - -public class Piercing extends Enchantment { - - private static final String TXT_PIERCING = "Piercing %s"; - - @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - - int level = Math.max( 0, weapon.level ); - - int maxDamage = (int)(damage * Math.pow( 2, -1d / (level + 1) )); - if (maxDamage >= 1) { - - int d = defender.pos - attacker.pos; - int pos = defender.pos + d; - - do { - - Char ch = Actor.findChar( pos ); - if (ch == null) { - break; - } - - int dr = Random.IntRange( 0, ch.dr() ); - int dmg = Random.Int( 1, maxDamage ); - int effectiveDamage = Math.max( dmg - dr, 0 ); - - ch.damage( effectiveDamage, this ); - - ch.sprite.bloodBurstA( attacker.sprite.center(), effectiveDamage ); - ch.sprite.flash(); - - pos += d; - } while (pos >= 0 && pos < Level.LENGTH); - - return true; - - } else { - - return false; - - } - } - - @Override - public String name( String weaponName) { - return String.format( TXT_PIERCING, weaponName ); - } - -} diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Poison.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Poison.java index 6d2bb5898d..e44ceee91e 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Poison.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Poison.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Shock.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Shock.java new file mode 100644 index 0000000000..4b75ac99ca --- /dev/null +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Shock.java @@ -0,0 +1,100 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.items.weapon.enchantments; + +import java.util.ArrayList; +import java.util.HashSet; + +import com.watabou.pixeldungeon.actors.Actor; +import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.effects.Lightning; +import com.watabou.pixeldungeon.effects.particles.SparkParticle; +import com.watabou.pixeldungeon.items.weapon.Weapon; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.levels.traps.LightningTrap; +import com.watabou.utils.Random; + +public class Shock extends Weapon.Enchantment { + + private static final String TXT_SHOCKING = "Shocking %s"; + + @Override + public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + // lvl 0 - 25% + // lvl 1 - 40% + // lvl 2 - 50% + int level = Math.max( 0, weapon.level ); + + if (Random.Int( level + 4 ) >= 3) { + + points[0] = attacker.pos; + nPoints = 1; + + affected.clear(); + affected.add( attacker ); + + hit( defender, Random.Int( 1, damage / 2 ) ); + + attacker.sprite.parent.add( new Lightning( points, nPoints, null ) ); + + return true; + + } else { + + return false; + + } + } + + @Override + public String name( String weaponName ) { + return String.format( TXT_SHOCKING, weaponName ); + } + + private ArrayList affected = new ArrayList(); + + private int[] points = new int[20]; + private int nPoints; + + private void hit( Char ch, int damage ) { + + if (damage < 1) { + return; + } + + affected.add( ch ); + ch.damage( Level.water[ch.pos] && !ch.flying ? (int)(damage * 2) : damage, LightningTrap.LIGHTNING ); + + ch.sprite.centerEmitter().burst( SparkParticle.FACTORY, 3 ); + ch.sprite.flash(); + + points[nPoints++] = ch.pos; + + HashSet ns = new HashSet(); + for (int i=0; i < Level.NEIGHBOURS8.length; i++) { + Char n = Actor.findChar( ch.pos + Level.NEIGHBOURS8[i] ); + if (n != null && !affected.contains( n )) { + ns.add( n ); + } + } + + if (ns.size() > 0) { + hit( Random.element( ns ), Random.Int( damage / 2, damage ) ); + } + } +} diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Slow.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Slow.java index b34fefd8fd..8cc916f3e9 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Slow.java +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Slow.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Swing.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Swing.java deleted file mode 100644 index 3719c09883..0000000000 --- a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Swing.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya - * - * 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.watabou.pixeldungeon.items.weapon.enchantments; - -import com.watabou.pixeldungeon.actors.Actor; -import com.watabou.pixeldungeon.actors.Char; -import com.watabou.pixeldungeon.items.weapon.Weapon; -import com.watabou.pixeldungeon.items.weapon.Weapon.Enchantment; -import com.watabou.pixeldungeon.levels.Level; -import com.watabou.utils.Random; - -public class Swing extends Enchantment { - - private static final String TXT_WILD = "Wild %s"; - - @Override - public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { - - int level = Math.max( 0, weapon.level ); - - int maxDamage = (int)(damage * Math.pow( 2, -1d / (level + 1) )); - if (maxDamage >= 1) { - - int p = attacker.pos; - int[] neighbours = { - p+1, p-1, p+Level.WIDTH, p-Level.WIDTH, - p+1+Level.WIDTH, p+1-Level.WIDTH, p-1+Level.WIDTH, p-1-Level.WIDTH}; - - for (int n : neighbours) { - Char ch = Actor.findChar( n ); - if (ch != null && ch != defender && ch.isAlive()) { - - int dr = Random.IntRange( 0, ch.dr() ); - int dmg = Random.Int( 1, maxDamage ); - int effectiveDamage = Math.max( dmg - dr, 0 ); - - ch.damage( effectiveDamage, this ); - - ch.sprite.bloodBurstA( attacker.sprite.center(), effectiveDamage ); - ch.sprite.flash(); - - } - } - - return true; - - } else { - - return false; - - } - } - - @Override - public String name( String weaponName) { - return String.format( TXT_WILD, weaponName ); - } - -} diff --git a/src/com/watabou/pixeldungeon/items/weapon/enchantments/Tempering.java b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Tempering.java new file mode 100644 index 0000000000..8c464375ea --- /dev/null +++ b/src/com/watabou/pixeldungeon/items/weapon/enchantments/Tempering.java @@ -0,0 +1,47 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.items.weapon.enchantments; + +import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.items.weapon.Weapon; +import com.watabou.pixeldungeon.sprites.ItemSprite; +import com.watabou.pixeldungeon.sprites.ItemSprite.Glowing; + +public class Tempering extends Weapon.Enchantment { + + private static final String TXT_TEMPERED = "Tempered %s"; + + private static ItemSprite.Glowing GRAY = new ItemSprite.Glowing( 0xCC8888 ); + + @Override + public boolean proc( Weapon weapon, Char attacker, Char defender, int damage ) { + weapon.polish(); + return true; + } + + @Override + public Glowing glowing() { + return GRAY; + } + + @Override + public String name( String weaponName) { + return String.format( TXT_TEMPERED, weaponName ); + } + +} diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/BattleAxe.java b/src/com/watabou/pixeldungeon/items/weapon/melee/BattleAxe.java index e658df7a8e..e008760cc6 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/BattleAxe.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/BattleAxe.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Dagger.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Dagger.java index baab2fd282..1916bf0e78 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Dagger.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Dagger.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Glaive.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Glaive.java index 965855c22c..59923f7077 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Glaive.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Glaive.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Knuckles.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Knuckles.java index 5f0cdf33e9..e2d9847cd5 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Knuckles.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Knuckles.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Longsword.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Longsword.java index 9ea294590b..26f5ec1571 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Longsword.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Longsword.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Mace.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Mace.java index 4e4d987175..ee4c245137 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Mace.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Mace.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/MeleeWeapon.java b/src/com/watabou/pixeldungeon/items/weapon/melee/MeleeWeapon.java index af49f6133b..a28066ccee 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/MeleeWeapon.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/MeleeWeapon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -50,7 +50,7 @@ private int max() { } @Override - public Item upgrade() { + final public Item upgrade() { return upgrade( false ); } @@ -185,7 +185,7 @@ public Item random() { super.random(); if (Random.Int( 10 + level ) == 0) { - enchant( Enchantment.random() ); + enchant(); } return this; diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Quarterstaff.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Quarterstaff.java index 98dc7630d2..d0d06fda6b 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Quarterstaff.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Quarterstaff.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/ShortSword.java b/src/com/watabou/pixeldungeon/items/weapon/melee/ShortSword.java index 1531b3254d..aaad641994 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/ShortSword.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/ShortSword.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Spear.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Spear.java index 0a9e711bf6..4b9a5fc404 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Spear.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Spear.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/Sword.java b/src/com/watabou/pixeldungeon/items/weapon/melee/Sword.java index 14b015f382..395c4c895a 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/Sword.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/Sword.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/melee/WarHammer.java b/src/com/watabou/pixeldungeon/items/weapon/melee/WarHammer.java index 3a8a3258d7..415f21ba7a 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/melee/WarHammer.java +++ b/src/com/watabou/pixeldungeon/items/weapon/melee/WarHammer.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/Boomerang.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/Boomerang.java index 0f103e97bf..c64365658e 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/Boomerang.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/Boomerang.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -16,13 +16,11 @@ * along with this program. If not, see */ package com.watabou.pixeldungeon.items.weapon.missiles; + import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.hero.Hero; import com.watabou.pixeldungeon.items.Item; -import com.watabou.pixeldungeon.items.weapon.Weapon; -import com.watabou.pixeldungeon.items.weapon.enchantments.Piercing; -import com.watabou.pixeldungeon.items.weapon.enchantments.Swing; import com.watabou.pixeldungeon.sprites.ItemSpriteSheet; import com.watabou.pixeldungeon.sprites.MissileSprite; @@ -69,12 +67,8 @@ public Item degrade() { } @Override - public Weapon enchant( Enchantment ench ) { - while (ench instanceof Piercing || ench instanceof Swing) { - ench = Enchantment.random(); - } - - return super.enchant( ench ); + public int maxDurability( int lvl ) { + return 7 * (lvl < 16 ? 16 - lvl : 1); } @Override diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/CurareDart.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/CurareDart.java index 409be7da68..49bc7ca8ca 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/CurareDart.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/CurareDart.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/Dart.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/Dart.java index bebc5790de..90f9f486e9 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/Dart.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/Dart.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/IncendiaryDart.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/IncendiaryDart.java index d8bbc88c84..ae4995f867 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/IncendiaryDart.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/IncendiaryDart.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/Javelin.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/Javelin.java index 6fb7cc7bf1..ed6fca5d27 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/Javelin.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/Javelin.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/MissileWeapon.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/MissileWeapon.java index 5bbf02b173..ead538fe90 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/Shuriken.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/Shuriken.java index a5f37a73c8..e35817c6b6 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/Shuriken.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/Shuriken.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/items/weapon/missiles/Tamahawk.java b/src/com/watabou/pixeldungeon/items/weapon/missiles/Tamahawk.java index baa9cd1a8d..c55c4410f1 100644 --- a/src/com/watabou/pixeldungeon/items/weapon/missiles/Tamahawk.java +++ b/src/com/watabou/pixeldungeon/items/weapon/missiles/Tamahawk.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java b/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java index 5142b9c21f..d2407d7973 100644 --- a/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java +++ b/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/CavesLevel.java b/src/com/watabou/pixeldungeon/levels/CavesLevel.java index 0a1744910e..bebfefed52 100644 --- a/src/com/watabou/pixeldungeon/levels/CavesLevel.java +++ b/src/com/watabou/pixeldungeon/levels/CavesLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -156,7 +156,7 @@ protected void decorate() { for (Room r : rooms) { if (r.type == Type.STANDARD) { for (Room n : r.neigbours) { - if (n.type == Type.STANDARD && !r.connected.containsKey( n )/* && Random.Int( 2 ) == 0*/) { + if (n.type == Type.STANDARD && !r.connected.containsKey( n )) { Rect w = r.intersect( n ); if (w.left == w.right && w.bottom - w.top >= 5) { diff --git a/src/com/watabou/pixeldungeon/levels/CityBossLevel.java b/src/com/watabou/pixeldungeon/levels/CityBossLevel.java index 03c114c306..d78c716e0e 100644 --- a/src/com/watabou/pixeldungeon/levels/CityBossLevel.java +++ b/src/com/watabou/pixeldungeon/levels/CityBossLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,6 +18,7 @@ package com.watabou.pixeldungeon.levels; import com.watabou.noosa.Scene; +import com.watabou.noosa.tweeners.AlphaTweener; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Bones; import com.watabou.pixeldungeon.Dungeon; @@ -179,14 +180,21 @@ public void press( int cell, Char hero ) { Mob boss = Bestiary.mob( Dungeon.depth ); boss.state = boss.HUNTING; + int count = 0; do { boss.pos = Random.Int( LENGTH ); } while ( !passable[boss.pos] || !outsideEntraceRoom( boss.pos ) || - Dungeon.visible[boss.pos]); + (Dungeon.visible[boss.pos] && count++ < 20)); GameScene.add( boss ); + if (Dungeon.visible[boss.pos]) { + boss.notice(); + boss.sprite.alpha( 0 ); + boss.sprite.parent.add( new AlphaTweener( boss.sprite, 1, 0.1f ) ); + } + set( arenaDoor, Terrain.LOCKED_DOOR ); GameScene.updateMap( arenaDoor ); Dungeon.observe(); diff --git a/src/com/watabou/pixeldungeon/levels/CityLevel.java b/src/com/watabou/pixeldungeon/levels/CityLevel.java index 38778a43cd..3fcc667014 100644 --- a/src/com/watabou/pixeldungeon/levels/CityLevel.java +++ b/src/com/watabou/pixeldungeon/levels/CityLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/DeadEndLevel.java b/src/com/watabou/pixeldungeon/levels/DeadEndLevel.java index 5d87f4b29d..2dfcea406d 100644 --- a/src/com/watabou/pixeldungeon/levels/DeadEndLevel.java +++ b/src/com/watabou/pixeldungeon/levels/DeadEndLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java b/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java index 0345ae9d97..8e255a6c98 100644 --- a/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java +++ b/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/HallsLevel.java b/src/com/watabou/pixeldungeon/levels/HallsLevel.java index 285818e482..9cedb4fa3f 100644 --- a/src/com/watabou/pixeldungeon/levels/HallsLevel.java +++ b/src/com/watabou/pixeldungeon/levels/HallsLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -85,18 +85,11 @@ protected void decorate() { } } else - if (map[i] == Terrain.WALL) { + if (map[i] == Terrain.WALL && + map[i-1] != Terrain.WALL_DECO && map[i-WIDTH] != Terrain.WALL_DECO && + Random.Int( 20 ) == 0) { - int count = 0; - for (int j=0; j < NEIGHBOURS4.length; j++) { - if (map[i + NEIGHBOURS4[j]] == Terrain.WATER) { - count++; - } - } - - if (Random.Int( 4 ) < count) { - map[i] = Terrain.WALL_DECO; - } + map[i] = Terrain.WALL_DECO; } } diff --git a/src/com/watabou/pixeldungeon/levels/LastLevel.java b/src/com/watabou/pixeldungeon/levels/LastLevel.java index f39f1d9341..b7d8326857 100644 --- a/src/com/watabou/pixeldungeon/levels/LastLevel.java +++ b/src/com/watabou/pixeldungeon/levels/LastLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/LastShopLevel.java b/src/com/watabou/pixeldungeon/levels/LastShopLevel.java index 981cbc1cb0..cc3f486385 100644 --- a/src/com/watabou/pixeldungeon/levels/LastShopLevel.java +++ b/src/com/watabou/pixeldungeon/levels/LastShopLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/Level.java b/src/com/watabou/pixeldungeon/levels/Level.java index 9c8a8003eb..981fd8b65e 100644 --- a/src/com/watabou/pixeldungeon/levels/Level.java +++ b/src/com/watabou/pixeldungeon/levels/Level.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -49,11 +49,14 @@ import com.watabou.pixeldungeon.items.Gold; import com.watabou.pixeldungeon.items.Heap; import com.watabou.pixeldungeon.items.Item; -import com.watabou.pixeldungeon.items.Stylus; import com.watabou.pixeldungeon.items.armor.Armor; +import com.watabou.pixeldungeon.items.bags.ScrollHolder; +import com.watabou.pixeldungeon.items.bags.SeedPouch; import com.watabou.pixeldungeon.items.food.Food; import com.watabou.pixeldungeon.items.potions.PotionOfHealing; import com.watabou.pixeldungeon.items.potions.PotionOfStrength; +import com.watabou.pixeldungeon.items.scrolls.Scroll; +import com.watabou.pixeldungeon.items.scrolls.ScrollOfEnchantment; import com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade; import com.watabou.pixeldungeon.levels.features.Chasm; import com.watabou.pixeldungeon.levels.features.Door; @@ -91,8 +94,6 @@ public static enum Feeling { private static final String TXT_HIDDEN_PLATE_CLICKS = "A hidden pressure plate clicks!"; public static boolean resizingNeeded; - // This one can be different from resizingNeeded if the level - // was created in the older version of the game public static int loadedMapSize; public int[] map; @@ -163,13 +164,13 @@ public void create() { addItemToSpawn( new PotionOfStrength() ); Dungeon.potionOfStrength++; } - if (Dungeon.soeNeeded()) { + if (Dungeon.souNeeded()) { addItemToSpawn( new ScrollOfUpgrade() ); Dungeon.scrollsOfUpgrade++; } - if (Dungeon.asNeeded()) { - addItemToSpawn( new Stylus() ); - Dungeon.arcaneStyli++; + if (Dungeon.soeNeeded()) { + addItemToSpawn( new ScrollOfEnchantment() ); + Dungeon.scrollsOfEnchantment++; } if (Dungeon.depth > 1) { @@ -293,7 +294,7 @@ public int tunnelTile() { } private void adjustMapSize() { - // For levels from older saves + // For levels saved before 1.6.3 if (map.length < LENGTH) { resizingNeeded = true; @@ -338,8 +339,11 @@ public String waterTex() { } abstract protected boolean build(); + abstract protected void decorate(); + abstract protected void createMobs(); + abstract protected void createItems(); public void addVisuals( Scene scene ) { @@ -410,7 +414,7 @@ public Item itemToSpanAsPrize() { return null; } } - + private void buildFlagMaps() { for (int i=0; i < LENGTH; i++) { @@ -424,7 +428,7 @@ private void buildFlagMaps() { water[i] = (flags & Terrain.LIQUID) != 0; pit[i] = (flags & Terrain.PIT) != 0; } - + int lastRow = LENGTH - WIDTH; for (int i=0; i < WIDTH; i++) { passable[i] = avoid[i] = false; @@ -464,7 +468,7 @@ private void buildFlagMaps() { } } - private void cleanWalls() { + private void cleanWalls() { for (int i=0; i < LENGTH; i++) { boolean d = false; @@ -517,6 +521,16 @@ public Heap drop( Item item, int cell ) { } else if (Dungeon.isChallenged( Challenges.NO_HEALING ) && item instanceof PotionOfHealing) { item = new Gold( item.price() ); + } else + if (Dungeon.isChallenged( Challenges.NO_HERBALISM ) && item instanceof SeedPouch) { + item = new Gold( item.price() ); + } else + if (Dungeon.isChallenged( Challenges.NO_SCROLLS ) && (item instanceof Scroll || item instanceof ScrollHolder)) { + if (item instanceof ScrollOfUpgrade) { + // These scrolls still can be found + } else { + item = new Gold( item.price() ); + } } if ((map[cell] == Terrain.ALCHEMY) && !(item instanceof Plant.Seed)) { @@ -533,6 +547,7 @@ public Heap drop( Item item, int cell ) { heap = new Heap(); heap.pos = cell; if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) { + Dungeon.dropToChasm( item ); GameScene.discard( heap ); } else { heaps.put( cell, heap ); @@ -558,7 +573,6 @@ public Heap drop( Item item, int cell ) { } public Plant plant( Plant.Seed seed, int pos ) { - Plant plant = plants.get( pos ); if (plant != null) { plant.wither(); @@ -566,7 +580,7 @@ public Plant plant( Plant.Seed seed, int pos ) { plant = seed.couch( pos ); plants.put( pos, plant ); - + GameScene.add( plant ); return plant; @@ -757,7 +771,7 @@ public boolean[] updateFieldOfView( Char c ) { } else { Arrays.fill( fieldOfView, false ); } - + int sense = 1; if (c.isAlive()) { for (Buff b : c.buffs( MindVision.class )) { diff --git a/src/com/watabou/pixeldungeon/levels/Patch.java b/src/com/watabou/pixeldungeon/levels/Patch.java index 85563a8314..b2b6ef69cc 100644 --- a/src/com/watabou/pixeldungeon/levels/Patch.java +++ b/src/com/watabou/pixeldungeon/levels/Patch.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java b/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java index dc97bc1e5a..1643d9305f 100644 --- a/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java +++ b/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -89,7 +89,7 @@ public void restoreFromBundle( Bundle bundle ) { protected boolean build() { initRooms(); - + int distance; int retry = 0; @@ -149,7 +149,7 @@ protected boolean build() { } paint(); - + Room r = (Room)roomExit.connected.keySet().toArray()[0]; if (roomExit.connected.get( r ).y == roomExit.top) { return false; @@ -172,7 +172,6 @@ protected boolean[] grass() { } protected void paintDoors( Room r ) { - for (Room n : r.connected.keySet()) { if (r.type == Type.NULL) { @@ -196,7 +195,7 @@ protected void paintDoors( Room r ) { @Override protected void placeTraps() { - + int nTraps = nTraps(); for (int i=0; i < nTraps; i++) { @@ -265,7 +264,7 @@ protected void decorate() { Point door = roomExit.entrance(); arenaDoor = door.x + door.y * WIDTH; Painter.set( this, arenaDoor, Terrain.LOCKED_DOOR ); - + Painter.fill( this, roomExit.left + 2, roomExit.top + 2, @@ -284,7 +283,6 @@ public Actor respawner() { @Override protected void createItems() { - int keyPos = anteroom.random(); while (!passable[keyPos]) { keyPos = anteroom.random(); diff --git a/src/com/watabou/pixeldungeon/levels/PrisonLevel.java b/src/com/watabou/pixeldungeon/levels/PrisonLevel.java index 92773a7a92..944bb1c1f3 100644 --- a/src/com/watabou/pixeldungeon/levels/PrisonLevel.java +++ b/src/com/watabou/pixeldungeon/levels/PrisonLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/RegularLevel.java b/src/com/watabou/pixeldungeon/levels/RegularLevel.java index f2ed1f162b..fa86652c1f 100644 --- a/src/com/watabou/pixeldungeon/levels/RegularLevel.java +++ b/src/com/watabou/pixeldungeon/levels/RegularLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -55,7 +55,7 @@ protected boolean build() { if (!initRooms()) { return false; } - + int distance; int retry = 0; int minDistance = (int)Math.sqrt( rooms.size() ); @@ -107,11 +107,9 @@ protected boolean build() { int nConnected = (int)(rooms.size() * Random.Float( 0.5f, 0.7f )); while (connected.size() < nConnected) { - Room cr = Random.element( connected ); Room or = Random.element( cr.neigbours ); if (!connected.contains( or )) { - cr.connect( or ); connected.add( or ); } @@ -149,14 +147,13 @@ protected boolean build() { } protected boolean initRooms() { - rooms = new HashSet(); split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) ); - + if (rooms.size() < 8) { return false; } - + Room[] ra = rooms.toArray( new Room[0] ); for (int i=0; i < ra.length-1; i++) { for (int j=i+1; j < ra.length; j++) { @@ -170,7 +167,7 @@ protected boolean initRooms() { protected void assignRoomType() { int specialRooms = 0; - + for (Room r : rooms) { if (r.type == Type.NULL && r.connected.size() == 1) { @@ -355,7 +352,7 @@ protected void split( Rect rect ) { int h = rect.height(); if (w > maxRoomSize && h < minRoomSize) { - + int vw = Random.Int( rect.left + 3, rect.right - 3 ); split( new Rect( rect.left, rect.top, vw, rect.bottom ) ); split( new Rect( vw, rect.top, rect.right, rect.bottom ) ); @@ -590,7 +587,7 @@ public int randomDestination() { protected void createItems() { int nItems = 3; - while (Random.Float() < 0.3f) { + while (Random.Float() < 0.4f) { nItems++; } @@ -606,6 +603,9 @@ protected void createItems() { case 4: type = Heap.Type.CHEST; break; + case 5: + type = Dungeon.depth > 1 ? Heap.Type.MIMIC : Heap.Type.CHEST; + break; default: type = Heap.Type.HEAP; } @@ -615,12 +615,10 @@ protected void createItems() { for (Item item : itemsToSpawn) { int cell = randomDropCell(); if (item instanceof ScrollOfUpgrade) { - while (map[cell] == Terrain.FIRE_TRAP || map[cell] == Terrain.SECRET_FIRE_TRAP) { cell = randomDropCell(); } } - drop( item, cell ).type = Heap.Type.HEAP; } diff --git a/src/com/watabou/pixeldungeon/levels/Room.java b/src/com/watabou/pixeldungeon/levels/Room.java index b4ff9f4642..3719805960 100644 --- a/src/com/watabou/pixeldungeon/levels/Room.java +++ b/src/com/watabou/pixeldungeon/levels/Room.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -87,7 +87,7 @@ public void paint( Level level, Room room ) { }; public static final ArrayList SPECIALS = new ArrayList( Arrays.asList( - Type.WEAK_FLOOR, Type.MAGIC_WELL, Type.CRYPT, Type.POOL, Type.GARDEN, Type.LIBRARY, Type.ARMORY, + Type.ARMORY, Type.WEAK_FLOOR, Type.MAGIC_WELL, Type.CRYPT, Type.POOL, Type.GARDEN, Type.LIBRARY, Type.TREASURY, Type.TRAPS, Type.STORAGE, Type.STATUE, Type.LABORATORY, Type.VAULT ) ); @@ -164,6 +164,8 @@ public Collection edges() { return neigbours; } + // FIXME: use proper string constants + @Override public void storeInBundle( Bundle bundle ) { bundle.put( "left", left ); @@ -239,17 +241,3 @@ public void set( Type type ) { } } } - - - - - - - - - - - - - - diff --git a/src/com/watabou/pixeldungeon/levels/SewerBossLevel.java b/src/com/watabou/pixeldungeon/levels/SewerBossLevel.java index a8f5a65173..57bb98c2b4 100644 --- a/src/com/watabou/pixeldungeon/levels/SewerBossLevel.java +++ b/src/com/watabou/pixeldungeon/levels/SewerBossLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -93,12 +93,12 @@ protected boolean build() { Graph.buildDistanceMap( rooms, roomExit ); List path = Graph.buildPath( rooms, roomEntrance, roomExit ); - + Graph.setPrice( path, roomEntrance.distance ); - + Graph.buildDistanceMap( rooms, roomExit ); path = Graph.buildPath( rooms, roomEntrance, roomExit ); - + Room room = roomEntrance; for (Room next : path) { room.connect( next ); diff --git a/src/com/watabou/pixeldungeon/levels/SewerLevel.java b/src/com/watabou/pixeldungeon/levels/SewerLevel.java index e538effc66..b679fd8047 100644 --- a/src/com/watabou/pixeldungeon/levels/SewerLevel.java +++ b/src/com/watabou/pixeldungeon/levels/SewerLevel.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -193,7 +193,7 @@ public void update() { } } } - + public static final class WaterParticle extends PixelParticle { public WaterParticle() { diff --git a/src/com/watabou/pixeldungeon/levels/Terrain.java b/src/com/watabou/pixeldungeon/levels/Terrain.java index c21302b5fb..24e0f64696 100644 --- a/src/com/watabou/pixeldungeon/levels/Terrain.java +++ b/src/com/watabou/pixeldungeon/levels/Terrain.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/features/AlchemyPot.java b/src/com/watabou/pixeldungeon/levels/features/AlchemyPot.java index 2d4fee824b..d9f2cc5aca 100644 --- a/src/com/watabou/pixeldungeon/levels/features/AlchemyPot.java +++ b/src/com/watabou/pixeldungeon/levels/features/AlchemyPot.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/features/Chasm.java b/src/com/watabou/pixeldungeon/levels/features/Chasm.java index 57b892b2ec..df96f44596 100644 --- a/src/com/watabou/pixeldungeon/levels/features/Chasm.java +++ b/src/com/watabou/pixeldungeon/levels/features/Chasm.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -103,9 +103,7 @@ public void onDeath() { } public static void mobFall( Mob mob ) { - // Destroy instead of kill to prevent dropping loot mob.destroy(); - ((MobSprite)mob.sprite).fall(); } } diff --git a/src/com/watabou/pixeldungeon/levels/features/Door.java b/src/com/watabou/pixeldungeon/levels/features/Door.java index 29904910b2..5afc45e71b 100644 --- a/src/com/watabou/pixeldungeon/levels/features/Door.java +++ b/src/com/watabou/pixeldungeon/levels/features/Door.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/features/HighGrass.java b/src/com/watabou/pixeldungeon/levels/features/HighGrass.java index 9a584952d4..aafcbe8303 100644 --- a/src/com/watabou/pixeldungeon/levels/features/HighGrass.java +++ b/src/com/watabou/pixeldungeon/levels/features/HighGrass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -49,7 +49,6 @@ public static void trample( Level level, int pos, Char ch ) { herbalismLevel = herbalism.level; } } - // Seed if (herbalismLevel >= 0 && Random.Int( 18 ) <= Random.Int( herbalismLevel + 1 )) { level.drop( Generator.random( Generator.Category.SEED ), pos ).sprite.drop(); @@ -63,7 +62,7 @@ public static void trample( Level level, int pos, Char ch ) { int leaves = 4; - // Barkskin + // Warlock's barkskin if (ch instanceof Hero && ((Hero)ch).subClass == HeroSubClass.WARDEN) { Buff.affect( ch, Barkskin.class ).level( ch.HT / 3 ); leaves = 8; diff --git a/src/com/watabou/pixeldungeon/levels/features/Sign.java b/src/com/watabou/pixeldungeon/levels/features/Sign.java new file mode 100644 index 0000000000..925e86d920 --- /dev/null +++ b/src/com/watabou/pixeldungeon/levels/features/Sign.java @@ -0,0 +1,101 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.levels.features; + +import com.watabou.noosa.audio.Sample; +import com.watabou.pixeldungeon.Assets; +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.effects.CellEmitter; +import com.watabou.pixeldungeon.effects.particles.ElmoParticle; +import com.watabou.pixeldungeon.levels.DeadEndLevel; +import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.levels.Terrain; +import com.watabou.pixeldungeon.scenes.GameScene; +import com.watabou.pixeldungeon.utils.GLog; +import com.watabou.pixeldungeon.windows.WndMessage; + +public class Sign { + + private static final String TXT_DEAD_END = + "What are you doing here?!"; + + private static final String[] TIPS = { + "Don't overestimate your strength, use weapons and armor you can handle.", + "Not all doors in the dungeon are visible at first sight. If you are stuck, search for hidden doors.", + "Remember, that raising your strength is not the only way to access better equipment. You can go " + + "the other way, lowering its strength requirement with Scrolls of Upgrade.", + "You can spend your gold in shops on deeper levels of the dungeon. The first one is on the 6th level.", + + "Beware of Goo!", + + "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 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.", + "With 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!" + }; + + private static final String TXT_BURN = + "As you try to read the sign it bursts into greenish flames."; + + public static void read( int pos ) { + + if (Dungeon.level instanceof DeadEndLevel) { + + GameScene.show( new WndMessage( TXT_DEAD_END ) ); + + } else { + + int index = Dungeon.depth - 1; + + if (index < TIPS.length) { + GameScene.show( new WndMessage( TIPS[index] ) ); + } else { + + Level.set( pos, Terrain.EMBERS ); + GameScene.updateMap( pos ); + GameScene.discoverTile( pos, Terrain.SIGN ); + + CellEmitter.get( pos ).burst( ElmoParticle.FACTORY, 6 ); + Sample.INSTANCE.play( Assets.SND_BURNING ); + + GLog.w( TXT_BURN ); + + } + } + } +} diff --git a/src/com/watabou/pixeldungeon/levels/painters/ArmoryPainter.java b/src/com/watabou/pixeldungeon/levels/painters/ArmoryPainter.java index 4cad6ac0fd..9bafd5e302 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/ArmoryPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/ArmoryPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,6 +17,7 @@ */ package com.watabou.pixeldungeon.levels.painters; +import com.watabou.pixeldungeon.items.Bomb; import com.watabou.pixeldungeon.items.Generator; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.items.keys.IronKey; @@ -48,7 +49,7 @@ public static void paint( Level level, Room room ) { set( level, statue, Terrain.STATUE ); } - int n = Random.IntRange( 2, 3 ); + int n = 3 + (Random.Int( 4 ) == 0 ? 1 : 0); for (int i=0; i < n; i++) { int pos; do { @@ -62,9 +63,11 @@ public static void paint( Level level, Room room ) { } private static Item prize( Level level ) { - return Generator.random( Random.oneOf( - Generator.Category.ARMOR, - Generator.Category.WEAPON - ) ); + return Random.Int( 6 ) == 0 ? + new Bomb().random() : + Generator.random( Random.oneOf( + Generator.Category.ARMOR, + Generator.Category.WEAPON + ) ); } } diff --git a/src/com/watabou/pixeldungeon/levels/painters/BlacksmithPainter.java b/src/com/watabou/pixeldungeon/levels/painters/BlacksmithPainter.java index ac98fc7cfc..adf1185f29 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/BlacksmithPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/BlacksmithPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/BossExitPainter.java b/src/com/watabou/pixeldungeon/levels/painters/BossExitPainter.java index e2fa8be890..8d7d07abce 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/BossExitPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/BossExitPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/CryptPainter.java b/src/com/watabou/pixeldungeon/levels/painters/CryptPainter.java index c12102c1dd..7037d255ff 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/CryptPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/CryptPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/EntrancePainter.java b/src/com/watabou/pixeldungeon/levels/painters/EntrancePainter.java index 8f89496922..c3b71684e4 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/EntrancePainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/EntrancePainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/ExitPainter.java b/src/com/watabou/pixeldungeon/levels/painters/ExitPainter.java index ca9a96eaad..2c21717de1 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/ExitPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/ExitPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/GardenPainter.java b/src/com/watabou/pixeldungeon/levels/painters/GardenPainter.java index 3189ed9da4..46e1700a70 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/GardenPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/GardenPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,6 +18,7 @@ package com.watabou.pixeldungeon.levels.painters; import com.watabou.pixeldungeon.actors.blobs.Foliage; +import com.watabou.pixeldungeon.items.Honeypot; import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.levels.Room; import com.watabou.pixeldungeon.levels.Terrain; @@ -34,9 +35,15 @@ public static void paint( Level level, Room room ) { room.entrance().set( Room.Door.Type.REGULAR ); - int bushes = Random.Int( 3 ) == 0 ? (Random.Int( 5 ) == 0 ? 2 : 1) : 0; - for (int i=0; i < bushes; i++) { - level.plant( new Sungrass.Seed(), room.random() ); + if (Random.Int( 2 ) == 0) { + level.drop( new Honeypot(), room.random() ); + } else { + int bushes = (Random.Int( 5 ) == 0 ? 2 : 1); + for (int i=0; i < bushes; i++) { + int pos = room.random(); + set( level, pos, Terrain.GRASS ); + level.plant( new Sungrass.Seed(), pos ); + } } Foliage light = (Foliage)level.blobs.get( Foliage.class ); diff --git a/src/com/watabou/pixeldungeon/levels/painters/LaboratoryPainter.java b/src/com/watabou/pixeldungeon/levels/painters/LaboratoryPainter.java index 9a70b4ccaf..598f405c7a 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/LaboratoryPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/LaboratoryPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/LibraryPainter.java b/src/com/watabou/pixeldungeon/levels/painters/LibraryPainter.java index f14be56952..0ddf8ddaf2 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/LibraryPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/LibraryPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/MagicWellPainter.java b/src/com/watabou/pixeldungeon/levels/painters/MagicWellPainter.java index aa83b49566..c60cfe506d 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/MagicWellPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/MagicWellPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/Painter.java b/src/com/watabou/pixeldungeon/levels/painters/Painter.java index cef7487b46..fd0d43b165 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/Painter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/Painter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/PassagePainter.java b/src/com/watabou/pixeldungeon/levels/painters/PassagePainter.java index 5c3627f4f5..8c95da1315 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/PassagePainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/PassagePainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -76,14 +76,14 @@ private static int xy2p( Room room, Point xy ) { return (xy.x - room.left - 1); } else if (xy.x == room.right) { - + return (xy.y - room.top - 1) + pasWidth; } else if (xy.y == room.bottom) { - + return (room.right - xy.x - 1) + pasWidth + pasHeight; - } else { + } else /*if (xy.x == room.left)*/ { if (xy.y == room.top + 1) { return 0; @@ -108,7 +108,7 @@ private static Point p2xy( Room room, int p ) { return new Point( room.right - 1 - (p - (pasWidth + pasHeight)), room.bottom - 1 ); } else { - + return new Point( room.left + 1, room.bottom - 1 - (p - (pasWidth * 2 + pasHeight)) ); } diff --git a/src/com/watabou/pixeldungeon/levels/painters/PitPainter.java b/src/com/watabou/pixeldungeon/levels/painters/PitPainter.java index 5dc60e69dc..ed786b0abd 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/PitPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/PitPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,7 +17,6 @@ */ package com.watabou.pixeldungeon.levels.painters; - import com.watabou.pixeldungeon.items.Generator; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.items.Heap.Type; diff --git a/src/com/watabou/pixeldungeon/levels/painters/PoolPainter.java b/src/com/watabou/pixeldungeon/levels/painters/PoolPainter.java index 92a117d93c..bbab7fa8d6 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/PoolPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/PoolPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/RatKingPainter.java b/src/com/watabou/pixeldungeon/levels/painters/RatKingPainter.java index 3af1d78ef6..d060283512 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/RatKingPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/RatKingPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -49,6 +49,14 @@ public static void paint( Level level, Room room ) { addChest( level, i * Level.WIDTH + room.right - 1, door ); } + while (true) { + Heap chest = level.heaps.get( room.random() ); + if (chest != null) { + chest.type = Heap.Type.MIMIC; + break; + } + } + RatKing king = new RatKing(); king.pos = room.random( 1 ); level.mobs.add( king ); diff --git a/src/com/watabou/pixeldungeon/levels/painters/ShopPainter.java b/src/com/watabou/pixeldungeon/levels/painters/ShopPainter.java index 59b92f40c8..2258c6c652 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/ShopPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/ShopPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -55,7 +55,7 @@ public static void paint( Level level, Room room ) { fill( level, room, Terrain.WALL ); fill( level, room, 1, Terrain.EMPTY_SP ); - + pasWidth = room.width() - 2; pasHeight = room.height() - 2; int per = pasWidth * 2 + pasHeight * 2; @@ -185,7 +185,7 @@ private static int xy2p( Room room, Point xy ) { return (room.right - xy.x - 1) + pasWidth + pasHeight; - } else { + } else /*if (xy.x == room.left)*/ { if (xy.y == room.top + 1) { return 0; @@ -210,7 +210,7 @@ private static Point p2xy( Room room, int p ) { return new Point( room.right - 1 - (p - (pasWidth + pasHeight)), room.bottom - 1 ); } else { - + return new Point( room.left + 1, room.bottom - 1 - (p - (pasWidth * 2 + pasHeight)) ); } diff --git a/src/com/watabou/pixeldungeon/levels/painters/StandardPainter.java b/src/com/watabou/pixeldungeon/levels/painters/StandardPainter.java index e941a07683..429446a9b8 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/StandardPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/StandardPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/StatuePainter.java b/src/com/watabou/pixeldungeon/levels/painters/StatuePainter.java index b90c7a6544..3a1e54b63a 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/StatuePainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/StatuePainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/StoragePainter.java b/src/com/watabou/pixeldungeon/levels/painters/StoragePainter.java index c9e32d1242..1789dac925 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/StoragePainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/StoragePainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -35,7 +35,7 @@ public static void paint( Level level, Room room ) { fill( level, room, 1, floor ); int n = Random.IntRange( 3, 4 ); - for (int i=0; i < n; i++) { + for (int i=0; i < n; i++) { int pos; do { pos = room.random(); @@ -58,7 +58,8 @@ private static Item prize( Level level ) { Generator.Category.POTION, Generator.Category.SCROLL, Generator.Category.FOOD, - Generator.Category.GOLD + Generator.Category.GOLD, + Generator.Category.MISC ) ); } } diff --git a/src/com/watabou/pixeldungeon/levels/painters/TrapsPainter.java b/src/com/watabou/pixeldungeon/levels/painters/TrapsPainter.java index 45ba75fabd..3d1344b4b9 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/TrapsPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/TrapsPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/TreasuryPainter.java b/src/com/watabou/pixeldungeon/levels/painters/TreasuryPainter.java index 4d27444a7e..37edccacb0 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/TreasuryPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/TreasuryPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -42,7 +42,7 @@ public static void paint( Level level, Room room ) { do { pos = room.random(); } while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null); - level.drop( new Gold().random(), pos ).type = heapType; + level.drop( new Gold().random(), pos ).type = (i == 0 && heapType == Heap.Type.CHEST ? Heap.Type.MIMIC : heapType); } if (heapType == Heap.Type.HEAP) { diff --git a/src/com/watabou/pixeldungeon/levels/painters/TunnelPainter.java b/src/com/watabou/pixeldungeon/levels/painters/TunnelPainter.java index 2544f777e9..b99a0a9141 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/TunnelPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/TunnelPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/VaultPainter.java b/src/com/watabou/pixeldungeon/levels/painters/VaultPainter.java index de7f57e5a6..53642bd9e4 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/VaultPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/VaultPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/painters/WeakFloorPainter.java b/src/com/watabou/pixeldungeon/levels/painters/WeakFloorPainter.java index 5da8bd3d12..4f9f212877 100644 --- a/src/com/watabou/pixeldungeon/levels/painters/WeakFloorPainter.java +++ b/src/com/watabou/pixeldungeon/levels/painters/WeakFloorPainter.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/AlarmTrap.java b/src/com/watabou/pixeldungeon/levels/traps/AlarmTrap.java index 7eeca71aaf..983d929066 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/AlarmTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/AlarmTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/FireTrap.java b/src/com/watabou/pixeldungeon/levels/traps/FireTrap.java index 64d638d368..9bd6a07faa 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/FireTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/FireTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/GrippingTrap.java b/src/com/watabou/pixeldungeon/levels/traps/GrippingTrap.java index 7e5878ed02..ccc0405fc3 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/GrippingTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/GrippingTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/LightningTrap.java b/src/com/watabou/pixeldungeon/levels/traps/LightningTrap.java index d1b16a5300..f9e1bc2c76 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/LightningTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/LightningTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/ParalyticTrap.java b/src/com/watabou/pixeldungeon/levels/traps/ParalyticTrap.java index a858fef6ec..f3e2f385ae 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/ParalyticTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/ParalyticTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/PoisonTrap.java b/src/com/watabou/pixeldungeon/levels/traps/PoisonTrap.java index 84fd46eb60..554642f644 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/PoisonTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/PoisonTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/levels/traps/SummoningTrap.java b/src/com/watabou/pixeldungeon/levels/traps/SummoningTrap.java index 8f7408563b..0ceb279158 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/SummoningTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/SummoningTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -55,8 +55,6 @@ public static void trigger( int pos, Char c ) { } } - // It's complicated here, because these traps can be activated in chain - ArrayList candidates = new ArrayList(); for (int i=0; i < Level.NEIGHBOURS8.length; i++) { diff --git a/src/com/watabou/pixeldungeon/levels/traps/ToxicTrap.java b/src/com/watabou/pixeldungeon/levels/traps/ToxicTrap.java index 61957c59f7..15ba814fba 100644 --- a/src/com/watabou/pixeldungeon/levels/traps/ToxicTrap.java +++ b/src/com/watabou/pixeldungeon/levels/traps/ToxicTrap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/mechanics/Ballistica.java b/src/com/watabou/pixeldungeon/mechanics/Ballistica.java index 56d5fcd126..7dc0aca571 100644 --- a/src/com/watabou/pixeldungeon/mechanics/Ballistica.java +++ b/src/com/watabou/pixeldungeon/mechanics/Ballistica.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/mechanics/ShadowCaster.java b/src/com/watabou/pixeldungeon/mechanics/ShadowCaster.java index 696bd7a243..566fc3b772 100644 --- a/src/com/watabou/pixeldungeon/mechanics/ShadowCaster.java +++ b/src/com/watabou/pixeldungeon/mechanics/ShadowCaster.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -91,7 +91,7 @@ private static void scanSector( int cx, int cy, int m1, int m2, int m3, int m4 ) int pos = y * WIDTH + x; if (obs.isBlocked( a0 ) && obs.isBlocked( a1 ) && obs.isBlocked( a2 )) { - + // Do nothing } else { fieldOfView[pos] = true; } @@ -125,6 +125,7 @@ public void add( float o1, float o2 ) { if (length > limit && o1 <= a2[length-1]) { + // Merging several blocking cells a2[length-1] = o2; } else { diff --git a/src/com/watabou/pixeldungeon/plants/Dreamweed.java b/src/com/watabou/pixeldungeon/plants/Dreamweed.java index a0935f912e..49a2333ebe 100644 --- a/src/com/watabou/pixeldungeon/plants/Dreamweed.java +++ b/src/com/watabou/pixeldungeon/plants/Dreamweed.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,7 +17,6 @@ */ package com.watabou.pixeldungeon.plants; -import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.Char; import com.watabou.pixeldungeon.actors.blobs.Blob; import com.watabou.pixeldungeon.actors.blobs.ConfusionGas; @@ -40,7 +39,7 @@ public void activate( Char ch ) { super.activate( ch ); if (ch != null) { - GameScene.add( Blob.seed( pos, 300 + 20 * Dungeon.depth, ConfusionGas.class ) ); + GameScene.add( Blob.seed( pos, 400, ConfusionGas.class ) ); } } diff --git a/src/com/watabou/pixeldungeon/plants/Earthroot.java b/src/com/watabou/pixeldungeon/plants/Earthroot.java index 400614ebc5..e49674f10b 100644 --- a/src/com/watabou/pixeldungeon/plants/Earthroot.java +++ b/src/com/watabou/pixeldungeon/plants/Earthroot.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/plants/Fadeleaf.java b/src/com/watabou/pixeldungeon/plants/Fadeleaf.java index fda8c78e27..6b0ce575c2 100644 --- a/src/com/watabou/pixeldungeon/plants/Fadeleaf.java +++ b/src/com/watabou/pixeldungeon/plants/Fadeleaf.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -49,8 +49,6 @@ public void activate( Char ch ) { } else if (ch instanceof Mob) { - // Why do I try to choose a new position 10 times? - // I don't remember... int count = 10; int newPos; do { diff --git a/src/com/watabou/pixeldungeon/plants/Firebloom.java b/src/com/watabou/pixeldungeon/plants/Firebloom.java index 8b5e9a19a6..83384775ba 100644 --- a/src/com/watabou/pixeldungeon/plants/Firebloom.java +++ b/src/com/watabou/pixeldungeon/plants/Firebloom.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/plants/Icecap.java b/src/com/watabou/pixeldungeon/plants/Icecap.java index 6bb1c25637..81deb86d9f 100644 --- a/src/com/watabou/pixeldungeon/plants/Icecap.java +++ b/src/com/watabou/pixeldungeon/plants/Icecap.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -46,7 +46,6 @@ public void activate( Char ch ) { for (int i=0; i < Level.LENGTH; i++) { if (PathFinder.distance[i] < Integer.MAX_VALUE) { - Freezing.affect( i, fire ); } } diff --git a/src/com/watabou/pixeldungeon/plants/Plant.java b/src/com/watabou/pixeldungeon/plants/Plant.java index c3632c8edb..4e0df3d43c 100644 --- a/src/com/watabou/pixeldungeon/plants/Plant.java +++ b/src/com/watabou/pixeldungeon/plants/Plant.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -145,7 +145,9 @@ public void execute( Hero hero, String action ) { public Plant couch( int pos ) { try { - Sample.INSTANCE.play( Assets.SND_PLANT ); + if (Dungeon.visible[pos]) { + Sample.INSTANCE.play( Assets.SND_PLANT ); + } Plant plant = plantClass.newInstance(); plant.pos = pos; return plant; @@ -170,7 +172,7 @@ public int price() { } @Override - public String info() { + public String info() { return String.format( TXT_INFO, Utils.indefinite( plantName ), desc() ); } } diff --git a/src/com/watabou/pixeldungeon/plants/Sorrowmoss.java b/src/com/watabou/pixeldungeon/plants/Sorrowmoss.java index b5a8b7c2ff..e6626ebadf 100644 --- a/src/com/watabou/pixeldungeon/plants/Sorrowmoss.java +++ b/src/com/watabou/pixeldungeon/plants/Sorrowmoss.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/plants/Sungrass.java b/src/com/watabou/pixeldungeon/plants/Sungrass.java index c1a1e82aba..a3b6b6b4ce 100644 --- a/src/com/watabou/pixeldungeon/plants/Sungrass.java +++ b/src/com/watabou/pixeldungeon/plants/Sungrass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/scenes/AboutScene.java b/src/com/watabou/pixeldungeon/scenes/AboutScene.java index 803d67faaa..b6de6de98b 100644 --- a/src/com/watabou/pixeldungeon/scenes/AboutScene.java +++ b/src/com/watabou/pixeldungeon/scenes/AboutScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -75,7 +75,7 @@ protected void onClick( Touch touch ) { add( hotArea ); Image wata = Icons.WATA.get(); - wata.x = align( text.x + (text.width() - wata.width) / 2 ); + wata.x = align( (Camera.main.width - wata.width) / 2 ); wata.y = text.y - wata.height - 8; add( wata ); diff --git a/src/com/watabou/pixeldungeon/scenes/AmuletScene.java b/src/com/watabou/pixeldungeon/scenes/AmuletScene.java index c7f9ed8320..ff934b566c 100644 --- a/src/com/watabou/pixeldungeon/scenes/AmuletScene.java +++ b/src/com/watabou/pixeldungeon/scenes/AmuletScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/scenes/BadgesScene.java b/src/com/watabou/pixeldungeon/scenes/BadgesScene.java index cd6ca4d8d1..5d839a0367 100644 --- a/src/com/watabou/pixeldungeon/scenes/BadgesScene.java +++ b/src/com/watabou/pixeldungeon/scenes/BadgesScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,6 +19,7 @@ import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; +import com.watabou.noosa.Game; import com.watabou.noosa.NinePatch; import com.watabou.noosa.audio.Music; import com.watabou.pixeldungeon.Assets; @@ -30,11 +31,14 @@ import com.watabou.pixeldungeon.ui.ExitButton; import com.watabou.pixeldungeon.ui.ScrollPane; import com.watabou.pixeldungeon.ui.Window; +import com.watabou.utils.Callback; public class BadgesScene extends PixelScene { private static final String TXT_TITLE = "Your Badges"; + private static final int MAX_PANE_WIDTH = 160; + @Override public void create() { @@ -52,7 +56,7 @@ public void create() { archs.setSize( w, h ); add( archs ); - int pw = Math.min( 160, w - 6 ); + int pw = Math.min( MAX_PANE_WIDTH, w - 6 ); int ph = h - 30; NinePatch panel = Chrome.get( Chrome.Type.WINDOW ); @@ -84,6 +88,24 @@ public void create() { add( btnExit ); fadeIn(); + + Badges.loadingListener = new Callback() { + @Override + public void call() { + if (Game.scene() == BadgesScene.this) { + PixelDungeon.switchNoFade( BadgesScene.class ); + } + } + }; + } + + @Override + public void destroy() { + + Badges.saveGlobal(); + Badges.loadingListener = null; + + super.destroy(); } @Override diff --git a/src/com/watabou/pixeldungeon/scenes/CellSelector.java b/src/com/watabou/pixeldungeon/scenes/CellSelector.java index 0d489a4914..90bc54391d 100644 --- a/src/com/watabou/pixeldungeon/scenes/CellSelector.java +++ b/src/com/watabou/pixeldungeon/scenes/CellSelector.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -95,7 +95,7 @@ protected void onTouchDown( Touch t ) { @Override protected void onTouchUp( Touch t ) { if (pinching && (t == touch || t == another)) { - + pinching = false; int zoom = Math.round( camera.zoom ); @@ -110,7 +110,7 @@ protected void onTouchUp( Touch t ) { lastPos.set( touch.current ); } } - + private boolean dragging = false; private PointF lastPos = new PointF(); @@ -143,7 +143,6 @@ protected void onDrag( Touch t ) { } public void cancel() { - if (listener != null) { listener.onSelect( null ); } diff --git a/src/com/watabou/pixeldungeon/scenes/GameScene.java b/src/com/watabou/pixeldungeon/scenes/GameScene.java index 928f1aa3c4..881fc94ee5 100644 --- a/src/com/watabou/pixeldungeon/scenes/GameScene.java +++ b/src/com/watabou/pixeldungeon/scenes/GameScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,6 +18,7 @@ package com.watabou.pixeldungeon.scenes; import java.io.IOException; +import java.util.ArrayList; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; @@ -46,6 +47,7 @@ import com.watabou.pixeldungeon.effects.SpellSprite; import com.watabou.pixeldungeon.items.Heap; import com.watabou.pixeldungeon.items.Item; +import com.watabou.pixeldungeon.items.potions.Potion; import com.watabou.pixeldungeon.items.wands.WandOfBlink; import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.levels.RegularLevel; @@ -157,11 +159,12 @@ public void create() { for (int i=0; i < size; i++) { addHeapSprite( Dungeon.level.heaps.valueAt( i ) ); } - + + emitters = new Group(); effects = new Group(); emoicons = new Group(); - + mobs = new Group(); add( mobs ); @@ -297,6 +300,21 @@ public void create() { default: } + ArrayList dropped = Dungeon.droppedItems.get( Dungeon.depth ); + if (dropped != null) { + for (Item item : dropped) { + int pos = Dungeon.level.randomRespawnCell(); + if (item instanceof Potion) { + ((Potion)item).shatter( pos ); + } else if (item instanceof Plant.Seed) { + Dungeon.level.plant( (Plant.Seed)item, pos ); + } else { + Dungeon.level.drop( item, pos ); + } + } + Dungeon.droppedItems.remove( Dungeon.depth ); + } + Camera.main.target = hero; fadeIn(); } @@ -583,7 +601,7 @@ public static WndBag selectItem( WndBag.Listener listener, WndBag.Mode mode, Str return wnd; } - + static boolean cancel() { if (Dungeon.hero.curAction != null || Dungeon.hero.restoreHealth) { @@ -607,7 +625,6 @@ public static void ready() { @Override public void onSelect( Integer cell ) { if (Dungeon.hero.handle( cell )) { - // Actor.next(); Dungeon.hero.next(); } } diff --git a/src/com/watabou/pixeldungeon/scenes/InterlevelScene.java b/src/com/watabou/pixeldungeon/scenes/InterlevelScene.java index e88d8e5527..4ded60b4be 100644 --- a/src/com/watabou/pixeldungeon/scenes/InterlevelScene.java +++ b/src/com/watabou/pixeldungeon/scenes/InterlevelScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -113,47 +113,7 @@ public void run() { Generator.reset(); - Sample.INSTANCE.load( - Assets.SND_OPEN, - Assets.SND_UNLOCK, - Assets.SND_ITEM, - Assets.SND_DEWDROP, - Assets.SND_HIT, - Assets.SND_MISS, - Assets.SND_STEP, - Assets.SND_WATER, - Assets.SND_DESCEND, - 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 ); + switch (mode) { case DESCEND: @@ -175,7 +135,7 @@ public void run() { fall(); break; } - + if ((Dungeon.depth % 5) == 0) { Sample.INSTANCE.load( Assets.SND_BOSS ); } @@ -221,7 +181,6 @@ public void update() { case FADE_OUT: message.alpha( p ); - if (mode == Mode.CONTINUE || (mode == Mode.DESCEND && Dungeon.depth == 1)) { Music.INSTANCE.volume( p ); } @@ -322,7 +281,7 @@ private void resurrect() throws Exception { if (Dungeon.bossLevel()) { Dungeon.hero.resurrect( Dungeon.depth ); Dungeon.depth--; - Level level = Dungeon.newLevel(/* true */); + Level level = Dungeon.newLevel(); Dungeon.switchLevel( level, level.entrance ); } else { Dungeon.hero.resurrect( -1 ); @@ -332,5 +291,6 @@ private void resurrect() throws Exception { @Override protected void onBackPressed() { + // Do nothing } } diff --git a/src/com/watabou/pixeldungeon/scenes/IntroScene.java b/src/com/watabou/pixeldungeon/scenes/IntroScene.java index a28d32ec07..fe78128cd2 100644 --- a/src/com/watabou/pixeldungeon/scenes/IntroScene.java +++ b/src/com/watabou/pixeldungeon/scenes/IntroScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/scenes/PixelScene.java b/src/com/watabou/pixeldungeon/scenes/PixelScene.java index 7145102861..c1f483196e 100644 --- a/src/com/watabou/pixeldungeon/scenes/PixelScene.java +++ b/src/com/watabou/pixeldungeon/scenes/PixelScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -24,7 +24,6 @@ import com.watabou.input.Touchscreen; import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText.Font; -import com.watabou.noosa.audio.Sample; import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Camera; import com.watabou.noosa.ColorBlock; @@ -39,15 +38,18 @@ public class PixelScene extends Scene { - public static final float MIN_WIDTH = 128; - public static final float MIN_HEIGHT = 224; + // Minimum virtual display size for portrait orientation + public static final float MIN_WIDTH_P = 128; + public static final float MIN_HEIGHT_P = 224; + + // Minimum virtual display size for landscape orientation + public static final float MIN_WIDTH_L = 224; + public static final float MIN_HEIGHT_L = 160; public static float defaultZoom = 0; public static float minZoom; public static float maxZoom; - public static boolean landscapeAvailable; - public static Camera uiCamera; public static BitmapText.Font font1x; @@ -63,27 +65,34 @@ public void create() { GameScene.scene = null; + float minWidth, minHeight; + if (PixelDungeon.landscape()) { + minWidth = MIN_WIDTH_L; + minHeight = MIN_HEIGHT_L; + } else { + minWidth = MIN_WIDTH_P; + minHeight = MIN_HEIGHT_P; + } + defaultZoom = (int)Math.ceil( Game.density * 2.5 ); while (( - Game.width / defaultZoom < MIN_WIDTH || - Game.height / defaultZoom < MIN_HEIGHT + Game.width / defaultZoom < minWidth || + Game.height / defaultZoom < minHeight ) && defaultZoom > 1) { defaultZoom--; } - - landscapeAvailable = - Game.height / defaultZoom >= MIN_WIDTH && - Game.width / defaultZoom >= MIN_HEIGHT; if (PixelDungeon.scaleUp()) { - while ((Game.width / (defaultZoom + 1) >= MIN_WIDTH && Game.height / (defaultZoom + 1) >= MIN_HEIGHT)) { + while ( + Game.width / (defaultZoom + 1) >= minWidth && + Game.height / (defaultZoom + 1) >= minHeight) { + defaultZoom++; } } minZoom = 1; maxZoom = defaultZoom * 2; - Camera.reset( new PixelCamera( defaultZoom ) ); @@ -123,11 +132,6 @@ public void create() { font3x.baseLine = 17; font3x.tracking = -2; } - - Sample.INSTANCE.load( - Assets.SND_CLICK, - Assets.SND_BADGE, - Assets.SND_GOLD ); } @Override @@ -140,11 +144,15 @@ public void destroy() { public static float scale; public static void chooseFont( float size ) { - - float pt = size * defaultZoom; - + chooseFont( size, defaultZoom ); + } + + public static void chooseFont( float size, float zoom ) { + + float pt = size * zoom; + if (pt >= 19) { - + scale = pt / 19; if (1.5 <= scale && scale < 2) { font = font25x; @@ -153,9 +161,9 @@ public static void chooseFont( float size ) { font = font3x; scale = (int)scale; } - + } else if (pt >= 14) { - + scale = pt / 14; if (1.8 <= scale && scale < 2) { font = font2x; @@ -164,9 +172,9 @@ public static void chooseFont( float size ) { font = font25x; scale = (int)scale; } - + } else if (pt >= 12) { - + scale = pt / 12; if (1.7 <= scale && scale < 2) { font = font15x; @@ -175,9 +183,9 @@ public static void chooseFont( float size ) { font = font2x; scale = (int)scale; } - + } else if (pt >= 10) { - + scale = pt / 10; if (1.4 <= scale && scale < 2) { font = font1x; @@ -186,15 +194,15 @@ public static void chooseFont( float size ) { font = font15x; scale = (int)scale; } - + } else { - + font = font1x; scale = Math.max( 1, (int)(pt / 7) ); - + } - - scale /= defaultZoom; + + scale /= zoom; } public static BitmapText createText( float size ) { @@ -229,6 +237,7 @@ public static float align( Camera camera, float pos ) { return ((int)(pos * camera.zoom)) / camera.zoom; } + // This one should be used for UI elements public static float align( float pos ) { return ((int)(pos * defaultZoom)) / defaultZoom; } diff --git a/src/com/watabou/pixeldungeon/scenes/RankingsScene.java b/src/com/watabou/pixeldungeon/scenes/RankingsScene.java index 96049653d3..8850ad647a 100644 --- a/src/com/watabou/pixeldungeon/scenes/RankingsScene.java +++ b/src/com/watabou/pixeldungeon/scenes/RankingsScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -33,19 +33,24 @@ import com.watabou.pixeldungeon.ui.ExitButton; import com.watabou.pixeldungeon.ui.Icons; import com.watabou.pixeldungeon.ui.Window; -import com.watabou.pixeldungeon.utils.Utils; import com.watabou.pixeldungeon.windows.WndError; import com.watabou.pixeldungeon.windows.WndRanking; public class RankingsScene extends PixelScene { + private static final int DEFAULT_COLOR = 0xCCCCCC; + private static final String TXT_TITLE = "Top Rankings"; - private static final String TXT_TOTAL = "Total games played: %d"; + private static final String TXT_TOTAL = "Games played: "; private static final String TXT_NO_GAMES = "No games have been played yet."; private static final String TXT_NO_INFO = "No additional information"; - private static final float ROW_HEIGHT = 30; + private static final float ROW_HEIGHT_L = 22; + private static final float ROW_HEIGHT_P = 28; + + private static final float MAX_ROW_WIDTH = 180; + private static final float GAP = 4; private Archs archs; @@ -71,8 +76,10 @@ public void create() { if (Rankings.INSTANCE.records.size() > 0) { - float left = (w - Math.min( 160, w )) / 2 + GAP; - float top = align( (h - ROW_HEIGHT * Rankings.INSTANCE.records.size()) / 2 ); + float rowHeight = PixelDungeon.landscape() ? ROW_HEIGHT_L : ROW_HEIGHT_P; + + float left = (w - Math.min( MAX_ROW_WIDTH, w )) / 2 + GAP; + float top = align( (h - rowHeight * Rankings.INSTANCE.records.size()) / 2 ); BitmapText title = PixelScene.createText( TXT_TITLE, 9 ); title.hardlight( Window.TITLE_COLOR ); @@ -85,25 +92,41 @@ public void create() { for (Rankings.Record rec : Rankings.INSTANCE.records) { Record row = new Record( pos, pos == Rankings.INSTANCE.lastRecord, rec ); - row.setRect( left, top + pos * ROW_HEIGHT, w - left * 2, ROW_HEIGHT ); + row.setRect( left, top + pos * rowHeight, w - left * 2, rowHeight ); add( row ); pos++; } if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) { - BitmapText total = PixelScene.createText( Utils.format( TXT_TOTAL, Rankings.INSTANCE.totalNumber ), 8 ); - total.hardlight( Window.TITLE_COLOR ); + BitmapText label = PixelScene.createText( TXT_TOTAL, 8 ); + label.hardlight( DEFAULT_COLOR ); + label.measure(); + add( label ); + + BitmapText won = PixelScene.createText( Integer.toString( Rankings.INSTANCE.wonNumber ), 8 ); + won.hardlight( Window.TITLE_COLOR ); + won.measure(); + add( won ); + + BitmapText total = PixelScene.createText( "/" + Rankings.INSTANCE.totalNumber, 8 ); + total.hardlight( DEFAULT_COLOR ); total.measure(); total.x = align( (w - total.width()) / 2 ); - total.y = align( top + pos * ROW_HEIGHT + GAP ); + total.y = align( top + pos * rowHeight + GAP ); add( total ); + + float tw = label.width() + won.width() + total.width(); + label.x = align( (w - tw) / 2 ); + won.x = label.x + label.width(); + total.x = won.x + won.width(); + label.y = won.y = total.y = align( top + pos * rowHeight + GAP ); } } else { BitmapText title = PixelScene.createText( TXT_NO_GAMES, 8 ); - title.hardlight( Window.TITLE_COLOR ); + title.hardlight( DEFAULT_COLOR ); title.measure(); title.x = align( (w - title.width()) / 2 ); title.y = align( (h - title.height()) / 2 ); diff --git a/src/com/watabou/pixeldungeon/scenes/StartScene.java b/src/com/watabou/pixeldungeon/scenes/StartScene.java index adcac0cec1..e924a09d36 100644 --- a/src/com/watabou/pixeldungeon/scenes/StartScene.java +++ b/src/com/watabou/pixeldungeon/scenes/StartScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -46,6 +46,7 @@ import com.watabou.pixeldungeon.windows.WndClass; import com.watabou.pixeldungeon.windows.WndMessage; import com.watabou.pixeldungeon.windows.WndOptions; +import com.watabou.utils.Callback; public class StartScene extends PixelScene { @@ -68,11 +69,17 @@ public class StartScene extends PixelScene { private static final String TXT_WIN_THE_GAME = "To unlock \"Challenges\", win the game with any character class."; - private static final float WIDTH = 116; - private static final float HEIGHT = 220; + private static final float WIDTH_P = 116; + private static final float HEIGHT_P = 220; + + private static final float WIDTH_L = 224; + private static final float HEIGHT_L = 124; private static HashMap shields = new HashMap(); + private float buttonX; + private float buttonY; + private GameButton btnLoad; private GameButton btnNewGame; @@ -92,9 +99,18 @@ public void create() { int w = Camera.main.width; int h = Camera.main.height; + + float width, height; + if (PixelDungeon.landscape()) { + width = WIDTH_L; + height = HEIGHT_L; + } else { + width = WIDTH_P; + height = HEIGHT_P; + } - float left = (w - WIDTH) / 2; - float top = (h - HEIGHT) / 2; + float left = (w - width) / 2; + float top = (h - height) / 2; float bottom = h - top; Archs archs = new Archs(); @@ -103,9 +119,12 @@ public void create() { Image title = BannerSprites.get( Type.SELECT_YOUR_HERO ); title.x = align( (w - title.width()) / 2 ); - title.y = top; + title.y = align( top ); add( title ); + buttonX = left; + buttonY = bottom - BUTTON_HEIGHT; + btnNewGame = new GameButton( TXT_NEW ) { @Override protected void onClick() { @@ -135,43 +154,64 @@ protected void onClick() { }; add( btnLoad ); + float centralHeight = buttonY - title.y - title.height(); + HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS }; - float shieldW = WIDTH / 2; - float shieldH = Math.min( (bottom - BUTTON_HEIGHT - title.y - title.height()) / 2, shieldW * 1.2f ); - top = (bottom - BUTTON_HEIGHT + title.y + title.height() - shieldH * 2) / 2; - for (int i=0; i < classes.length; i++) { - ClassShield shield = new ClassShield( classes[i] ); - shield.setRect( - left + (i % 2) * shieldW, - top + (i / 2) * shieldH, - shieldW, shieldH ); + for (HeroClass cl : classes) { + ClassShield shield = new ClassShield( cl ); + shields.put( cl, shield ); add( shield ); + } + if (PixelDungeon.landscape()) { + float shieldW = width / 4; + float shieldH = Math.min( centralHeight, shieldW ); + top = title.y + title.height + (centralHeight - shieldH) / 2; + for (int i=0; i < classes.length; i++) { + ClassShield shield = shields.get( classes[i] ); + shield.setRect( left + i * shieldW, top, shieldW, shieldH ); + } - shields.put( classes[i], shield ); + ChallengeButton challenge = new ChallengeButton(); + challenge.setPos( + w / 2 - challenge.width() / 2, + top + shieldH - challenge.height() / 2 ); + add( challenge ); + + } else { + float shieldW = width / 2; + float shieldH = Math.min( centralHeight / 2, shieldW * 1.2f ); + top = title.y + title.height() + centralHeight / 2 - shieldH; + for (int i=0; i < classes.length; i++) { + ClassShield shield = shields.get( classes[i] ); + shield.setRect( + left + (i % 2) * shieldW, + top + (i / 2) * shieldH, + shieldW, shieldH ); + } + + ChallengeButton challenge = new ChallengeButton(); + challenge.setPos( + w / 2 - challenge.width() / 2, + top + shieldH - challenge.height() / 2 ); + add( challenge ); } unlock = new Group(); add( unlock ); - ChallengeButton challenge = new ChallengeButton(); - challenge.setPos( - w / 2 - challenge.width() / 2, - top + shieldH - challenge.height() / 2 ); - add( challenge ); - if (!(huntressUnlocked = Badges.isUnlocked( Badges.Badge.BOSS_SLAIN_3 ))) { BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 9 ); - text.maxWidth = (int)WIDTH; + text.maxWidth = (int)width; text.measure(); float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2; for (BitmapText line : text.new LineSplitter().split()) { line.measure(); line.hardlight( 0xFFFF00 ); - line.x = PixelScene.align( left + WIDTH / 2 - line.width() / 2 ); + line.x = PixelScene.align( w / 2 - line.width() / 2 ); line.y = PixelScene.align( pos ); unlock.add( line ); @@ -187,6 +227,24 @@ protected void onClick() { updateClass( HeroClass.values()[PixelDungeon.lastClass()] ); fadeIn(); + + Badges.loadingListener = new Callback() { + @Override + public void call() { + if (Game.scene() == StartScene.this) { + PixelDungeon.switchNoFade( StartScene.class ); + } + } + }; + } + + @Override + public void destroy() { + + Badges.saveGlobal(); + Badges.loadingListener = null; + + super.destroy(); } private void updateClass( HeroClass cl ) { @@ -204,32 +262,29 @@ private void updateClass( HeroClass cl ) { if (cl != HeroClass.HUNTRESS || huntressUnlocked) { unlock.visible = false; - - float buttonPos = (Camera.main.height + HEIGHT) / 2 - BUTTON_HEIGHT; - - float left = (Camera.main.width - WIDTH) / 2; GamesInProgress.Info info = GamesInProgress.check( curClass ); if (info != null) { btnLoad.visible = true; - btnLoad.secondary( Utils.format( TXT_DPTH_LVL, info.depth, info.level ) ); + btnLoad.secondary( Utils.format( TXT_DPTH_LVL, info.depth, info.level ), info.challenges ); + btnNewGame.visible = true; - btnNewGame.secondary( TXT_ERASE ); + btnNewGame.secondary( TXT_ERASE, false ); - float w = (WIDTH - GAP) / 2; + float w = (Camera.main.width - GAP) / 2 - buttonX; btnLoad.setRect( - left, buttonPos, w, BUTTON_HEIGHT ); + buttonX, buttonY, w, BUTTON_HEIGHT ); btnNewGame.setRect( - btnLoad.right() + GAP, buttonPos, w, BUTTON_HEIGHT ); + btnLoad.right() + GAP, buttonY, w, BUTTON_HEIGHT ); } else { btnLoad.visible = false; btnNewGame.visible = true; - btnNewGame.secondary( null ); - btnNewGame.setRect( left, buttonPos, WIDTH, BUTTON_HEIGHT ); + btnNewGame.secondary( null, false ); + btnNewGame.setRect( buttonX, buttonY, Camera.main.width - buttonX * 2, BUTTON_HEIGHT ); } } else { @@ -261,7 +316,8 @@ protected void onBackPressed() { private static class GameButton extends RedButton { - private static final int SECONDARY_COLOR = 0xCACFC2; + private static final int SECONDARY_COLOR_N = 0xCACFC2; + private static final int SECONDARY_COLOR_H = 0xFFFF88; private BitmapText secondary; @@ -276,7 +332,6 @@ protected void createChildren() { super.createChildren(); secondary = createText( 6 ); - secondary.hardlight( SECONDARY_COLOR ); add( secondary ); } @@ -294,9 +349,11 @@ protected void layout() { } } - public void secondary( String text ) { + public void secondary( String text, boolean highlighted ) { secondary.text( text ); secondary.measure(); + + secondary.hardlight( highlighted ? SECONDARY_COLOR_H : SECONDARY_COLOR_N ); } } @@ -304,6 +361,12 @@ private class ClassShield extends Button { private static final float MIN_BRIGHTNESS = 0.6f; + private static final int BASIC_NORMAL = 0x444444; + private static final int BASIC_HIGHLIGHTED = 0xCACFC2; + + private static final int MASTERY_NORMAL = 0x666644; + private static final int MASTERY_HIGHLIGHTED= 0xFFFF88; + private static final int WIDTH = 24; private static final int HEIGHT = 28; private static final int SCALE = 2; @@ -316,6 +379,9 @@ private class ClassShield extends Button { private float brightness; + private int normal; + private int highlighted; + public ClassShield( HeroClass cl ) { super(); @@ -324,8 +390,17 @@ public ClassShield( HeroClass cl ) { avatar.frame( cl.ordinal() * WIDTH, 0, WIDTH, HEIGHT ); avatar.scale.set( SCALE ); + if (Badges.isUnlocked( cl.masteryBadge() )) { + normal = MASTERY_NORMAL; + highlighted = MASTERY_HIGHLIGHTED; + } else { + normal = BASIC_NORMAL; + highlighted = BASIC_HIGHLIGHTED; + } + name.text( cl.name() ); name.measure(); + name.hardlight( normal ); brightness = MIN_BRIGHTNESS; updateBrightness(); @@ -385,10 +460,10 @@ public void update() { public void highlight( boolean value ) { if (value) { brightness = 1.0f; - name.hardlight( 0xCACFC2 ); + name.hardlight( highlighted ); } else { brightness = 0.999f; - name.hardlight( 0x444444 ); + name.hardlight( normal ); } updateBrightness(); @@ -433,7 +508,7 @@ protected void layout() { @Override protected void onClick() { if (Badges.isUnlocked( Badges.Badge.VICTORY )) { - add( new WndChallenges( PixelDungeon.challenges(), true ) { + StartScene.this.add( new WndChallenges( PixelDungeon.challenges(), true ) { public void onBackPressed() { super.onBackPressed(); image.copy( Icons.get( PixelDungeon.challenges() > 0 ? @@ -441,7 +516,7 @@ public void onBackPressed() { }; } ); } else { - add( new WndMessage( TXT_WIN_THE_GAME ) ); + StartScene.this.add( new WndMessage( TXT_WIN_THE_GAME ) ); } } diff --git a/src/com/watabou/pixeldungeon/scenes/SurfaceScene.java b/src/com/watabou/pixeldungeon/scenes/SurfaceScene.java index 67e2e9f095..908e642346 100644 --- a/src/com/watabou/pixeldungeon/scenes/SurfaceScene.java +++ b/src/com/watabou/pixeldungeon/scenes/SurfaceScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -46,8 +46,16 @@ public class SurfaceScene extends PixelScene { - private static final int WIDTH = 80; - private static final int HEIGHT = 112; + private static final int FRAME_WIDTH = 88; + private static final int FRAME_HEIGHT = 125; + + private static final int FRAME_MARGIN_TOP = 9; + private static final int FRAME_MARGIN_X = 4; + + private static final int BUTTON_HEIGHT = 20; + + private static final int SKY_WIDTH = 80; + private static final int SKY_HEIGHT = 112; private static final int NSTARS = 100; private static final int NCLOUDS = 5; @@ -71,11 +79,11 @@ public void create() { archs.setSize( w, h ); add( archs ); - float vx = align( (w - WIDTH) / 2 ); - float vy = align( (h - HEIGHT) / 2 ); + float vx = align( (w - SKY_WIDTH) / 2 ); + float vy = align( (h - SKY_HEIGHT - BUTTON_HEIGHT) / 2 ); Point s = Camera.main.cameraToScreen( vx, vy ); - viewport = new Camera( s.x, s.y, WIDTH, HEIGHT, defaultZoom ); + viewport = new Camera( s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom ); Camera.add( viewport ); Group window = new Group(); @@ -85,21 +93,21 @@ public void create() { boolean dayTime = !Dungeon.nightMode; Sky sky = new Sky( dayTime ); - sky.scale.set( WIDTH, HEIGHT ); + sky.scale.set( SKY_WIDTH, SKY_HEIGHT ); window.add( sky ); if (!dayTime) { for (int i=0; i < NSTARS; i++) { float size = Random.Float(); ColorBlock star = new ColorBlock( size, size, 0xFFFFFFFF ); - star.x = Random.Float( WIDTH ) - size / 2; - star.y = Random.Float( HEIGHT ) - size / 2; - star.am = size * (1 - star.y / HEIGHT); + star.x = Random.Float( SKY_WIDTH ) - size / 2; + star.y = Random.Float( SKY_HEIGHT ) - size / 2; + star.am = size * (1 - star.y / SKY_HEIGHT); window.add( star ); } } - float range = HEIGHT * 2 / 3; + float range = SKY_HEIGHT * 2 / 3; for (int i=0; i < NCLOUDS; i++) { Cloud cloud = new Cloud( (NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float( range / NCLOUDS ), dayTime ); window.add( cloud ); @@ -108,27 +116,22 @@ public void create() { int nPatches = (int)(sky.width() / GrassPatch.WIDTH + 1); for (int i=0; i < nPatches * 4; i++) { - GrassPatch patch = new GrassPatch( (i - 0.75f) * GrassPatch.WIDTH / 4, HEIGHT + 1, dayTime ); + GrassPatch patch = new GrassPatch( (i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime ); patch.brightness( dayTime ? 0.7f : 0.4f ); window.add( patch ); } Avatar a = new Avatar( Dungeon.hero.heroClass ); - a.x = PixelScene.align( (WIDTH - a.width) / 2 ); - a.y = HEIGHT - a.height + 1; + a.x = PixelScene.align( (SKY_WIDTH - a.width) / 2 ); + a.y = SKY_HEIGHT - a.height; window.add( a ); final Pet pet = new Pet(); pet.rm = pet.gm = pet.bm = 1.2f; - pet.x = WIDTH / 2 + 2; - pet.y = HEIGHT - pet.height; + pet.x = SKY_WIDTH / 2 + 2; + pet.y = SKY_HEIGHT - pet.height; window.add( pet ); - if (dayTime) { - a.brightness( 1.2f ); - pet.brightness( 1.2f ); - } - window.add( new TouchArea( sky ) { protected void onClick( Touch touch ) { pet.jump(); @@ -136,27 +139,31 @@ protected void onClick( Touch touch ) { } ); for (int i=0; i < nPatches; i++) { - GrassPatch patch = new GrassPatch( (i - 0.5f) * GrassPatch.WIDTH, HEIGHT, dayTime ); + GrassPatch patch = new GrassPatch( (i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime ); patch.brightness( dayTime ? 1.0f : 0.8f ); window.add( patch ); } Image frame = new Image( Assets.SURFACE ); - if (!dayTime) { + frame.frame( 0, 0, FRAME_WIDTH, FRAME_HEIGHT ); + frame.x = vx - FRAME_MARGIN_X; + frame.y = vy - FRAME_MARGIN_TOP; + add( frame ); + + if (dayTime) { + a.brightness( 1.2f ); + pet.brightness( 1.2f ); + } else { frame.hardlight( 0xDDEEFF ); } - frame.frame( 0, 0, 88, 125 ); - frame.x = vx - 4; - frame.y = vy - 9; - add( frame ); RedButton gameOver = new RedButton( "Game Over" ) { protected void onClick() { Game.switchScene( TitleScene.class ); } }; - gameOver.setSize( WIDTH - 10, 20 ); - gameOver.setPos( 5 + frame.x + 4, frame.y + frame.height + 4 ); + gameOver.setSize( SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT ); + gameOver.setPos( frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4 ); add( gameOver ); Badges.validateHappyEnd(); @@ -267,8 +274,8 @@ public Cloud( float y, boolean dayTime ) { this.y = y; - scale.set( 1 - y / HEIGHT ); - x = Random.Float( WIDTH + width() ) - width(); + scale.set( 1 - y / SKY_HEIGHT ); + x = Random.Float( SKY_WIDTH + width() ) - width(); speed.x = scale.x * (dayTime ? +8 : -8); if (dayTime) { @@ -282,10 +289,10 @@ public Cloud( float y, boolean dayTime ) { @Override public void update() { super.update(); - if (speed.x > 0 && x > WIDTH) { + if (speed.x > 0 && x > SKY_WIDTH) { x = -width(); } else if (speed.x < 0 && x < -width()) { - x = WIDTH; + x = SKY_WIDTH; } } } diff --git a/src/com/watabou/pixeldungeon/scenes/TitleScene.java b/src/com/watabou/pixeldungeon/scenes/TitleScene.java index 33eb0349d3..2914aa3c78 100644 --- a/src/com/watabou/pixeldungeon/scenes/TitleScene.java +++ b/src/com/watabou/pixeldungeon/scenes/TitleScene.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -17,6 +17,10 @@ */ package com.watabou.pixeldungeon.scenes; +import javax.microedition.khronos.opengles.GL10; + +import android.opengl.GLES20; + import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; @@ -52,8 +56,6 @@ public void create() { int w = Camera.main.width; int h = Camera.main.height; - float height = 180; - Archs archs = new Archs(); archs.setSize( w, h ); add( archs ); @@ -61,19 +63,39 @@ public void create() { Image title = BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON ); add( title ); + float height = title.height + + (PixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2); + title.x = (w - title.width()) / 2; title.y = (h - height) / 2; placeTorch( title.x + 18, title.y + 20 ); placeTorch( title.x + title.width - 18, title.y + 20 ); + Image signs = new Image( BannerSprites.get( BannerSprites.Type.PIXEL_DUNGEON_SIGNS ) ) { + private float time = 0; + @Override + public void update() { + super.update(); + am = (float)Math.sin( -(time += Game.elapsed) ); + } + @Override + public void draw() { + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + super.draw(); + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + } + }; + signs.x = title.x; + signs.y = title.y; + add( signs ); + DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) { @Override protected void onClick() { PixelDungeon.switchNoFade( BadgesScene.class ); } }; - btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE ); add( btnBadges ); DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) { @@ -82,7 +104,6 @@ protected void onClick() { PixelDungeon.switchNoFade( AboutScene.class ); } }; - btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE ); add( btnAbout ); DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) { @@ -91,7 +112,6 @@ protected void onClick() { PixelDungeon.switchNoFade( StartScene.class ); } }; - btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE ); add( btnPlay ); DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) { @@ -100,9 +120,21 @@ protected void onClick() { PixelDungeon.switchNoFade( RankingsScene.class ); } }; - btnHighscores.setPos( w / 2, btnPlay.top() ); add( btnHighscores ); + if (PixelDungeon.landscape()) { + float y = (h + height) / 2 - DashboardItem.SIZE; + btnHighscores .setPos( w / 2 - btnHighscores.width(), y ); + btnBadges .setPos( w / 2, y ); + btnPlay .setPos( btnHighscores.left() - btnPlay.width(), y ); + btnAbout .setPos( btnBadges.right(), y ); + } else { + btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE ); + btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE ); + btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE ); + btnHighscores.setPos( w / 2, btnPlay.top() ); + } + BitmapText version = new BitmapText( "v " + Game.version, font1x ); version.measure(); version.hardlight( 0x888888 ); diff --git a/src/com/watabou/pixeldungeon/sprites/AcidicSprite.java b/src/com/watabou/pixeldungeon/sprites/AcidicSprite.java index eeac79c0f1..e03f70e30d 100644 --- a/src/com/watabou/pixeldungeon/sprites/AcidicSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/AcidicSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/AlbinoSprite.java b/src/com/watabou/pixeldungeon/sprites/AlbinoSprite.java index 473dcec543..a7eef199cf 100644 --- a/src/com/watabou/pixeldungeon/sprites/AlbinoSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/AlbinoSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/BanditSprite.java b/src/com/watabou/pixeldungeon/sprites/BanditSprite.java index a4d8cc6a52..12b9434d28 100644 --- a/src/com/watabou/pixeldungeon/sprites/BanditSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/BanditSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/BatSprite.java b/src/com/watabou/pixeldungeon/sprites/BatSprite.java index 050e139f9f..eaabfc76ee 100644 --- a/src/com/watabou/pixeldungeon/sprites/BatSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/BatSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/BeeSprite.java b/src/com/watabou/pixeldungeon/sprites/BeeSprite.java new file mode 100644 index 0000000000..c998d68732 --- /dev/null +++ b/src/com/watabou/pixeldungeon/sprites/BeeSprite.java @@ -0,0 +1,51 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.sprites; + +import com.watabou.noosa.TextureFilm; +import com.watabou.pixeldungeon.Assets; + +public class BeeSprite extends MobSprite { + + public BeeSprite() { + super(); + + texture( Assets.BEE ); + + TextureFilm frames = new TextureFilm( texture, 16, 16 ); + + idle = new Animation( 12, true ); + idle.frames( frames, 0, 1, 1, 0, 2, 2 ); + + run = new Animation( 15, true ); + run.frames( frames, 0, 1, 1, 0, 2, 2 ); + + attack = new Animation( 20, false ); + attack.frames( frames, 3, 4, 5, 6 ); + + die = new Animation( 20, false ); + die.frames( frames, 7, 8, 9, 10 ); + + play( idle ); + } + + @Override + public int blood() { + return 0xffd500; + } +} diff --git a/src/com/watabou/pixeldungeon/sprites/BlacksmithSprite.java b/src/com/watabou/pixeldungeon/sprites/BlacksmithSprite.java index fb8e6be00e..a270d8605f 100644 --- a/src/com/watabou/pixeldungeon/sprites/BlacksmithSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/BlacksmithSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/BruteSprite.java b/src/com/watabou/pixeldungeon/sprites/BruteSprite.java index 90ccc923d7..70d5f6186e 100644 --- a/src/com/watabou/pixeldungeon/sprites/BruteSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/BruteSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/BurningFistSprite.java b/src/com/watabou/pixeldungeon/sprites/BurningFistSprite.java index ae56f1d792..13bd11f3cf 100644 --- a/src/com/watabou/pixeldungeon/sprites/BurningFistSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/BurningFistSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/CharSprite.java b/src/com/watabou/pixeldungeon/sprites/CharSprite.java index e09d2639ee..4c2715576e 100644 --- a/src/com/watabou/pixeldungeon/sprites/CharSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/CharSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -19,6 +19,7 @@ import com.watabou.noosa.Game; import com.watabou.noosa.MovieClip; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.particles.Emitter; import com.watabou.noosa.tweeners.PosTweener; @@ -43,7 +44,6 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip.Listener { - // Color constants for floating text public static final int DEFAULT = 0xFFFFFF; public static final int POSITIVE = 0x00FF00; public static final int NEGATIVE = 0xFF0000; @@ -76,14 +76,15 @@ public enum State { protected EmoIcon emo; + private Tweener jumpTweener; + private Callback jumpCallback; + private float flashTime = 0; protected boolean sleeping = false; - // Char owner public Char ch; - // The sprite is currently in motion public boolean isMoving = false; public CharSprite() { @@ -187,6 +188,17 @@ public void turnTo( int from, int to ) { } } + public void jump( int from, int to, Callback callback ) { + jumpCallback = callback; + + int distance = Level.distance( from, to ); + jumpTweener = new JumpTweener( this, worldToCamera( to ), distance * 4, distance * 0.1f ); + jumpTweener.listener = this; + parent.add( jumpTweener ); + + turnTo( from, to ); + } + public void die() { sleeping = false; play( die ); @@ -228,7 +240,6 @@ public void bloodBurstA( PointF from, int damage ) { } } - // Blood color public int blood() { return 0xFFBB0000; } @@ -382,7 +393,16 @@ public void kill() { @Override public void onComplete( Tweener tweener ) { - if (tweener == motion) { + if (tweener == jumpTweener) { + + if (visible && Level.water[ch.pos] && !ch.flying) { + GameScene.ripple( ch.pos ); + } + if (jumpCallback != null) { + jumpCallback.call(); + } + + } else if (tweener == motion) { isMoving = false; @@ -413,4 +433,29 @@ public void onComplete( Animation anim ) { } } + + private static class JumpTweener extends Tweener { + + public Visual visual; + + public PointF start; + public PointF end; + + public float height; + + public JumpTweener( Visual visual, PointF pos, float height, float time ) { + super( visual, time ); + + this.visual = visual; + start = visual.point(); + end = pos; + + this.height = height; + } + + @Override + protected void updateValues( float progress ) { + visual.point( PointF.inter( start, end, progress ).offset( 0, -height * 4 * progress * (1 - progress) ) ); + } + } } diff --git a/src/com/watabou/pixeldungeon/sprites/CrabSprite.java b/src/com/watabou/pixeldungeon/sprites/CrabSprite.java index f06c2f5189..76e8b8f27a 100644 --- a/src/com/watabou/pixeldungeon/sprites/CrabSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/CrabSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/DM300Sprite.java b/src/com/watabou/pixeldungeon/sprites/DM300Sprite.java index 29527ef1f1..2f9f404e78 100644 --- a/src/com/watabou/pixeldungeon/sprites/DM300Sprite.java +++ b/src/com/watabou/pixeldungeon/sprites/DM300Sprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/DiscardedItemSprite.java b/src/com/watabou/pixeldungeon/sprites/DiscardedItemSprite.java index 1f14ba904f..687eb0aa09 100644 --- a/src/com/watabou/pixeldungeon/sprites/DiscardedItemSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/DiscardedItemSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ElementalSprite.java b/src/com/watabou/pixeldungeon/sprites/ElementalSprite.java index a74a358a59..d93209c8a2 100644 --- a/src/com/watabou/pixeldungeon/sprites/ElementalSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ElementalSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/EyeSprite.java b/src/com/watabou/pixeldungeon/sprites/EyeSprite.java index f56bd601bf..c7d3d76ca5 100644 --- a/src/com/watabou/pixeldungeon/sprites/EyeSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/EyeSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/FetidRatSprite.java b/src/com/watabou/pixeldungeon/sprites/FetidRatSprite.java index 3942f4041c..021e5a2e47 100644 --- a/src/com/watabou/pixeldungeon/sprites/FetidRatSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/FetidRatSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/GhostSprite.java b/src/com/watabou/pixeldungeon/sprites/GhostSprite.java index 917f49797e..39e68b5695 100644 --- a/src/com/watabou/pixeldungeon/sprites/GhostSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/GhostSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/GnollSprite.java b/src/com/watabou/pixeldungeon/sprites/GnollSprite.java index a4bc706bd1..f618ef2f41 100644 --- a/src/com/watabou/pixeldungeon/sprites/GnollSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/GnollSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/GolemSprite.java b/src/com/watabou/pixeldungeon/sprites/GolemSprite.java index 7179e9d724..bbb16a2067 100644 --- a/src/com/watabou/pixeldungeon/sprites/GolemSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/GolemSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/GooSprite.java b/src/com/watabou/pixeldungeon/sprites/GooSprite.java index ae730e8af2..7554510b0a 100644 --- a/src/com/watabou/pixeldungeon/sprites/GooSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/GooSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,11 +18,19 @@ package com.watabou.pixeldungeon.sprites; import com.watabou.noosa.TextureFilm; +import com.watabou.noosa.particles.Emitter; +import com.watabou.noosa.particles.PixelParticle; +import com.watabou.noosa.particles.Emitter.Factory; import com.watabou.pixeldungeon.Assets; +import com.watabou.utils.PointF; +import com.watabou.utils.Random; public class GooSprite extends MobSprite { private Animation pump; + private Animation jump; + + private Emitter spray; public GooSprite() { super(); @@ -40,6 +48,9 @@ public GooSprite() { pump = new Animation( 20, true ); pump.frames( frames, 0, 1 ); + jump = new Animation( 1, true ); + jump.frames( frames, 6 ); + attack = new Animation( 10, false ); attack.frames( frames, 5, 0, 6 ); @@ -53,8 +64,59 @@ public void pumpUp() { play( pump ); } + @Override + public void play( Animation anim, boolean force ) { + super.play( anim, force ); + + if (anim == pump) { + spray = centerEmitter(); + spray.pour( GooParticle.FACTORY, 0.04f ); + } else if (spray != null) { + spray.on = false; + spray = null; + } + } + @Override public int blood() { return 0xFF000000; } + + public static class GooParticle extends PixelParticle.Shrinking { + + public static final Emitter.Factory FACTORY = new Factory() { + @Override + public void emit( Emitter emitter, int index, float x, float y ) { + ((GooParticle)emitter.recycle( GooParticle.class )).reset( x, y ); + } + }; + + public GooParticle() { + super(); + + color( 0x000000 ); + lifespan = 0.3f; + + acc.set( 0, +50 ); + } + + public void reset( float x, float y ) { + revive(); + + this.x = x; + this.y = y; + + left = lifespan; + + size = 4; + speed.polar( -Random.Float( PointF.PI ), Random.Float( 32, 48 ) ); + } + + @Override + public void update() { + super.update(); + float p = left / lifespan; + am = p > 0.5f ? (1 - p) * 2f : 1; + } + } } diff --git a/src/com/watabou/pixeldungeon/sprites/HeroSprite.java b/src/com/watabou/pixeldungeon/sprites/HeroSprite.java index 4403360af9..e441b7772e 100644 --- a/src/com/watabou/pixeldungeon/sprites/HeroSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/HeroSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -24,16 +24,11 @@ import com.watabou.noosa.Camera; import com.watabou.noosa.Image; import com.watabou.noosa.TextureFilm; -import com.watabou.noosa.Visual; -import com.watabou.noosa.tweeners.Tweener; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.actors.hero.Hero; import com.watabou.pixeldungeon.actors.hero.HeroClass; -import com.watabou.pixeldungeon.levels.Level; -import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.utils.Callback; -import com.watabou.utils.PointF; public class HeroSprite extends CharSprite { @@ -46,9 +41,6 @@ public class HeroSprite extends CharSprite { private Animation fly; - private Tweener jumpTweener; - private Callback jumpCallback; - public HeroSprite() { super(); @@ -100,34 +92,12 @@ public void move( int from, int to ) { Camera.main.target = this; } + @Override public void jump( int from, int to, Callback callback ) { - jumpCallback = callback; - - int distance = Level.distance( from, to ); - jumpTweener = new JumpTweener( this, worldToCamera( to ), distance * 4, distance * 0.1f ); - jumpTweener.listener = this; - parent.add( jumpTweener ); - - turnTo( from, to ); + super.jump( from, to, callback ); play( fly ); } - @Override - public void onComplete( Tweener tweener ) { - if (tweener == jumpTweener) { - - if (visible && Level.water[ch.pos] && !ch.flying) { - GameScene.ripple( ch.pos ); - } - if (jumpCallback != null) { - jumpCallback.call(); - } - - } else { - super.onComplete( tweener ); - } - } - @Override public void update() { sleeping = ((Hero)ch).restoreHealth; @@ -142,7 +112,6 @@ public boolean sprint( boolean on ) { public static TextureFilm tiers() { if (tiers == null) { - // Sprites for all classes are the same in size SmartTexture texture = TextureCache.get( Assets.ROGUE ); tiers = new TextureFilm( texture, texture.width, FRAME_HEIGHT ); } @@ -160,29 +129,4 @@ public static Image avatar( HeroClass cl, int armorTier ) { return avatar; } - - private static class JumpTweener extends Tweener { - - public Visual visual; - - public PointF start; - public PointF end; - - public float height; - - public JumpTweener( Visual visual, PointF pos, float height, float time ) { - super( visual, time ); - - this.visual = visual; - start = visual.point(); - end = pos; - - this.height = height; - } - - @Override - protected void updateValues( float progress ) { - visual.point( PointF.inter( start, end, progress ).offset( 0, -height * 4 * progress * (1 - progress) ) ); - } - } } diff --git a/src/com/watabou/pixeldungeon/sprites/ImpSprite.java b/src/com/watabou/pixeldungeon/sprites/ImpSprite.java index abd6edebb6..89900e2f9d 100644 --- a/src/com/watabou/pixeldungeon/sprites/ImpSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ImpSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ItemSprite.java b/src/com/watabou/pixeldungeon/sprites/ItemSprite.java index 1299b25d81..f339b6ba29 100644 --- a/src/com/watabou/pixeldungeon/sprites/ItemSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ItemSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,7 +18,6 @@ package com.watabou.pixeldungeon.sprites; import android.graphics.Bitmap; -import android.util.Log; import com.watabou.gltextures.TextureCache; import com.watabou.noosa.Game; @@ -34,6 +33,7 @@ import com.watabou.pixeldungeon.items.Heap; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.levels.Level; +import com.watabou.pixeldungeon.levels.Terrain; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.utils.PointF; import com.watabou.utils.Random; @@ -140,9 +140,6 @@ public void drop( int from ) { place( from ); speed.offset( (px-x) / DROP_INTERVAL, (py-y) / DROP_INTERVAL ); - - Log.d( "GAME", toString() ); - Log.d( "GAME", String.format( "drop aside: %.1f %.1f", speed.x, speed.y ) ); } } @@ -158,22 +155,30 @@ public ItemSprite view( int image, Glowing glowing ) { public void update() { super.update(); - // Visibility - visible = heap == null || Dungeon.visible[heap.pos]; + visible = (heap == null || Dungeon.visible[heap.pos]); - // Dropping if (dropInterval > 0 && (dropInterval -= Game.elapsed) <= 0) { speed.set( 0 ); acc.set( 0 ); place( heap.pos ); - if (Level.water[heap.pos]) { - GameScene.ripple( heap.pos ); + if (visible) { + boolean water = Level.water[heap.pos]; + + if (water) { + GameScene.ripple( heap.pos ); + } else { + int cell = Dungeon.level.map[heap.pos]; + water = (cell == Terrain.WELL || cell == Terrain.ALCHEMY); + } + + if (!(heap.peek() instanceof Gold)) { + Sample.INSTANCE.play( water ? Assets.SND_WATER : Assets.SND_STEP, 0.8f, 0.8f, 1.2f ); + } } } - // Glowing if (visible && glowing != null) { if (glowUp && (phase += Game.elapsed) > glowing.period) { diff --git a/src/com/watabou/pixeldungeon/sprites/ItemSpriteSheet.java b/src/com/watabou/pixeldungeon/sprites/ItemSpriteSheet.java index 713966a7c2..1ca4fe163d 100644 --- a/src/com/watabou/pixeldungeon/sprites/ItemSpriteSheet.java +++ b/src/com/watabou/pixeldungeon/sprites/ItemSpriteSheet.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -43,7 +43,7 @@ public class ItemSpriteSheet { public static final int SPEAR = 29; public static final int GLAIVE = 30; - // Missile weapons + // Missiles public static final int SHURIKEN = 15; public static final int DART = 31; public static final int BOOMERANG = 106; @@ -138,7 +138,7 @@ public class ItemSpriteSheet { public static final int DUST = 121; public static final int TOKEN = 122; - // Heaps (containers) + // Heaps public static final int BONES = 0; public static final int CHEST = 11; public static final int LOCKED_CHEST = 12; @@ -157,6 +157,11 @@ public class ItemSpriteSheet { public static final int POUCH = 83; public static final int HOLDER = 104; public static final int HOLSTER = 111; + public static final int KEYRING = 126; + + // UNUSED + public static final int SPARK_UPGRADE = 117; + public static final int SPARK_ENCHANT = 118; // Misc public static final int ANKH = 1; @@ -170,4 +175,6 @@ public class ItemSpriteSheet { public static final int AMULET = 87; public static final int VIAL = 120; public static final int WEIGHT = 123; + public static final int BOMB = 124; + public static final int HONEYPOT= 125; } diff --git a/src/com/watabou/pixeldungeon/sprites/KingSprite.java b/src/com/watabou/pixeldungeon/sprites/KingSprite.java index 30b45aea9f..03d0ea55e3 100644 --- a/src/com/watabou/pixeldungeon/sprites/KingSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/KingSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/LarvaSprite.java b/src/com/watabou/pixeldungeon/sprites/LarvaSprite.java index bb11bd44d2..740b062fea 100644 --- a/src/com/watabou/pixeldungeon/sprites/LarvaSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/LarvaSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/MimicSprite.java b/src/com/watabou/pixeldungeon/sprites/MimicSprite.java new file mode 100644 index 0000000000..32ae6f6326 --- /dev/null +++ b/src/com/watabou/pixeldungeon/sprites/MimicSprite.java @@ -0,0 +1,51 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.sprites; + +import com.watabou.noosa.TextureFilm; +import com.watabou.pixeldungeon.Assets; + +public class MimicSprite extends MobSprite { + + public MimicSprite() { + super(); + + texture( Assets.MIMIC ); + + TextureFilm frames = new TextureFilm( texture, 16, 16 ); + + idle = new Animation( 5, true ); + idle.frames( frames, 0, 0, 0, 1, 1 ); + + run = new Animation( 10, true ); + run.frames( frames, 0, 1, 2, 3, 3, 2, 1 ); + + attack = new Animation( 10, false ); + attack.frames( frames, 0, 4, 5, 6 ); + + die = new Animation( 5, false ); + die.frames( frames, 7, 8, 9 ); + + play( idle ); + } + + @Override + public int blood() { + return 0xFFcb9700; + } +} diff --git a/src/com/watabou/pixeldungeon/sprites/MirrorSprite.java b/src/com/watabou/pixeldungeon/sprites/MirrorSprite.java index 0f9335a61d..e07dbfd513 100644 --- a/src/com/watabou/pixeldungeon/sprites/MirrorSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/MirrorSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/MissileSprite.java b/src/com/watabou/pixeldungeon/sprites/MissileSprite.java index cbd2710c67..2bee5900e7 100644 --- a/src/com/watabou/pixeldungeon/sprites/MissileSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/MissileSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/MobSprite.java b/src/com/watabou/pixeldungeon/sprites/MobSprite.java index 9445724659..cd866c73ec 100644 --- a/src/com/watabou/pixeldungeon/sprites/MobSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/MobSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/MonkSprite.java b/src/com/watabou/pixeldungeon/sprites/MonkSprite.java index 6dedb1dc71..185142d53e 100644 --- a/src/com/watabou/pixeldungeon/sprites/MonkSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/MonkSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/PiranhaSprite.java b/src/com/watabou/pixeldungeon/sprites/PiranhaSprite.java index 77d128577d..aec9f44cc7 100644 --- a/src/com/watabou/pixeldungeon/sprites/PiranhaSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/PiranhaSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/PlantSprite.java b/src/com/watabou/pixeldungeon/sprites/PlantSprite.java index 25517de0b2..4b7440984a 100644 --- a/src/com/watabou/pixeldungeon/sprites/PlantSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/PlantSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -23,8 +23,8 @@ import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.DungeonTilemap; +import com.watabou.pixeldungeon.levels.Level; import com.watabou.pixeldungeon.plants.Plant; -import com.watabou.utils.PointF; public class PlantSprite extends Image { @@ -44,11 +44,9 @@ public PlantSprite() { super( Assets.PLANTS ); if (frames == null) { - // Hardcoded size frames = new TextureFilm( texture, 16, 16 ); } - // Hardcoded origin origin.set( 8, 12 ); } @@ -65,9 +63,8 @@ public void reset( Plant plant ) { alpha( 1f ); pos = plant.pos; - PointF p = DungeonTilemap.tileToWorld( plant.pos ); - x = p.x; - y = p.y; + x = (pos % Level.WIDTH) * DungeonTilemap.SIZE; + y = (pos / Level.WIDTH) * DungeonTilemap.SIZE; state = State.GROWING; time = DELAY; diff --git a/src/com/watabou/pixeldungeon/sprites/RatKingSprite.java b/src/com/watabou/pixeldungeon/sprites/RatKingSprite.java index c0350bff4c..d3382dd1d2 100644 --- a/src/com/watabou/pixeldungeon/sprites/RatKingSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/RatKingSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/RatSprite.java b/src/com/watabou/pixeldungeon/sprites/RatSprite.java index 5cf5494fe5..b3389f4ac1 100644 --- a/src/com/watabou/pixeldungeon/sprites/RatSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/RatSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/RottingFistSprite.java b/src/com/watabou/pixeldungeon/sprites/RottingFistSprite.java index 76872c53bd..2fd3fe1ba2 100644 --- a/src/com/watabou/pixeldungeon/sprites/RottingFistSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/RottingFistSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ScorpioSprite.java b/src/com/watabou/pixeldungeon/sprites/ScorpioSprite.java index c730ca2f46..8e0cb8e751 100644 --- a/src/com/watabou/pixeldungeon/sprites/ScorpioSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ScorpioSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SeniorSprite.java b/src/com/watabou/pixeldungeon/sprites/SeniorSprite.java index c32d2d4e65..8386853f2f 100644 --- a/src/com/watabou/pixeldungeon/sprites/SeniorSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SeniorSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ShamanSprite.java b/src/com/watabou/pixeldungeon/sprites/ShamanSprite.java index 8aefaf3a92..21a4416c3f 100644 --- a/src/com/watabou/pixeldungeon/sprites/ShamanSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ShamanSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SheepSprite.java b/src/com/watabou/pixeldungeon/sprites/SheepSprite.java index bd733e9d19..3de2841a4b 100644 --- a/src/com/watabou/pixeldungeon/sprites/SheepSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SheepSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ShieldedSprite.java b/src/com/watabou/pixeldungeon/sprites/ShieldedSprite.java index 705232b43f..51d89d0cac 100644 --- a/src/com/watabou/pixeldungeon/sprites/ShieldedSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ShieldedSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ShopkeeperSprite.java b/src/com/watabou/pixeldungeon/sprites/ShopkeeperSprite.java index a7094e0695..50c844a29a 100644 --- a/src/com/watabou/pixeldungeon/sprites/ShopkeeperSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ShopkeeperSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SkeletonSprite.java b/src/com/watabou/pixeldungeon/sprites/SkeletonSprite.java index 4340d0dc6a..5cd591c529 100644 --- a/src/com/watabou/pixeldungeon/sprites/SkeletonSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SkeletonSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SpinnerSprite.java b/src/com/watabou/pixeldungeon/sprites/SpinnerSprite.java index 87f73c50d1..615ff682e8 100644 --- a/src/com/watabou/pixeldungeon/sprites/SpinnerSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SpinnerSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/StatueSprite.java b/src/com/watabou/pixeldungeon/sprites/StatueSprite.java index 39be3052a1..a38ba78360 100644 --- a/src/com/watabou/pixeldungeon/sprites/StatueSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/StatueSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SuccubusSprite.java b/src/com/watabou/pixeldungeon/sprites/SuccubusSprite.java index 95fd8cdbf1..3a4098d05e 100644 --- a/src/com/watabou/pixeldungeon/sprites/SuccubusSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SuccubusSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/SwarmSprite.java b/src/com/watabou/pixeldungeon/sprites/SwarmSprite.java index d9a97ef5fb..cebc51ad3e 100644 --- a/src/com/watabou/pixeldungeon/sprites/SwarmSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/SwarmSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/TenguSprite.java b/src/com/watabou/pixeldungeon/sprites/TenguSprite.java index be7580cc88..9ff9f71bc2 100644 --- a/src/com/watabou/pixeldungeon/sprites/TenguSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/TenguSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/ThiefSprite.java b/src/com/watabou/pixeldungeon/sprites/ThiefSprite.java index b1cb86fabb..635cc23b39 100644 --- a/src/com/watabou/pixeldungeon/sprites/ThiefSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/ThiefSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/UndeadSprite.java b/src/com/watabou/pixeldungeon/sprites/UndeadSprite.java index 52c5d5d599..dfd09b12bc 100644 --- a/src/com/watabou/pixeldungeon/sprites/UndeadSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/UndeadSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/WandmakerSprite.java b/src/com/watabou/pixeldungeon/sprites/WandmakerSprite.java index f4f29902b6..ed837a2a4d 100644 --- a/src/com/watabou/pixeldungeon/sprites/WandmakerSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/WandmakerSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/WarlockSprite.java b/src/com/watabou/pixeldungeon/sprites/WarlockSprite.java index 21c51ab3a9..4863b74907 100644 --- a/src/com/watabou/pixeldungeon/sprites/WarlockSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/WarlockSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/WraithSprite.java b/src/com/watabou/pixeldungeon/sprites/WraithSprite.java index 1364948557..b1b152a4a8 100644 --- a/src/com/watabou/pixeldungeon/sprites/WraithSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/WraithSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/sprites/YogSprite.java b/src/com/watabou/pixeldungeon/sprites/YogSprite.java index 848f3240a2..2b289cd138 100644 --- a/src/com/watabou/pixeldungeon/sprites/YogSprite.java +++ b/src/com/watabou/pixeldungeon/sprites/YogSprite.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/Archs.java b/src/com/watabou/pixeldungeon/ui/Archs.java index 5d0e0bf864..1749980ba1 100644 --- a/src/com/watabou/pixeldungeon/ui/Archs.java +++ b/src/com/watabou/pixeldungeon/ui/Archs.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/AttackIndicator.java b/src/com/watabou/pixeldungeon/ui/AttackIndicator.java index 7e64ede5f8..5088f1479b 100644 --- a/src/com/watabou/pixeldungeon/ui/AttackIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/AttackIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/BadgesList.java b/src/com/watabou/pixeldungeon/ui/BadgesList.java index 044f6d04f1..40031982d8 100644 --- a/src/com/watabou/pixeldungeon/ui/BadgesList.java +++ b/src/com/watabou/pixeldungeon/ui/BadgesList.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/Banner.java b/src/com/watabou/pixeldungeon/ui/Banner.java index 2dcb59dbc1..737f208dd2 100644 --- a/src/com/watabou/pixeldungeon/ui/Banner.java +++ b/src/com/watabou/pixeldungeon/ui/Banner.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/BuffIndicator.java b/src/com/watabou/pixeldungeon/ui/BuffIndicator.java index 28bca07176..c3b186822a 100644 --- a/src/com/watabou/pixeldungeon/ui/BuffIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/BuffIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/BusyIndicator.java b/src/com/watabou/pixeldungeon/ui/BusyIndicator.java index 3486aa0f9e..86329a4a29 100644 --- a/src/com/watabou/pixeldungeon/ui/BusyIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/BusyIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/CheckBox.java b/src/com/watabou/pixeldungeon/ui/CheckBox.java index e736891f2e..1ed9b41b88 100644 --- a/src/com/watabou/pixeldungeon/ui/CheckBox.java +++ b/src/com/watabou/pixeldungeon/ui/CheckBox.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -38,8 +38,10 @@ protected void layout() { text.x = PixelScene.align( PixelScene.uiCamera, x + margin ); text.y = PixelScene.align( PixelScene.uiCamera, y + margin ); + margin = (height - icon.height) / 2; + icon.x = PixelScene.align( PixelScene.uiCamera, x + width - margin - icon.width ); - icon.y = PixelScene.align( PixelScene.uiCamera, y + (height - icon.height()) / 2 ); + icon.y = PixelScene.align( PixelScene.uiCamera, y + margin ); } public boolean checked() { diff --git a/src/com/watabou/pixeldungeon/ui/Compass.java b/src/com/watabou/pixeldungeon/ui/Compass.java index 8bba032b5a..74f47c4c5a 100644 --- a/src/com/watabou/pixeldungeon/ui/Compass.java +++ b/src/com/watabou/pixeldungeon/ui/Compass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/DangerIndicator.java b/src/com/watabou/pixeldungeon/ui/DangerIndicator.java index baf0a83070..957b842cac 100644 --- a/src/com/watabou/pixeldungeon/ui/DangerIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/DangerIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -80,7 +80,7 @@ public void update() { number.text( Integer.toString( lastNumber ) ); number.measure(); placeNumber(); - + flash(); } } diff --git a/src/com/watabou/pixeldungeon/ui/ExitButton.java b/src/com/watabou/pixeldungeon/ui/ExitButton.java index 38abf45cb4..5b8304e196 100644 --- a/src/com/watabou/pixeldungeon/ui/ExitButton.java +++ b/src/com/watabou/pixeldungeon/ui/ExitButton.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/GameLog.java b/src/com/watabou/pixeldungeon/ui/GameLog.java index 987016f8f8..9b2230bbdc 100644 --- a/src/com/watabou/pixeldungeon/ui/GameLog.java +++ b/src/com/watabou/pixeldungeon/ui/GameLog.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/GoldIndicator.java b/src/com/watabou/pixeldungeon/ui/GoldIndicator.java index 8586eb48b0..5e53252ee8 100644 --- a/src/com/watabou/pixeldungeon/ui/GoldIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/GoldIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/HealthBar.java b/src/com/watabou/pixeldungeon/ui/HealthBar.java new file mode 100644 index 0000000000..99b48fdedf --- /dev/null +++ b/src/com/watabou/pixeldungeon/ui/HealthBar.java @@ -0,0 +1,62 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.ui; + +import com.watabou.noosa.ColorBlock; +import com.watabou.noosa.ui.Component; + +public class HealthBar extends Component { + + private static final int COLOR_BG = 0xFFCC0000; + private static final int COLOR_LVL = 0xFF00EE00; + + private static final int HEIGHT = 2; + + private ColorBlock hpBg; + private ColorBlock hpLvl; + + private float level; + + @Override + protected void createChildren() { + hpBg = new ColorBlock( 1, 1, COLOR_BG ); + add( hpBg ); + + hpLvl = new ColorBlock( 1, 1, COLOR_LVL ); + add( hpLvl ); + + height = HEIGHT; + } + + @Override + protected void layout() { + + hpBg.x = hpLvl.x = x; + hpBg.y = hpLvl.y = y; + + hpBg.size( width, HEIGHT ); + hpLvl.size( width * level, HEIGHT ); + + height = HEIGHT; + } + + public void level( float value ) { + level = value; + layout(); + } +} diff --git a/src/com/watabou/pixeldungeon/ui/HealthIndicator.java b/src/com/watabou/pixeldungeon/ui/HealthIndicator.java index 6415569dce..61c94d2d4f 100644 --- a/src/com/watabou/pixeldungeon/ui/HealthIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/HealthIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/Icons.java b/src/com/watabou/pixeldungeon/ui/Icons.java index 40432fa518..c31ad43370 100644 --- a/src/com/watabou/pixeldungeon/ui/Icons.java +++ b/src/com/watabou/pixeldungeon/ui/Icons.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -25,7 +25,7 @@ public enum Icons { SKULL, BUSY, - COMPASS, + COMPASS, PREFS, WARNING, TARGET, @@ -44,11 +44,13 @@ public enum Icons { SEED_POUCH, SCROLL_HOLDER, WAND_HOLSTER, + KEYRING, CHECKED, UNCHECKED, EXIT, CHALLENGE_OFF, - CHALLENGE_ON; + CHALLENGE_ON, + RESUME; public Image get() { return get( this ); @@ -120,6 +122,9 @@ public static Image get( Icons type ) { case WAND_HOLSTER: icon.frame( icon.texture.uvRect( 88, 0, 98, 10 ) ); break; + case KEYRING: + icon.frame( icon.texture.uvRect( 64, 29, 74, 39 ) ); + break; case CHECKED: icon.frame( icon.texture.uvRect( 54, 12, 66, 24 ) ); break; @@ -135,6 +140,9 @@ public static Image get( Icons type ) { case CHALLENGE_ON: icon.frame( icon.texture.uvRect( 102, 16, 126, 40 ) ); break; + case RESUME: + icon.frame( icon.texture.uvRect( 114, 0, 126, 11 ) ); + break; } return icon; } diff --git a/src/com/watabou/pixeldungeon/ui/ItemSlot.java b/src/com/watabou/pixeldungeon/ui/ItemSlot.java index 082e03be92..59f99d86c1 100644 --- a/src/com/watabou/pixeldungeon/ui/ItemSlot.java +++ b/src/com/watabou/pixeldungeon/ui/ItemSlot.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -47,8 +47,9 @@ public class ItemSlot extends Button { private static final String TXT_TYPICAL_STR = "%d?"; private static final String TXT_LEVEL = "%+d"; + private static final String TXT_CURSED = "";//"-"; - // Special items for containers + // Special "virtual items" public static final Item CHEST = new Item() { public int image() { return ItemSpriteSheet.CHEST; }; }; @@ -158,9 +159,8 @@ public void item( Item item ) { } int level = item.visiblyUpgraded(); - if (level != 0 || (item.cursed && item.cursedKnown)) { - bottomRight.text( item.levelKnown ? Utils.format( TXT_LEVEL, level ) : "" ); + bottomRight.text( item.levelKnown ? Utils.format( TXT_LEVEL, level ) : TXT_CURSED ); bottomRight.measure(); bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED ); } else { diff --git a/src/com/watabou/pixeldungeon/ui/LootIndicator.java b/src/com/watabou/pixeldungeon/ui/LootIndicator.java index dfaeee349d..383484d317 100644 --- a/src/com/watabou/pixeldungeon/ui/LootIndicator.java +++ b/src/com/watabou/pixeldungeon/ui/LootIndicator.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -64,7 +64,7 @@ public void update() { if (heap != null) { Item item = - heap.type == Heap.Type.CHEST ? ItemSlot.CHEST : + heap.type == Heap.Type.CHEST || heap.type == Heap.Type.MIMIC ? ItemSlot.CHEST : heap.type == Heap.Type.LOCKED_CHEST ? ItemSlot.LOCKED_CHEST : heap.type == Heap.Type.TOMB ? ItemSlot.TOMB : heap.type == Heap.Type.SKELETON ? ItemSlot.SKELETON : diff --git a/src/com/watabou/pixeldungeon/ui/PrefsButton.java b/src/com/watabou/pixeldungeon/ui/PrefsButton.java index f13fbe2697..2e725dad5f 100644 --- a/src/com/watabou/pixeldungeon/ui/PrefsButton.java +++ b/src/com/watabou/pixeldungeon/ui/PrefsButton.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/QuickSlot.java b/src/com/watabou/pixeldungeon/ui/QuickSlot.java index d7a053f194..e0a7504129 100644 --- a/src/com/watabou/pixeldungeon/ui/QuickSlot.java +++ b/src/com/watabou/pixeldungeon/ui/QuickSlot.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -23,16 +23,19 @@ import com.watabou.pixeldungeon.DungeonTilemap; import com.watabou.pixeldungeon.actors.Actor; import com.watabou.pixeldungeon.actors.Char; +import com.watabou.pixeldungeon.actors.hero.Belongings; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.scenes.GameScene; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.windows.WndBag; +import com.watabou.utils.Bundle; public class QuickSlot extends Button implements WndBag.Listener { private static final String TXT_SELECT_ITEM = "Select an item for the quickslot"; - private static QuickSlot instance; + private static QuickSlot primary; + private static QuickSlot secondary; private Item itemInSlot; private ItemSlot slot; @@ -43,19 +46,29 @@ public class QuickSlot extends Button implements WndBag.Listener { private boolean targeting = false; private Item lastItem = null; private Char lastTarget= null; + + public static Object primaryValue; + public static Object secondaryValue; - public QuickSlot() { - super(); + public void primary() { + primary = this; + item( select() ); + } + + public void secondary() { + secondary = this; item( select() ); - - instance = this; } @Override public void destroy() { super.destroy(); - instance = null; + if (this == primary) { + primary = null; + } else { + secondary = null; + } lastItem = null; lastTarget = null; @@ -125,15 +138,17 @@ protected boolean onLongClick() { } @SuppressWarnings("unchecked") - private static Item select() { - if (Dungeon.quickslot instanceof Item) { + private Item select() { + + Object content = (this == primary ? primaryValue : secondaryValue); + if (content instanceof Item) { - return (Item)Dungeon.quickslot; + return (Item)content; - } else if (Dungeon.quickslot != null) { + } else if (content != null) { - Item item = Dungeon.hero.belongings.getItem( (Class)Dungeon.quickslot ); - return item != null ? item : Item.virtual( (Class)Dungeon.quickslot ); + Item item = Dungeon.hero.belongings.getItem( (Class)content ); + return item != null ? item : Item.virtual( (Class)content ); } else { @@ -145,7 +160,11 @@ private static Item select() { @Override public void onSelect( Item item ) { if (item != null) { - Dungeon.quickslot = item.stackable ? item.getClass() : item; + if (this == primary) { + primaryValue = (item.stackable ? item.getClass() : item); + } else { + secondaryValue = (item.stackable ? item.getClass() : item); + } refresh(); } } @@ -188,24 +207,108 @@ private void useTargeting() { } public static void refresh() { - if (instance != null) { - instance.item( select() ); + if (primary != null) { + primary.item( primary.select() ); + } + if (secondary != null) { + secondary.item( secondary.select() ); } } public static void target( Item item, Char target ) { - if (item == instance.lastItem && target != Dungeon.hero) { - instance.lastTarget = target; - - HealthIndicator.instance.target( target ); + if (target != Dungeon.hero) { + if (item == primary.lastItem) { + + primary.lastTarget = target; + HealthIndicator.instance.target( target ); + + } else if (item == secondary.lastItem) { + + secondary.lastTarget = target; + HealthIndicator.instance.target( target ); + + } } } public static void cancel() { - if (instance != null && instance.targeting) { - instance.crossB.visible = false; - instance.crossM.remove(); - instance.targeting = false; + if (primary != null && primary.targeting) { + primary.crossB.visible = false; + primary.crossM.remove(); + primary.targeting = false; + } + if (secondary != null && secondary.targeting) { + secondary.crossB.visible = false; + secondary.crossM.remove(); + secondary.targeting = false; + } + } + + private static final String QUICKSLOT1 = "quickslot"; + private static final String QUICKSLOT2 = "quickslot2"; + + @SuppressWarnings("unchecked") + public static void save( Bundle bundle ) { + Belongings stuff = Dungeon.hero.belongings; + + if (primaryValue instanceof Class && + stuff.getItem( (Class)primaryValue ) != null) { + + bundle.put( QUICKSLOT1, ((Class)primaryValue).getName() ); + } + if (QuickSlot.secondaryValue instanceof Class && + stuff.getItem( (Class)secondaryValue ) != null && + Toolbar.secondQuickslot()) { + + bundle.put( QUICKSLOT2, ((Class)secondaryValue).getName() ); + } + } + + public static void save( Bundle bundle, Item item ) { + if (item == primaryValue) { + bundle.put( QuickSlot.QUICKSLOT1, true ); + } + if (item == secondaryValue && Toolbar.secondQuickslot()) { + bundle.put( QuickSlot.QUICKSLOT2, true ); + } + } + + public static void restore( Bundle bundle ) { + primaryValue = null; + secondaryValue = null; + + String qsClass = bundle.getString( QUICKSLOT1 ); + if (qsClass != null) { + try { + primaryValue = Class.forName( qsClass ); + } catch (ClassNotFoundException e) { + } + } + + qsClass = bundle.getString( QUICKSLOT2 ); + if (qsClass != null) { + try { + secondaryValue = Class.forName( qsClass ); + } catch (ClassNotFoundException e) { + } + } + } + + public static void restore( Bundle bundle, Item item ) { + if (bundle.getBoolean( QUICKSLOT1 )) { + primaryValue = item; + } + if (bundle.getBoolean( QUICKSLOT2 )) { + secondaryValue = item; + } + } + + public static void compress() { + if ((primaryValue == null && secondaryValue != null) || + (primaryValue == secondaryValue)) { + + primaryValue = secondaryValue; + secondaryValue = null; } } } diff --git a/src/com/watabou/pixeldungeon/ui/RedButton.java b/src/com/watabou/pixeldungeon/ui/RedButton.java index 0305aa23c8..fc439f048d 100644 --- a/src/com/watabou/pixeldungeon/ui/RedButton.java +++ b/src/com/watabou/pixeldungeon/ui/RedButton.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -90,6 +90,10 @@ public void text( String value ) { layout(); } + public void textColor( int value ) { + text.hardlight( value ); + } + public void icon( Image icon ) { if (this.icon != null) { remove( this.icon ); diff --git a/src/com/watabou/pixeldungeon/ui/ResumeButton.java b/src/com/watabou/pixeldungeon/ui/ResumeButton.java new file mode 100644 index 0000000000..2182903f9d --- /dev/null +++ b/src/com/watabou/pixeldungeon/ui/ResumeButton.java @@ -0,0 +1,67 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * 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.watabou.pixeldungeon.ui; + +import com.watabou.noosa.Image; +import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.scenes.PixelScene; + +public class ResumeButton extends Tag { + + private Image icon; + + public ResumeButton() { + super( 0xCDD5C0 ); + + setSize( 24, 22 ); + + visible = false; + } + + @Override + protected void createChildren() { + super.createChildren(); + + icon = Icons.get( Icons.RESUME ); + add( icon ); + } + + @Override + protected void layout() { + super.layout(); + + icon.x = PixelScene.align( PixelScene.uiCamera, x+1 + (width - icon.width) / 2 ); + icon.y = PixelScene.align( PixelScene.uiCamera, y + (height - icon.height) / 2 ); + } + + @Override + public void update() { + boolean prevVisible = visible; + visible = (Dungeon.hero.lastAction != null); + if (visible && !prevVisible) { + flash(); + } + + super.update(); + } + + @Override + protected void onClick() { + Dungeon.hero.resume(); + } +} diff --git a/src/com/watabou/pixeldungeon/ui/ScrollPane.java b/src/com/watabou/pixeldungeon/ui/ScrollPane.java index 5600e086b6..ec7198afa1 100644 --- a/src/com/watabou/pixeldungeon/ui/ScrollPane.java +++ b/src/com/watabou/pixeldungeon/ui/ScrollPane.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -110,9 +110,7 @@ protected void onClick( Touch touch ) { } } - // true if dragging is in progress private boolean dragging = false; - // last touch coords private PointF lastPos = new PointF(); @Override diff --git a/src/com/watabou/pixeldungeon/ui/SimpleButton.java b/src/com/watabou/pixeldungeon/ui/SimpleButton.java index 60ed12f8bc..afc6090e35 100644 --- a/src/com/watabou/pixeldungeon/ui/SimpleButton.java +++ b/src/com/watabou/pixeldungeon/ui/SimpleButton.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/StatusPane.java b/src/com/watabou/pixeldungeon/ui/StatusPane.java index 2362f9f3c4..28b7ca36ce 100644 --- a/src/com/watabou/pixeldungeon/ui/StatusPane.java +++ b/src/com/watabou/pixeldungeon/ui/StatusPane.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -58,6 +58,7 @@ public class StatusPane extends Component { private DangerIndicator danger; private LootIndicator loot; + private ResumeButton resume; private BuffIndicator buffs; private Compass compass; @@ -122,6 +123,9 @@ protected void onClick( Touch touch ) { loot = new LootIndicator(); add( loot ); + resume = new ResumeButton(); + add( resume ); + buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); } @@ -147,19 +151,49 @@ protected void layout() { keys.y = 6; - danger.setPos( width - danger.width(), 20 ); - - loot.setPos( width - loot.width(), danger.bottom() + 2 ); + layoutTags(); buffs.setPos( 32, 11 ); btnMenu.setPos( width - btnMenu.width(), 1 ); } + private void layoutTags() { + + float pos = 18; + + if (tagDanger) { + danger.setPos( width - danger.width(), pos ); + pos = danger.bottom() + 1; + } + + if (tagLoot) { + loot.setPos( width - loot.width(), pos ); + pos = loot.bottom() + 1; + } + + if (tagResume) { + resume.setPos( width - resume.width(), pos ); + } + } + + private boolean tagDanger = false; + private boolean tagLoot = false; + private boolean tagResume = false; + @Override public void update() { super.update(); + if (tagDanger != danger.visible || tagLoot != loot.visible || tagResume != resume.visible) { + + tagDanger = danger.visible; + tagLoot = loot.visible; + tagResume = resume.visible; + + layoutTags(); + } + float health = (float)Dungeon.hero.HP / Dungeon.hero.HT; if (health == 0) { diff --git a/src/com/watabou/pixeldungeon/ui/Tag.java b/src/com/watabou/pixeldungeon/ui/Tag.java index e3d11ce8fc..17d08c04b4 100644 --- a/src/com/watabou/pixeldungeon/ui/Tag.java +++ b/src/com/watabou/pixeldungeon/ui/Tag.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/Toast.java b/src/com/watabou/pixeldungeon/ui/Toast.java index 118b732cc8..7a89c1c150 100644 --- a/src/com/watabou/pixeldungeon/ui/Toast.java +++ b/src/com/watabou/pixeldungeon/ui/Toast.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/ui/Toolbar.java b/src/com/watabou/pixeldungeon/ui/Toolbar.java index 0f317cef7b..3443085b14 100644 --- a/src/com/watabou/pixeldungeon/ui/Toolbar.java +++ b/src/com/watabou/pixeldungeon/ui/Toolbar.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -49,17 +49,21 @@ public class Toolbar extends Component { private Tool btnWait; private Tool btnSearch; private Tool btnInfo; - private Tool btnResume; private Tool btnInventory; - private Tool btnQuick; + private Tool btnQuick1; + private Tool btnQuick2; private PickedUpItem pickedUp; private boolean lastEnabled = true; + private static Toolbar instance; + public Toolbar() { super(); + instance = this; + height = btnInventory.height(); } @@ -91,14 +95,7 @@ protected void onClick() { } } ); - add( btnResume = new Tool( 61, 7, 21, 24 ) { - @Override - protected void onClick() { - Dungeon.hero.resume(); - } - } ); - - add( btnInventory = new Tool( 82, 7, 23, 24 ) { + add( btnInventory = new Tool( 60, 7, 23, 24 ) { private GoldIndicator gold; @Override protected void onClick() { @@ -121,7 +118,9 @@ protected void layout() { }; } ); - add( btnQuick = new QuickslotTool( 105, 7, 22, 24 ) ); + add( btnQuick1 = new QuickslotTool( 83, 7, 22, 24, true ) ); + add( btnQuick2 = new QuickslotTool( 83, 7, 22, 24, false ) ); + btnQuick2.visible = (QuickSlot.secondaryValue != null); add( pickedUp = new PickedUpItem() ); } @@ -131,9 +130,13 @@ protected void layout() { btnWait.setPos( x, y ); btnSearch.setPos( btnWait.right(), y ); btnInfo.setPos( btnSearch.right(), y ); - btnResume.setPos( btnInfo.right(), y ); - btnQuick.setPos( width - btnQuick.width(), y ); - btnInventory.setPos( btnQuick.left() - btnInventory.width(), y ); + btnQuick1.setPos( width - btnQuick1.width(), y ); + if (btnQuick2.visible) { + btnQuick2.setPos(btnQuick1.left() - btnQuick2.width(), y ); + btnInventory.setPos( btnQuick2.left() - btnInventory.width(), y ); + } else { + btnInventory.setPos( btnQuick1.left() - btnInventory.width(), y ); + } } @Override @@ -150,8 +153,6 @@ public void update() { } } - btnResume.visible = Dungeon.hero.lastAction != null; - if (!Dungeon.hero.isAlive()) { btnInventory.enable( true ); } @@ -163,6 +164,17 @@ public void pickup( Item item ) { btnInventory.centerY() ); } + public static boolean secondQuickslot() { + return instance.btnQuick2.visible; + } + + public static void secondQuickslot( boolean value ) { + instance.btnQuick2.visible = + instance.btnQuick2.active = + value; + instance.layout(); + } + private static CellSelector.Listener informer = new CellSelector.Listener() { @Override public void onSelect( Integer cell ) { @@ -220,7 +232,7 @@ private static class Tool extends Button { private static final int BGCOLOR = 0x7B8073; - private Image base; + protected Image base; public Tool( int x, int y, int width, int height ) { super(); @@ -277,8 +289,13 @@ private static class QuickslotTool extends Tool { private QuickSlot slot; - public QuickslotTool( int x, int y, int width, int height ) { + public QuickslotTool( int x, int y, int width, int height, boolean primary ) { super( x, y, width, height ); + if (primary) { + slot.primary(); + } else { + slot.secondary(); + } } @Override @@ -298,7 +315,7 @@ protected void layout() { @Override public void enable( boolean value ) { slot.enable( value ); - active = value; + super.enable( value ); } } diff --git a/src/com/watabou/pixeldungeon/ui/Window.java b/src/com/watabou/pixeldungeon/ui/Window.java index 3a1b3c1779..528f461f51 100644 --- a/src/com/watabou/pixeldungeon/ui/Window.java +++ b/src/com/watabou/pixeldungeon/ui/Window.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -29,6 +29,7 @@ import com.watabou.noosa.NinePatch; import com.watabou.noosa.TouchArea; import com.watabou.pixeldungeon.Chrome; +import com.watabou.pixeldungeon.effects.ShadowBox; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.utils.Signal; @@ -38,6 +39,7 @@ public class Window extends Group implements Signal.Listener { protected int height; protected TouchArea blocker; + protected ShadowBox shadow; protected NinePatch chrome; public static final int TITLE_COLOR = 0xFFFF44; @@ -72,6 +74,12 @@ protected void onClick( Touch touch ) { this.width = width; this.height = height; + shadow = new ShadowBox(); + shadow.am = 0.5f; + shadow.camera = PixelScene.uiCamera.visible ? + PixelScene.uiCamera : Camera.main; + add( shadow ); + chrome.x = -chrome.marginLeft(); chrome.y = -chrome.marginTop(); chrome.size( @@ -88,6 +96,11 @@ protected void onClick( Touch touch ) { camera.scroll.set( chrome.x, chrome.y ); Camera.add( camera ); + shadow.boxRect( + camera.x / camera.zoom, + camera.y / camera.zoom, + chrome.width(), chrome.height ); + Keys.event.add( this ); } @@ -102,6 +115,8 @@ public void resize( int w, int h ) { camera.resize( (int)chrome.width, (int)chrome.height ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; + + shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height ); } public void hide() { diff --git a/src/com/watabou/pixeldungeon/utils/BArray.java b/src/com/watabou/pixeldungeon/utils/BArray.java index c109f09fd4..dec22b52f0 100644 --- a/src/com/watabou/pixeldungeon/utils/BArray.java +++ b/src/com/watabou/pixeldungeon/utils/BArray.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/utils/GLog.java b/src/com/watabou/pixeldungeon/utils/GLog.java index 40a0329666..2baa8e2a26 100644 --- a/src/com/watabou/pixeldungeon/utils/GLog.java +++ b/src/com/watabou/pixeldungeon/utils/GLog.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/utils/Utils.java b/src/com/watabou/pixeldungeon/utils/Utils.java index 4cff2ab6ca..2b5be9d9c2 100644 --- a/src/com/watabou/pixeldungeon/utils/Utils.java +++ b/src/com/watabou/pixeldungeon/utils/Utils.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/IconTitle.java b/src/com/watabou/pixeldungeon/windows/IconTitle.java index 1d852aae4a..fdfe0c1b7c 100644 --- a/src/com/watabou/pixeldungeon/windows/IconTitle.java +++ b/src/com/watabou/pixeldungeon/windows/IconTitle.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -23,6 +23,7 @@ import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.sprites.ItemSprite; +import com.watabou.pixeldungeon.ui.HealthBar; import com.watabou.pixeldungeon.ui.Window; import com.watabou.pixeldungeon.utils.Utils; @@ -34,6 +35,9 @@ public class IconTitle extends Component { protected Image imIcon; protected BitmapTextMultiline tfLabel; + protected HealthBar health; + + private float healthLvl = Float.NaN; public IconTitle() { super(); @@ -60,22 +64,33 @@ protected void createChildren() { tfLabel = PixelScene.createMultiline( FONT_SIZE ); tfLabel.hardlight( Window.TITLE_COLOR ); add( tfLabel ); + + health = new HealthBar(); + add( health ); } @Override protected void layout() { - imIcon.x = 0; - imIcon.y = 0; + + health.visible = !Float.isNaN( healthLvl ); + + imIcon.x = x; + imIcon.y = y; tfLabel.x = PixelScene.align( PixelScene.uiCamera, imIcon.x + imIcon.width() + GAP ); tfLabel.maxWidth = (int)(width - tfLabel.x); tfLabel.measure(); tfLabel.y = PixelScene.align( PixelScene.uiCamera, imIcon.height > tfLabel.height() ? - (imIcon.height() - tfLabel.baseLine()) / 2 : + imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 : imIcon.y ); - - height = Math.max( imIcon.y + imIcon.height(), tfLabel.y + tfLabel.height() ); + + if (health.visible) { + health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 ); + height = health.bottom(); + } else { + height = Math.max( imIcon.y + imIcon.height(), tfLabel.y + tfLabel.height() ); + } } public void icon( Image icon ) { @@ -95,4 +110,9 @@ public void label( String label, int color ) { public void color( int color ) { tfLabel.hardlight( color ); } + + public void health( float value ) { + health.level( healthLvl = value ); + layout(); + } } diff --git a/src/com/watabou/pixeldungeon/windows/WndBadge.java b/src/com/watabou/pixeldungeon/windows/WndBadge.java index b0cd1e0893..c7fb4d23ec 100644 --- a/src/com/watabou/pixeldungeon/windows/WndBadge.java +++ b/src/com/watabou/pixeldungeon/windows/WndBadge.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndBag.java b/src/com/watabou/pixeldungeon/windows/WndBag.java index e74d346b28..2e58bd4eda 100644 --- a/src/com/watabou/pixeldungeon/windows/WndBag.java +++ b/src/com/watabou/pixeldungeon/windows/WndBag.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -26,12 +26,14 @@ import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Dungeon; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.actors.hero.Belongings; import com.watabou.pixeldungeon.actors.hero.Hero; import com.watabou.pixeldungeon.items.Gold; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.items.armor.Armor; import com.watabou.pixeldungeon.items.bags.Bag; +import com.watabou.pixeldungeon.items.bags.Keyring; import com.watabou.pixeldungeon.items.bags.ScrollHolder; import com.watabou.pixeldungeon.items.bags.SeedPouch; import com.watabou.pixeldungeon.items.bags.WandHolster; @@ -46,6 +48,7 @@ import com.watabou.pixeldungeon.ui.ItemSlot; import com.watabou.pixeldungeon.ui.QuickSlot; import com.watabou.pixeldungeon.utils.Utils; +import com.watabou.utils.GameMath; public class WndBag extends WndTabbed { @@ -57,27 +60,28 @@ public static enum Mode { FOR_SALE, WEAPON, ARMOR, + ENCHANTABLE, WAND, SEED } - protected static final int COLS = 4; + protected static final int COLS_P = 4; + protected static final int COLS_L = 6; protected static final int SLOT_SIZE = 28; protected static final int SLOT_MARGIN = 1; - protected static final int TAB_WIDTH = 30; + protected static final int TAB_WIDTH = 25; protected static final int TITLE_HEIGHT = 12; - @SuppressWarnings("unused") - protected static final int ROWS = - (Belongings.BACKPACK_SIZE + 4 + 1) / COLS + ((Belongings.BACKPACK_SIZE + 4 + 1) % COLS > 0 ? 1 : 0); - private Listener listener; private WndBag.Mode mode; private String title; + private int nCols; + private int nRows; + protected int count; protected int col; protected int row; @@ -96,25 +100,30 @@ public WndBag( Bag bag, Listener listener, Mode mode, String title ) { lastMode = mode; lastBag = bag; + nCols = PixelDungeon.landscape() ? COLS_L : COLS_P; + nRows = (Belongings.BACKPACK_SIZE + 4 + 1) / nCols + ((Belongings.BACKPACK_SIZE + 4 + 1) % nCols > 0 ? 1 : 0); + + int slotsWidth = SLOT_SIZE * nCols + SLOT_MARGIN * (nCols - 1); + int slotsHeight = SLOT_SIZE * nRows + SLOT_MARGIN * (nRows - 1); + BitmapText txtTitle = PixelScene.createText( title != null ? title : Utils.capitalize( bag.name() ), 9 ); txtTitle.hardlight( TITLE_COLOR ); txtTitle.measure(); - txtTitle.x = (int)(SLOT_SIZE * COLS + SLOT_MARGIN * (COLS - 1) - txtTitle.width()) / 2; + txtTitle.x = (int)(slotsWidth - txtTitle.width()) / 2; txtTitle.y = (int)(TITLE_HEIGHT - txtTitle.height()) / 2; add( txtTitle ); placeItems( bag ); - resize( - SLOT_SIZE * COLS + SLOT_MARGIN * (COLS - 1), - SLOT_SIZE * ROWS + SLOT_MARGIN * (ROWS - 1) + TITLE_HEIGHT ); + resize( slotsWidth, slotsHeight + TITLE_HEIGHT ); Belongings stuff = Dungeon.hero.belongings; Bag[] bags = { stuff.backpack, stuff.getItem( SeedPouch.class ), stuff.getItem( ScrollHolder.class ), - stuff.getItem( WandHolster.class )}; + stuff.getItem( WandHolster.class ), + stuff.getItem( Keyring.class )}; for (Bag b : bags) { if (b != null) { @@ -157,20 +166,27 @@ protected void placeItems( Bag container ) { placeItem( stuff.ring1 != null ? stuff.ring1 : new Placeholder( ItemSpriteSheet.RING ) ); placeItem( stuff.ring2 != null ? stuff.ring2 : new Placeholder( ItemSpriteSheet.RING ) ); - // Unequipped items + boolean backpack = (container == Dungeon.hero.belongings.backpack); + if (!backpack) { + count = nCols; + col = 0; + row = 1; + } + + // Items in the bag for (Item item : container.items) { placeItem( item ); } - // Empty slots - while (count-4 < container.size) { + // Free space + while (count-(backpack ? 4 : nCols) < container.size) { placeItem( null ); } - // Gold + // Gold in the backpack if (container == Dungeon.hero.belongings.backpack) { - row = ROWS - 1; - col = COLS - 1; + row = nRows - 1; + col = nCols - 1; placeItem( new Gold( Dungeon.gold ) ); } } @@ -182,7 +198,7 @@ protected void placeItem( final Item item ) { add( new ItemButton( item ).setPos( x, y ) ); - if (++col >= COLS) { + if (++col >= nCols) { col = 0; row++; } @@ -259,6 +275,8 @@ private Image icon() { return Icons.get( Icons.SCROLL_HOLDER ); } else if (bag instanceof WandHolster) { return Icons.get( Icons.WAND_HOLSTER ); + } else if (bag instanceof Keyring) { + return Icons.get( Icons.KEYRING ); } else { return Icons.get( Icons.BACKPACK ); } @@ -290,9 +308,13 @@ private class ItemButton extends ItemSlot { private static final int NORMAL = 0xFF4A4D44; private static final int EQUIPPED = 0xFF63665B; + private static final int NBARS = 3; + private Item item; private ColorBlock bg; + private ColorBlock durability[]; + public ItemButton( Item item ) { super( item ); @@ -318,6 +340,13 @@ protected void layout() { bg.x = x; bg.y = y; + if (durability != null) { + for (int i=0; i < NBARS; i++) { + durability[i].x = x + 1 + i * 3; + durability[i].y = y + height - 3; + } + } + super.layout(); } @@ -336,16 +365,30 @@ public void item( Item item ) { bg.ba = 0.1f; } + if (lastBag.owner.isAlive() && item.isUpgradable() && item.levelKnown) { + durability = new ColorBlock[NBARS]; + int nBars = (int)GameMath.gate( 0, Math.round( (float)NBARS * item.durability() / item.maxDurability() ), NBARS ); + for (int i=0; i < nBars; i++) { + durability[i] = new ColorBlock( 2, 2, 0xFF00EE00 ); + add( durability[i] ); + } + for (int i=nBars; i < NBARS; i++) { + durability[i] = new ColorBlock( 2, 2, 0xFFCC0000 ); + add( durability[i] ); + } + } + if (item.name() == null) { enable( false ); } else { enable( + mode == Mode.QUICKSLOT && (item.defaultAction != null) || mode == Mode.FOR_SALE && (item.price() > 0) && (!item.isEquipped( Dungeon.hero ) || !item.cursed) || mode == Mode.UPGRADEABLE && item.isUpgradable() || mode == Mode.UNIDENTIFED && !item.isIdentified() || - mode == Mode.QUICKSLOT && (item.defaultAction != null) || mode == Mode.WEAPON && (item instanceof MeleeWeapon || item instanceof Boomerang) || mode == Mode.ARMOR && (item instanceof Armor) || + mode == Mode.ENCHANTABLE && (item instanceof MeleeWeapon || item instanceof Boomerang || item instanceof Armor) || mode == Mode.WAND && (item instanceof Wand) || mode == Mode.SEED && (item instanceof Seed) || mode == Mode.ALL @@ -384,7 +427,7 @@ protected void onClick() { protected boolean onLongClick() { if (listener == null && item.defaultAction != null) { hide(); - Dungeon.quickslot = item instanceof Wand ? item : item.getClass(); + QuickSlot.primaryValue = item.stackable ? item.getClass() : item; QuickSlot.refresh(); return true; } else { diff --git a/src/com/watabou/pixeldungeon/windows/WndBlacksmith.java b/src/com/watabou/pixeldungeon/windows/WndBlacksmith.java index 49069ce407..3e01d8392d 100644 --- a/src/com/watabou/pixeldungeon/windows/WndBlacksmith.java +++ b/src/com/watabou/pixeldungeon/windows/WndBlacksmith.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndCatalogus.java b/src/com/watabou/pixeldungeon/windows/WndCatalogus.java index 04209e9fb9..f948aff8b9 100644 --- a/src/com/watabou/pixeldungeon/windows/WndCatalogus.java +++ b/src/com/watabou/pixeldungeon/windows/WndCatalogus.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -21,6 +21,7 @@ import com.watabou.noosa.BitmapText; import com.watabou.noosa.ui.Component; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.items.Item; import com.watabou.pixeldungeon.items.potions.Potion; import com.watabou.pixeldungeon.items.scrolls.Scroll; @@ -33,8 +34,11 @@ public class WndCatalogus extends WndTabbed { - private static final int WIDTH = 112; - private static final int HEIGHT = 160; + private static final int WIDTH_P = 112; + private static final int HEIGHT_P = 160; + + private static final int WIDTH_L = 128; + private static final int HEIGHT_L = 128; private static final int ITEM_HEIGHT = 18; @@ -54,7 +58,12 @@ public class WndCatalogus extends WndTabbed { public WndCatalogus() { super(); - resize( WIDTH, HEIGHT ); + + if (PixelDungeon.landscape()) { + resize( WIDTH_L, HEIGHT_L ); + } else { + resize( WIDTH_P, HEIGHT_P ); + } txtTitle = PixelScene.createText( TXT_TITLE, 9 ); txtTitle.hardlight( Window.TITLE_COLOR ); @@ -73,7 +82,7 @@ public void onClick( float x, float y ) { } }; add( list ); - list.setRect( 0, txtTitle.height(), WIDTH, HEIGHT - txtTitle.height() ); + list.setRect( 0, txtTitle.height(), width, height - txtTitle.height() ); boolean showPotions = WndCatalogus.showPotions; Tab[] tabs = { @@ -104,7 +113,7 @@ private void updateList() { txtTitle.text( Utils.format( TXT_TITLE, showPotions ? TXT_POTIONS : TXT_SCROLLS ) ); txtTitle.measure(); - txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 ); + txtTitle.x = PixelScene.align( PixelScene.uiCamera, (width - txtTitle.width()) / 2 ); items.clear(); @@ -115,7 +124,7 @@ private void updateList() { float pos = 0; for (Class itemClass : showPotions ? Potion.getKnown() : Scroll.getKnown()) { ListItem item = new ListItem( itemClass ); - item.setRect( 0, pos, WIDTH, ITEM_HEIGHT ); + item.setRect( 0, pos, width, ITEM_HEIGHT ); content.add( item ); items.add( item ); @@ -124,14 +133,14 @@ private void updateList() { for (Class itemClass : showPotions ? Potion.getUnknown() : Scroll.getUnknown()) { ListItem item = new ListItem( itemClass ); - item.setRect( 0, pos, WIDTH, ITEM_HEIGHT ); + item.setRect( 0, pos, width, ITEM_HEIGHT ); content.add( item ); items.add( item ); pos += item.height(); } - content.setSize( WIDTH, pos ); + content.setSize( width, pos ); } private static class ListItem extends Component { @@ -156,7 +165,7 @@ public ListItem( Class cl ) { label.hardlight( 0xCCCCCC ); } } catch (Exception e) { - // + // Do nothing } } diff --git a/src/com/watabou/pixeldungeon/windows/WndChallenges.java b/src/com/watabou/pixeldungeon/windows/WndChallenges.java index 444077bcb1..f4d5f73343 100644 --- a/src/com/watabou/pixeldungeon/windows/WndChallenges.java +++ b/src/com/watabou/pixeldungeon/windows/WndChallenges.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -29,13 +29,14 @@ public class WndChallenges extends Window { private static final int WIDTH = 108; - private static final int BTN_HEIGHT = 20; - private static final int GAP = 2; + private static final int TTL_HEIGHT = 12; + private static final int BTN_HEIGHT = 18; + private static final int GAP = 1; private static final String TITLE = "Challenges"; private boolean editable; - private ArrayList boxes; + private ArrayList boxes; public WndChallenges( int checked, boolean editable ) { @@ -47,11 +48,12 @@ public WndChallenges( int checked, boolean editable ) { title.hardlight( TITLE_COLOR ); title.measure(); title.x = PixelScene.align( camera, (WIDTH - title.width()) / 2 ); + title.y = PixelScene.align( camera, (TTL_HEIGHT - title.height()) / 2 ); add( title ); - + boxes = new ArrayList(); - float pos = title.height() + GAP; + float pos = TTL_HEIGHT; for (int i=0; i < Challenges.NAMES.length; i++) { CheckBox cb = new CheckBox( Challenges.NAMES[i] ); @@ -67,7 +69,7 @@ public WndChallenges( int checked, boolean editable ) { add( cb ); boxes.add( cb ); } - + resize( WIDTH, (int)pos ); } diff --git a/src/com/watabou/pixeldungeon/windows/WndChooseWay.java b/src/com/watabou/pixeldungeon/windows/WndChooseWay.java index c6daf2c02a..fd86adb679 100644 --- a/src/com/watabou/pixeldungeon/windows/WndChooseWay.java +++ b/src/com/watabou/pixeldungeon/windows/WndChooseWay.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndClass.java b/src/com/watabou/pixeldungeon/windows/WndClass.java index b7a843fcaa..4c04addb75 100644 --- a/src/com/watabou/pixeldungeon/windows/WndClass.java +++ b/src/com/watabou/pixeldungeon/windows/WndClass.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndError.java b/src/com/watabou/pixeldungeon/windows/WndError.java index 099f86e008..df9a39f153 100644 --- a/src/com/watabou/pixeldungeon/windows/WndError.java +++ b/src/com/watabou/pixeldungeon/windows/WndError.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndGame.java b/src/com/watabou/pixeldungeon/windows/WndGame.java index bd16731eae..06abcd47c7 100644 --- a/src/com/watabou/pixeldungeon/windows/WndGame.java +++ b/src/com/watabou/pixeldungeon/windows/WndGame.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -37,7 +37,7 @@ public class WndGame extends Window { private static final String TXT_RANKINGS = "Rankings"; private static final String TXT_START = "Start New Game"; private static final String TXT_MENU = "Main Menu"; - private static final String TXT_EXIT = "Exit Pixel Dungeon"; + private static final String TXT_EXIT = "Exit Game"; private static final String TXT_RETURN = "Return to Game"; private static final int WIDTH = 120; @@ -92,24 +92,24 @@ protected void onClick() { } ); } - addButton( new RedButton( TXT_MENU ) { - @Override - protected void onClick() { - try { - Dungeon.saveAll(); - } catch (IOException e) { - // + addButtons( + new RedButton( TXT_MENU ) { + @Override + protected void onClick() { + try { + Dungeon.saveAll(); + } catch (IOException e) { + // Do nothing + } + Game.switchScene( TitleScene.class ); } - Game.switchScene( TitleScene.class ); - } - } ); - - addButton( new RedButton( TXT_EXIT ) { - @Override - protected void onClick() { - Game.instance.finish(); - } - } ); + }, new RedButton( TXT_EXIT ) { + @Override + protected void onClick() { + Game.instance.finish(); + } + } + ); addButton( new RedButton( TXT_RETURN ) { @Override @@ -126,4 +126,12 @@ private void addButton( RedButton btn ) { btn.setRect( 0, pos > 0 ? pos += GAP : 0, WIDTH, BTN_HEIGHT ); pos += BTN_HEIGHT; } + + private void addButtons( RedButton btn1, RedButton btn2 ) { + add( btn1 ); + btn1.setRect( 0, pos > 0 ? pos += GAP : 0, (WIDTH - GAP) / 2, BTN_HEIGHT ); + add( btn2 ); + btn2.setRect( btn1.right() + GAP, btn1.top(), WIDTH - btn1.right() - GAP, BTN_HEIGHT ); + pos += BTN_HEIGHT; + } } diff --git a/src/com/watabou/pixeldungeon/windows/WndHero.java b/src/com/watabou/pixeldungeon/windows/WndHero.java index 46cf4a18ff..387788c4aa 100644 --- a/src/com/watabou/pixeldungeon/windows/WndHero.java +++ b/src/com/watabou/pixeldungeon/windows/WndHero.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndImp.java b/src/com/watabou/pixeldungeon/windows/WndImp.java index 8f51447488..a09d6a7e4b 100644 --- a/src/com/watabou/pixeldungeon/windows/WndImp.java +++ b/src/com/watabou/pixeldungeon/windows/WndImp.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -39,8 +39,8 @@ public class WndImp extends Window { private static final String TXT_REWARD = "Take the ring"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; - private static final float GAP = 2; + private static final int BTN_HEIGHT = 20; + private static final int GAP = 2; public WndImp( final Imp imp, final DwarfToken tokens ) { diff --git a/src/com/watabou/pixeldungeon/windows/WndInfoCell.java b/src/com/watabou/pixeldungeon/windows/WndInfoCell.java index 4220c0f8c2..d49347d904 100644 --- a/src/com/watabou/pixeldungeon/windows/WndInfoCell.java +++ b/src/com/watabou/pixeldungeon/windows/WndInfoCell.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndInfoItem.java b/src/com/watabou/pixeldungeon/windows/WndInfoItem.java index 8188d330cc..378fe802f4 100644 --- a/src/com/watabou/pixeldungeon/windows/WndInfoItem.java +++ b/src/com/watabou/pixeldungeon/windows/WndInfoItem.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -69,7 +69,7 @@ public WndInfoItem( Heap heap ) { String title; String info; - if (heap.type == Type.CHEST) { + if (heap.type == Type.CHEST || heap.type == Type.MIMIC) { title = TXT_CHEST; info = TXT_WONT_KNOW; } else if (heap.type == Type.TOMB) { diff --git a/src/com/watabou/pixeldungeon/windows/WndInfoMob.java b/src/com/watabou/pixeldungeon/windows/WndInfoMob.java index 6f3b3b78f1..763d2b428f 100644 --- a/src/com/watabou/pixeldungeon/windows/WndInfoMob.java +++ b/src/com/watabou/pixeldungeon/windows/WndInfoMob.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,12 +18,12 @@ package com.watabou.pixeldungeon.windows; import com.watabou.noosa.BitmapText; -import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ui.Component; import com.watabou.pixeldungeon.actors.mobs.Mob; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.sprites.CharSprite; import com.watabou.pixeldungeon.ui.BuffIndicator; +import com.watabou.pixeldungeon.ui.HealthBar; import com.watabou.pixeldungeon.utils.Utils; public class WndInfoMob extends WndTitledMessage { @@ -45,24 +45,15 @@ private static String desc( Mob mob ) { private static class MobTitle extends Component { - private static final int COLOR_BG = 0xFFCC0000; - private static final int COLOR_LVL = 0xFF00EE00; - - private static final int BAR_HEIGHT = 2; private static final int GAP = 2; private CharSprite image; private BitmapText name; - private ColorBlock hpBg; - private ColorBlock hpLvl; + private HealthBar health; private BuffIndicator buffs; - private float hp; - public MobTitle( Mob mob ) { - hp = (float)mob.HP / mob.HT; - name = PixelScene.createText( Utils.capitalize( mob.name ), 9 ); name.hardlight( TITLE_COLOR ); name.measure(); @@ -71,11 +62,9 @@ public MobTitle( Mob mob ) { image = mob.sprite(); add( image ); - hpBg = new ColorBlock( 1, 1, COLOR_BG ); - add( hpBg ); - - hpLvl = new ColorBlock( 1, 1, COLOR_LVL ); - add( hpLvl ); + health = new HealthBar(); + health.level( (float)mob.HP / mob.HT ); + add( health ); buffs = new BuffIndicator( mob ); add( buffs ); @@ -85,24 +74,20 @@ public MobTitle( Mob mob ) { protected void layout() { image.x = 0; - image.y = Math.max( 0, name.height() + GAP + BAR_HEIGHT - image.height ); + image.y = Math.max( 0, name.height() + GAP + health.height() - image.height ); name.x = image.width + GAP; - name.y = image.height - BAR_HEIGHT - GAP - name.baseLine(); + name.y = image.height - health.height() - GAP - name.baseLine(); float w = width - image.width - GAP; - hpBg.size( w, BAR_HEIGHT ); - hpLvl.size( w * hp, BAR_HEIGHT ); - - hpBg.x = hpLvl.x = image.width + GAP; - hpBg.y = hpLvl.y = image.height - BAR_HEIGHT; + health.setRect( image.width + GAP, image.height - health.height(), w, health.height() ); buffs.setPos( name.x + name.width() + GAP, name.y + name.baseLine() - BuffIndicator.SIZE ); - - height = hpBg.y + hpBg.height(); + + height = health.bottom(); } } } diff --git a/src/com/watabou/pixeldungeon/windows/WndInfoPlant.java b/src/com/watabou/pixeldungeon/windows/WndInfoPlant.java index f74982895a..89931d1332 100644 --- a/src/com/watabou/pixeldungeon/windows/WndInfoPlant.java +++ b/src/com/watabou/pixeldungeon/windows/WndInfoPlant.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndItem.java b/src/com/watabou/pixeldungeon/windows/WndItem.java index 66326a2723..cb144dca97 100644 --- a/src/com/watabou/pixeldungeon/windows/WndItem.java +++ b/src/com/watabou/pixeldungeon/windows/WndItem.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -43,6 +43,9 @@ public WndItem( final WndBag owner, final Item item ) { IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( item.image(), item.glowing() ) ); titlebar.label( Utils.capitalize( item.toString() ) ); + if (item.isUpgradable() && item.levelKnown) { + titlebar.health( (float)item.durability() / item.maxDurability() ); + } titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); @@ -81,6 +84,10 @@ protected void onClick() { btn.setPos( x, y ); add( btn ); + if (action == item.defaultAction) { + btn.textColor( TITLE_COLOR ); + } + x += btn.width() + GAP; } } diff --git a/src/com/watabou/pixeldungeon/windows/WndJournal.java b/src/com/watabou/pixeldungeon/windows/WndJournal.java index 1b84e8f894..5b16b5328b 100644 --- a/src/com/watabou/pixeldungeon/windows/WndJournal.java +++ b/src/com/watabou/pixeldungeon/windows/WndJournal.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -24,6 +24,7 @@ import com.watabou.noosa.ui.Component; import com.watabou.pixeldungeon.Dungeon; import com.watabou.pixeldungeon.Journal; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.ui.Icons; import com.watabou.pixeldungeon.ui.ScrollPane; @@ -31,8 +32,9 @@ public class WndJournal extends Window { - private static final int WIDTH = 112; - private static final int HEIGHT = 160; + private static final int WIDTH = 112; + private static final int HEIGHT_P = 160; + private static final int HEIGHT_L = 144; private static final int ITEM_HEIGHT = 18; @@ -44,7 +46,7 @@ public class WndJournal extends Window { public WndJournal() { super(); - resize( WIDTH, HEIGHT ); + resize( WIDTH, PixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P ); txtTitle = PixelScene.createText( TXT_TITLE, 9 ); txtTitle.hardlight( Window.TITLE_COLOR ); @@ -70,7 +72,7 @@ public WndJournal() { list = new ScrollPane( content ); add( list ); - list.setRect( 0, txtTitle.height(), WIDTH, HEIGHT - txtTitle.height() ); + list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() ); } private static class ListItem extends Component { diff --git a/src/com/watabou/pixeldungeon/windows/WndList.java b/src/com/watabou/pixeldungeon/windows/WndList.java deleted file mode 100644 index 72b33749a9..0000000000 --- a/src/com/watabou/pixeldungeon/windows/WndList.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya - * - * 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.watabou.pixeldungeon.windows; - -import com.watabou.noosa.BitmapText; -import com.watabou.noosa.BitmapTextMultiline; -import com.watabou.pixeldungeon.scenes.PixelScene; -import com.watabou.pixeldungeon.ui.Window; - -public class WndList extends Window { - - private static final int WIDTH = 120; - private static final int MARGIN = 4; - private static final int GAP = 4; - - private static final String DOT = "\u007F"; - - public WndList( String[] items ) { - - super(); - - float pos = MARGIN; - float dotWidth = 0; - float maxWidth = 0; - - for (int i=0; i < items.length; i++) { - - if (i > 0) { - pos += GAP; - } - - BitmapText dot = PixelScene.createText( DOT, 6 ); - dot.x = MARGIN; - dot.y = pos; - if (dotWidth == 0) { - dot.measure(); - dotWidth = dot.width(); - } - add( dot ); - - BitmapTextMultiline item = PixelScene.createMultiline( items[i], 6 ); - item.x = dot.x + dotWidth; - item.y = pos; - item.maxWidth = (int)(WIDTH - MARGIN * 2 - dotWidth); - item.measure(); - add( item ); - - pos += item.height(); - float w = item.width(); - if (w > maxWidth) { - maxWidth = w; - } - } - - resize( (int)(maxWidth + dotWidth + MARGIN * 2), (int)(pos + MARGIN) ); - } -} diff --git a/src/com/watabou/pixeldungeon/windows/WndMessage.java b/src/com/watabou/pixeldungeon/windows/WndMessage.java index 3d8833e3bf..45755e6402 100644 --- a/src/com/watabou/pixeldungeon/windows/WndMessage.java +++ b/src/com/watabou/pixeldungeon/windows/WndMessage.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -18,12 +18,15 @@ package com.watabou.pixeldungeon.windows; import com.watabou.noosa.BitmapTextMultiline; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.ui.Window; public class WndMessage extends Window { - private static final int WIDTH = 120; + private static final int WIDTH_P = 120; + private static final int WIDTH_L = 144; + private static final int MARGIN = 4; public WndMessage( String text ) { @@ -31,7 +34,7 @@ public WndMessage( String text ) { super(); BitmapTextMultiline info = PixelScene.createMultiline( text, 6 ); - info.maxWidth = WIDTH - MARGIN * 2; + info.maxWidth = (PixelDungeon.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2; info.measure(); info.x = info.y = MARGIN; add( info ); diff --git a/src/com/watabou/pixeldungeon/windows/WndOptions.java b/src/com/watabou/pixeldungeon/windows/WndOptions.java index db236db1de..f4625306ea 100644 --- a/src/com/watabou/pixeldungeon/windows/WndOptions.java +++ b/src/com/watabou/pixeldungeon/windows/WndOptions.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndQuest.java b/src/com/watabou/pixeldungeon/windows/WndQuest.java index 293e681d7b..b3d4ea5700 100644 --- a/src/com/watabou/pixeldungeon/windows/WndQuest.java +++ b/src/com/watabou/pixeldungeon/windows/WndQuest.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 diff --git a/src/com/watabou/pixeldungeon/windows/WndRanking.java b/src/com/watabou/pixeldungeon/windows/WndRanking.java index b6199cfa22..f9b32b2e62 100644 --- a/src/com/watabou/pixeldungeon/windows/WndRanking.java +++ b/src/com/watabou/pixeldungeon/windows/WndRanking.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -37,6 +37,7 @@ import com.watabou.pixeldungeon.ui.BadgesList; import com.watabou.pixeldungeon.ui.Icons; import com.watabou.pixeldungeon.ui.ItemSlot; +import com.watabou.pixeldungeon.ui.QuickSlot; import com.watabou.pixeldungeon.ui.RedButton; import com.watabou.pixeldungeon.ui.ScrollPane; import com.watabou.pixeldungeon.utils.Utils; @@ -50,7 +51,7 @@ public class WndRanking extends WndTabbed { private static final String TXT_BADGES = "Badges"; private static final int WIDTH = 112; - private static final int HEIGHT = 144; + private static final int HEIGHT = 134; private static final int TAB_WIDTH = 40; @@ -225,6 +226,7 @@ private float statSlot( Group parent, String label, String value, float pos ) { private class ItemsTab extends Group { + private int count; private float pos; public ItemsTab() { @@ -244,25 +246,54 @@ public ItemsTab() { addItem( stuff.ring2 ); } - if (Dungeon.quickslot instanceof Item && - Dungeon.hero.belongings.backpack.contains( (Item)Dungeon.quickslot )) { + Item primary = getQuickslot( QuickSlot.primaryValue ); + Item secondary = getQuickslot( QuickSlot.secondaryValue ); + + if (count >= 4 && primary != null && secondary != null) { - addItem( (Item)Dungeon.quickslot ); - } else if (Dungeon.quickslot instanceof Class){ - @SuppressWarnings("unchecked") - Item item = Dungeon.hero.belongings.getItem( (Class)Dungeon.quickslot ); - if (item != null) { - addItem( item ); + float size = ItemButton.SIZE; + + ItemButton slot = new ItemButton( primary ); + slot.setRect( 0, pos, size, size ); + add( slot ); + + slot = new ItemButton( secondary ); + slot.setRect( size + 1, pos, size, size ); + add( slot ); + } else { + if (primary != null) { + addItem( primary ); + } + if (secondary != null) { + addItem( secondary ); } } } private void addItem( Item item ) { - ItemButton slot = new ItemButton( item ); - slot.setRect( 0, pos, width, ItemButton.HEIGHT ); + LabelledItemButton slot = new LabelledItemButton( item ); + slot.setRect( 0, pos, width, LabelledItemButton.SIZE ); add( slot ); pos += slot.height() + 1; + count++; + } + + private Item getQuickslot( Object value ) { + if (value instanceof Item && Dungeon.hero.belongings.backpack.contains( (Item)value )) { + + return (Item)value; + + } else if (value instanceof Class){ + + @SuppressWarnings("unchecked") + Item item = Dungeon.hero.belongings.getItem( (Class)value ); + if (item != null) { + return item; + } + } + + return null; } } @@ -282,13 +313,12 @@ public BadgesTab() { private class ItemButton extends Button { - public static final int HEIGHT = 28; + public static final int SIZE = 26; - private Item item; + protected Item item; - private ItemSlot slot; + protected ItemSlot slot; private ColorBlock bg; - private BitmapText name; public ItemButton( Item item ) { @@ -309,15 +339,12 @@ public ItemButton( Item item ) { @Override protected void createChildren() { - bg = new ColorBlock( HEIGHT, HEIGHT, 0xFF4A4D44 ); + bg = new ColorBlock( SIZE, SIZE, 0xFF4A4D44 ); add( bg ); slot = new ItemSlot(); add( slot ); - name = PixelScene.createText( "?", 7 ); - add( name ); - super.createChildren(); } @@ -326,21 +353,7 @@ protected void layout() { bg.x = x; bg.y = y; - slot.setRect( x, y, HEIGHT, HEIGHT ); - - name.x = slot.right() + 2; - name.y = y + (height - name.baseLine()) / 2; - - String str = Utils.capitalize( item.name() ); - name.text( str ); - name.measure(); - if (name.width() > width - name.x) { - do { - str = str.substring( 0, str.length() - 1 ); - name.text( str + "..." ); - name.measure(); - } while (name.width() > width - name.x); - } + slot.setRect( x, y, SIZE, SIZE ); super.layout(); } @@ -360,4 +373,40 @@ protected void onClick() { Game.scene().add( new WndItem( null, item ) ); } } + + private class LabelledItemButton extends ItemButton { + private BitmapText name; + + public LabelledItemButton( Item item ) { + super( item ); + } + + @Override + protected void createChildren() { + super.createChildren(); + + name = PixelScene.createText( "?", 7 ); + add( name ); + } + + @Override + protected void layout() { + + super.layout(); + + name.x = slot.right() + 2; + name.y = y + (height - name.baseLine()) / 2; + + String str = Utils.capitalize( item.name() ); + name.text( str ); + name.measure(); + if (name.width() > width - name.x) { + do { + str = str.substring( 0, str.length() - 1 ); + name.text( str + "..." ); + name.measure(); + } while (name.width() > width - name.x); + } + } + } } diff --git a/src/com/watabou/pixeldungeon/windows/WndResurrect.java b/src/com/watabou/pixeldungeon/windows/WndResurrect.java index 8a8ce7fe1f..725d9ddb16 100644 --- a/src/com/watabou/pixeldungeon/windows/WndResurrect.java +++ b/src/com/watabou/pixeldungeon/windows/WndResurrect.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -36,7 +36,7 @@ public class WndResurrect extends Window { private static final String TXT_NO = "No, I give up"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public static WndResurrect instance; diff --git a/src/com/watabou/pixeldungeon/windows/WndSadGhost.java b/src/com/watabou/pixeldungeon/windows/WndSadGhost.java index 35287fede4..cc36bc21df 100644 --- a/src/com/watabou/pixeldungeon/windows/WndSadGhost.java +++ b/src/com/watabou/pixeldungeon/windows/WndSadGhost.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -44,7 +44,7 @@ public class WndSadGhost extends Window { private static final String TXT_ARMOR = "Ghost's armor"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public WndSadGhost( final Ghost ghost, final Item item ) { diff --git a/src/com/watabou/pixeldungeon/windows/WndSettings.java b/src/com/watabou/pixeldungeon/windows/WndSettings.java index 48bae31e8b..ecdb54e869 100644 --- a/src/com/watabou/pixeldungeon/windows/WndSettings.java +++ b/src/com/watabou/pixeldungeon/windows/WndSettings.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -24,6 +24,7 @@ import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.ui.CheckBox; import com.watabou.pixeldungeon.ui.RedButton; +import com.watabou.pixeldungeon.ui.Toolbar; import com.watabou.pixeldungeon.ui.Window; public class WndSettings extends Window { @@ -41,6 +42,8 @@ public class WndSettings extends Window { private static final String TXT_BRIGHTNESS = "Brightness"; + private static final String TXT_QUICKSLOT = "Second quickslot"; + private static final String TXT_SWITCH_PORT = "Switch to portrait"; private static final String TXT_SWITCH_LAND = "Switch to landscape"; @@ -82,6 +85,8 @@ protected void onClick() { } }.setRect( btnZoomOut.right(), 0, WIDTH - btnZoomIn.width() - btnZoomOut.width(), BTN_HEIGHT ) ); + updateEnabled(); + } else { CheckBox btnScaleUp = new CheckBox( TXT_SCALE_UP ) { @@ -132,33 +137,44 @@ protected void onClick() { btnSound.checked( PixelDungeon.soundFx() ); add( btnSound ); - if (!inGame) { + if (inGame) { - RedButton btnOrientation = new RedButton( orientationText() ) { + CheckBox btnBrightness = new CheckBox( TXT_BRIGHTNESS ) { @Override protected void onClick() { - PixelDungeon.landscape( !PixelDungeon.landscape() ); + super.onClick(); + PixelDungeon.brightness( checked() ); } }; - btnOrientation.setRect( 0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT ); - add( btnOrientation ); + btnBrightness.setRect( 0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT ); + btnBrightness.checked( PixelDungeon.brightness() ); + add( btnBrightness ); - resize( WIDTH, (int)btnOrientation.bottom() ); + CheckBox btnQuickslot = new CheckBox( TXT_QUICKSLOT ) { + @Override + protected void onClick() { + super.onClick(); + Toolbar.secondQuickslot( checked() ); + } + }; + btnQuickslot.setRect( 0, btnBrightness.bottom() + GAP, WIDTH, BTN_HEIGHT ); + btnQuickslot.checked( Toolbar.secondQuickslot() ); + add( btnQuickslot ); + + resize( WIDTH, (int)btnQuickslot.bottom() ); } else { - - CheckBox btnBrightness = new CheckBox( TXT_BRIGHTNESS ) { + + RedButton btnOrientation = new RedButton( orientationText() ) { @Override protected void onClick() { - super.onClick(); - PixelDungeon.brightness( checked() ); + PixelDungeon.landscape( !PixelDungeon.landscape() ); } }; - btnBrightness.setRect( 0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT ); - btnBrightness.checked( PixelDungeon.brightness() ); - add( btnBrightness ); + btnOrientation.setRect( 0, btnSound.bottom() + GAP, WIDTH, BTN_HEIGHT ); + add( btnOrientation ); - resize( WIDTH, (int)btnBrightness.bottom() ); + resize( WIDTH, (int)btnOrientation.bottom() ); } } diff --git a/src/com/watabou/pixeldungeon/windows/WndStory.java b/src/com/watabou/pixeldungeon/windows/WndStory.java index 526d8106eb..ce36d0e599 100644 --- a/src/com/watabou/pixeldungeon/windows/WndStory.java +++ b/src/com/watabou/pixeldungeon/windows/WndStory.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -108,7 +108,7 @@ public void update() { super.update(); if (delay > 0 && (delay -= Game.elapsed) <= 0) { - chrome.visible = tf.visible = true; + shadow.visible = chrome.visible = tf.visible = true; } } @@ -122,7 +122,7 @@ public static void showChapter( int id ) { if (text != null) { WndStory wnd = new WndStory( text ); if ((wnd.delay = 0.6f) > 0) { - wnd.chrome.visible = wnd.tf.visible = false; + wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false; } Game.scene().add( wnd ); diff --git a/src/com/watabou/pixeldungeon/windows/WndTabbed.java b/src/com/watabou/pixeldungeon/windows/WndTabbed.java index 18282d95fd..1a54b01c49 100644 --- a/src/com/watabou/pixeldungeon/windows/WndTabbed.java +++ b/src/com/watabou/pixeldungeon/windows/WndTabbed.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -82,6 +82,11 @@ public void resize( int w, int h ) { camera.resize( (int)chrome.width, (int)(chrome.marginTop() + height + tabHeight()) ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; + + shadow.boxRect( + camera.x / camera.zoom, + camera.y / camera.zoom, + chrome.width(), chrome.height ); // <- super.resize(...) for (Tab tab : tabs) { diff --git a/src/com/watabou/pixeldungeon/windows/WndTitledMessage.java b/src/com/watabou/pixeldungeon/windows/WndTitledMessage.java index 7e94cef8f0..98f5fb28c9 100644 --- a/src/com/watabou/pixeldungeon/windows/WndTitledMessage.java +++ b/src/com/watabou/pixeldungeon/windows/WndTitledMessage.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -20,12 +20,15 @@ import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Image; import com.watabou.noosa.ui.Component; +import com.watabou.pixeldungeon.PixelDungeon; import com.watabou.pixeldungeon.scenes.PixelScene; import com.watabou.pixeldungeon.ui.Window; public class WndTitledMessage extends Window { - private static final int WIDTH = 120; + private static final int WIDTH_P = 120; + private static final int WIDTH_L = 144; + private static final int GAP = 2; private BitmapTextMultiline normal; @@ -41,13 +44,15 @@ public WndTitledMessage( Component titlebar, String message ) { super(); - titlebar.setRect( 0, 0, WIDTH, 0 ); + int width = PixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + + titlebar.setRect( 0, 0, width, 0 ); add( titlebar ); Highlighter hl = new Highlighter( message ); normal = PixelScene.createMultiline( hl.text, 6 ); - normal.maxWidth = WIDTH; + normal.maxWidth = width; normal.measure(); normal.x = titlebar.left(); normal.y = titlebar.bottom() + GAP; @@ -67,6 +72,6 @@ public WndTitledMessage( Component titlebar, String message ) { highlighted.hardlight( TITLE_COLOR ); } - resize( WIDTH, (int)(normal.y + normal.height()) ); + resize( width, (int)(normal.y + normal.height()) ); } } diff --git a/src/com/watabou/pixeldungeon/windows/WndTradeItem.java b/src/com/watabou/pixeldungeon/windows/WndTradeItem.java index e4855975b6..9000f45de0 100644 --- a/src/com/watabou/pixeldungeon/windows/WndTradeItem.java +++ b/src/com/watabou/pixeldungeon/windows/WndTradeItem.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -38,7 +38,7 @@ public class WndTradeItem extends Window { private static final float GAP = 2; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 16; private static final String TXT_SALE = "FOR SALE: %s - %dg"; private static final String TXT_BUY = "Buy for %dg"; @@ -166,7 +166,6 @@ public void hide() { private float createDescription( Item item, boolean forSale ) { - // Title IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( item.image(), item.glowing() ) ); titlebar.label( forSale ? @@ -175,14 +174,12 @@ private float createDescription( Item item, boolean forSale ) { titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); - // Upgraded / degraded if (item.levelKnown && item.level > 0) { titlebar.color( ItemSlot.UPGRADED ); } else if (item.levelKnown && item.level < 0) { titlebar.color( ItemSlot.DEGRADED ); } - // Description BitmapTextMultiline info = PixelScene.createMultiline( item.info(), 6 ); info.maxWidth = WIDTH; info.measure(); @@ -225,7 +222,7 @@ private void sellOne( Item item ) { } private int price( Item item ) { - // This formula is not completely correct... + int price = item.price() * 5 * (Dungeon.depth / 5 + 1); if (Dungeon.hero.buff( RingOfHaggler.Haggling.class ) != null && price >= 2) { price /= 2; diff --git a/src/com/watabou/pixeldungeon/windows/WndWandmaker.java b/src/com/watabou/pixeldungeon/windows/WndWandmaker.java index 50e808f67c..21db6e13c1 100644 --- a/src/com/watabou/pixeldungeon/windows/WndWandmaker.java +++ b/src/com/watabou/pixeldungeon/windows/WndWandmaker.java @@ -1,6 +1,6 @@ /* * Pixel Dungeon - * Copyright (C) 2012-2014 Oleg Dolya + * Copyright (C) 2012-2015 Oleg Dolya * * 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 @@ -41,7 +41,7 @@ public class WndWandmaker extends Window { private static final String TXT_FARAWELL = "Good luck in your quest, %s!"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public WndWandmaker( final Wandmaker wandmaker, final Item item ) {