v0.4.1: big changes to key functionality
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class GoldenKey extends Key {
|
||||
@@ -27,7 +29,13 @@ public class GoldenKey extends Key {
|
||||
{
|
||||
image = ItemSpriteSheet.GOLDEN_KEY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
Dungeon.hero.belongings.specialKeys[Dungeon.depth]++;
|
||||
return super.doPickUp(hero);
|
||||
}
|
||||
|
||||
public GoldenKey() {
|
||||
this( 0 );
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class IronKey extends Key {
|
||||
@@ -31,7 +31,13 @@ public class IronKey extends Key {
|
||||
{
|
||||
image = ItemSpriteSheet.IRON_KEY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
Dungeon.hero.belongings.ironKeys[Dungeon.depth]++;
|
||||
return super.doPickUp(hero);
|
||||
}
|
||||
|
||||
public IronKey() {
|
||||
this( 0 );
|
||||
}
|
||||
@@ -40,21 +46,5 @@ public class IronKey extends Key {
|
||||
super();
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collect( Bag bag ) {
|
||||
boolean result = super.collect( bag );
|
||||
if (result && depth == Dungeon.depth && Dungeon.hero != null) {
|
||||
Dungeon.hero.belongings.countIronKeys();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach( ) {
|
||||
if (depth == Dungeon.depth) {
|
||||
Dungeon.hero.belongings.countIronKeys();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
public class Key extends Item {
|
||||
public abstract class Key extends Item {
|
||||
|
||||
public static final float TIME_TO_UNLOCK = 1f;
|
||||
|
||||
@@ -38,7 +41,15 @@ public class Key extends Item {
|
||||
public boolean isSimilar( Item item ) {
|
||||
return item.getClass() == getClass() && ((Key)item).depth == depth;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
//TODO add a pickup animation to the journal
|
||||
Sample.INSTANCE.play( Assets.SND_ITEM );
|
||||
hero.spendAndNext( TIME_TO_PICK_UP );
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final String DEPTH = "depth";
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
@@ -38,6 +40,12 @@ public class SkeletonKey extends Key {
|
||||
super();
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
Dungeon.hero.belongings.specialKeys[Dungeon.depth]++;
|
||||
return super.doPickUp(hero);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimilar( Item item ) {
|
||||
|
||||
Reference in New Issue
Block a user