v0.4.0: refactored artifacts storing their image reference

This commit is contained in:
Evan Debenham 2016-05-13 16:24:31 -04:00
parent 07ec295889
commit c96966f54d
4 changed files with 28 additions and 19 deletions

View File

@ -241,7 +241,6 @@ public class Artifact extends KindofMisc {
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put( IMAGE, image );
bundle.put( EXP , exp ); bundle.put( EXP , exp );
bundle.put( CHARGE , charge ); bundle.put( CHARGE , charge );
bundle.put( PARTIALCHARGE , partialCharge ); bundle.put( PARTIALCHARGE , partialCharge );
@ -250,7 +249,6 @@ public class Artifact extends KindofMisc {
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
if (bundle.contains( IMAGE )) image = bundle.getInt( IMAGE );
exp = bundle.getInt( EXP ); exp = bundle.getInt( EXP );
charge = bundle.getInt( CHARGE ); charge = bundle.getInt( CHARGE );
partialCharge = bundle.getFloat( PARTIALCHARGE ); partialCharge = bundle.getFloat( PARTIALCHARGE );

View File

@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random; import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
@ -123,6 +124,13 @@ public class ChaliceOfBlood extends Artifact {
return super.upgrade(); return super.upgrade();
} }
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (level() >= 7) image = ItemSpriteSheet.ARTIFACT_CHALICE3;
else if (level() >= 3) image = ItemSpriteSheet.ARTIFACT_CHALICE2;
}
@Override @Override
protected ArtifactBuff passiveBuff() { protected ArtifactBuff passiveBuff() {
return new chaliceRegen(); return new chaliceRegen();

View File

@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import java.util.ArrayList; import java.util.ArrayList;
@ -154,6 +155,14 @@ public class HornOfPlenty extends Artifact {
return desc; return desc;
} }
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4;
else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3;
else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2;
}
public class hornRecharge extends ArtifactBuff{ public class hornRecharge extends ArtifactBuff{
@Override @Override
@ -170,14 +179,10 @@ public class HornOfPlenty extends Artifact {
charge++; charge++;
partialCharge -= 36; partialCharge -= 36;
if (charge == chargeCap) if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4;
image = ItemSpriteSheet.ARTIFACT_HORN4; else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3;
else if (charge >= 7) else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2;
image = ItemSpriteSheet.ARTIFACT_HORN3; else image = ItemSpriteSheet.ARTIFACT_HORN1;
else if (charge >= 3)
image = ItemSpriteSheet.ARTIFACT_HORN2;
else
image = ItemSpriteSheet.ARTIFACT_HORN1;
if (charge == chargeCap){ if (charge == chargeCap){
GLog.p( Messages.get(HornOfPlenty.class, "full") ); GLog.p( Messages.get(HornOfPlenty.class, "full") );
@ -220,5 +225,4 @@ public class HornOfPlenty extends Artifact {
} }
} }
}; };
} }

View File

@ -124,14 +124,10 @@ public class SandalsOfNature extends Artifact {
@Override @Override
public Item upgrade() { public Item upgrade() {
if (level() < 0) if (level() < 0) image = ItemSpriteSheet.ARTIFACT_SANDALS;
image = ItemSpriteSheet.ARTIFACT_SANDALS; else if (level() == 0) image = ItemSpriteSheet.ARTIFACT_SHOES;
else if (level() == 0) else if (level() == 1) image = ItemSpriteSheet.ARTIFACT_BOOTS;
image = ItemSpriteSheet.ARTIFACT_SHOES; else if (level() >= 2) image = ItemSpriteSheet.ARTIFACT_GREAVES;
else if (level() == 1)
image = ItemSpriteSheet.ARTIFACT_BOOTS;
else if (level() >= 2)
image = ItemSpriteSheet.ARTIFACT_GREAVES;
name = Messages.get(this, "name_" + (level()+1)); name = Messages.get(this, "name_" + (level()+1));
return super.upgrade(); return super.upgrade();
} }
@ -151,6 +147,9 @@ public class SandalsOfNature extends Artifact {
if (level() > 0) name = Messages.get(this, "name_" + level()); if (level() > 0) name = Messages.get(this, "name_" + level());
if (bundle.contains(SEEDS)) if (bundle.contains(SEEDS))
Collections.addAll(seeds , bundle.getClassArray(SEEDS)); Collections.addAll(seeds , bundle.getClassArray(SEEDS));
if (level() == 1) image = ItemSpriteSheet.ARTIFACT_SHOES;
else if (level() == 2) image = ItemSpriteSheet.ARTIFACT_BOOTS;
else if (level() >= 3) image = ItemSpriteSheet.ARTIFACT_GREAVES;
} }
public class Naturalism extends ArtifactBuff{ public class Naturalism extends ArtifactBuff{