v0.2.3: tweaks/polish to timekeeper's hourglass

This commit is contained in:
Evan Debenham 2014-12-11 17:24:38 -05:00
parent c429e0e832
commit c2b9718581

View File

@ -60,27 +60,33 @@ public class TimekeepersHourglass extends Artifact {
@Override @Override
public void execute( Hero hero, String action ) { public void execute( Hero hero, String action ) {
if (action.equals(AC_ACTIVATE)){ if (action.equals(AC_ACTIVATE)){
GameScene.show(
if (!isEquipped( hero )) GLog.i("You need to equip your hourglass to do that.");
else if (activeBuff != null) GLog.i("Your hourglass is already in use.");
else if (charge <= 1) GLog.i("Your hourglass hasn't recharged enough to be usable yet.");
else GameScene.show(
new WndOptions(TXT_HGLASS, TXT_DESC, TXT_STASIS, TXT_FREEZE) { new WndOptions(TXT_HGLASS, TXT_DESC, TXT_STASIS, TXT_FREEZE) {
@Override @Override
protected void onSelect(int index) { protected void onSelect(int index) {
if (index == 0){ if (index == 0) {
GLog.i("Everything seems to fly around you."); GLog.i("Everything seems to blur while moving around you.");
GameScene.flash( 0xFFFFFF ); GameScene.flash(0xFFFFFF);
Sample.INSTANCE.play( Assets.SND_TELEPORT ); Sample.INSTANCE.play(Assets.SND_TELEPORT);
activeBuff = new timeStasis(); activeBuff = new timeStasis();
activeBuff.attachTo(Dungeon.hero); activeBuff.attachTo(Dungeon.hero);
} else if (index == 1){ } else if (index == 1) {
GLog.i("everything around you suddenly freezes."); GLog.i("everything around you suddenly freezes.");
GameScene.flash( 0xFFFFFF ); GameScene.flash(0xFFFFFF);
Sample.INSTANCE.play( Assets.SND_TELEPORT ); Sample.INSTANCE.play(Assets.SND_TELEPORT);
activeBuff = new timeFreeze(); activeBuff = new timeFreeze();
activeBuff.attachTo(Dungeon.hero); activeBuff.attachTo(Dungeon.hero);
} }
}; }
;
} }
); );
} else } else
@ -94,6 +100,18 @@ public class TimekeepersHourglass extends Artifact {
activeBuff.attachTo(ch); activeBuff.attachTo(ch);
} }
@Override
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
if (super.doUnequip(hero, collect, single)){
if (activeBuff != null){
activeBuff.detach();
activeBuff = null;
}
return true;
} else
return false;
}
@Override @Override
protected ArtifactBuff passiveBuff() { protected ArtifactBuff passiveBuff() {
return new hourglassRecharge(); return new hourglassRecharge();
@ -126,6 +144,8 @@ public class TimekeepersHourglass extends Artifact {
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put( CHARGECAP, chargeCap ); bundle.put( CHARGECAP, chargeCap );
bundle.put( SANDBAGS, sandBags ); bundle.put( SANDBAGS, sandBags );
if (activeBuff != null)
bundle.put( BUFF , activeBuff ); bundle.put( BUFF , activeBuff );
} }
@ -134,7 +154,18 @@ public class TimekeepersHourglass extends Artifact {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
chargeCap = bundle.getInt( CHARGECAP ); chargeCap = bundle.getInt( CHARGECAP );
sandBags = bundle.getInt( SANDBAGS ); sandBags = bundle.getInt( SANDBAGS );
activeBuff = (ArtifactBuff)bundle.get( BUFF );
//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
if (bundle.contains( BUFF )){
Bundle buffBundle = bundle.getBundle( BUFF );
if (buffBundle.contains( timeFreeze.PARTIALTIME ))
activeBuff = new timeFreeze();
else
activeBuff = new timeStasis();
activeBuff.restoreFromBundle(buffBundle);
}
} }
public class hourglassRecharge extends ArtifactBuff { public class hourglassRecharge extends ArtifactBuff {
@ -162,8 +193,6 @@ public class TimekeepersHourglass extends Artifact {
} }
public class timeStasis extends ArtifactBuff { public class timeStasis extends ArtifactBuff {
//todo: add visuals
@Override @Override
public boolean attachTo(Char target) { public boolean attachTo(Char target) {
@ -181,6 +210,8 @@ public class TimekeepersHourglass extends Artifact {
QuickSlot.refresh(); QuickSlot.refresh();
Dungeon.observe();
return super.attachTo(target); return super.attachTo(target);
} }