v0.2.3: more implementation on hourglass
This commit is contained in:
parent
9a5f13b656
commit
3d55729861
|
@ -20,6 +20,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||||
|
|
||||||
public class Invisibility extends FlavourBuff {
|
public class Invisibility extends FlavourBuff {
|
||||||
|
@ -63,5 +64,10 @@ public class Invisibility extends FlavourBuff {
|
||||||
cloakBuff.act();
|
cloakBuff.act();
|
||||||
cloakBuff.detach();
|
cloakBuff.detach();
|
||||||
}
|
}
|
||||||
|
//this isn't a form of invisibilty, but it is meant to dispel at the same time as it.
|
||||||
|
TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class );
|
||||||
|
if (timeFreeze != null && Dungeon.hero.visibleEnemies() > 0) {
|
||||||
|
timeFreeze.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,7 @@ public class Hero extends Char {
|
||||||
|
|
||||||
rangedWeapon = wep;
|
rangedWeapon = wep;
|
||||||
boolean result = attack( enemy );
|
boolean result = attack( enemy );
|
||||||
|
Invisibility.dispel();
|
||||||
rangedWeapon = null;
|
rangedWeapon = null;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -378,6 +379,8 @@ public class Hero extends Char {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spend( float time ) {
|
public void spend( float time ) {
|
||||||
|
TimekeepersHourglass.timeFreeze buff = buff(TimekeepersHourglass.timeFreeze.class);
|
||||||
|
if (!(buff != null && buff.processTime(time)))
|
||||||
super.spend( time );
|
super.spend( time );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||||
|
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.Bundle;
|
||||||
|
|
||||||
|
@ -17,6 +21,12 @@ import java.util.ArrayList;
|
||||||
public class TimekeepersHourglass extends Artifact {
|
public class TimekeepersHourglass extends Artifact {
|
||||||
//TODO: string, effect implementation.
|
//TODO: string, effect implementation.
|
||||||
|
|
||||||
|
private static final String TXT_HGLASS = "Timekeeper's Hourglass";
|
||||||
|
private static final String TXT_STASIS = "Put myself in stasis";
|
||||||
|
private static final String TXT_FREEZE = "Freeze time around me";
|
||||||
|
private static final String TXT_DESC =
|
||||||
|
"...";
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "timekeeper's hourglass";
|
name = "timekeeper's hourglass";
|
||||||
image = ItemSpriteSheet.ARTIFACT_HOURGLASS;
|
image = ItemSpriteSheet.ARTIFACT_HOURGLASS;
|
||||||
|
@ -28,6 +38,8 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
defaultAction = AC_ACTIVATE;
|
defaultAction = AC_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String TXT_CHARGE = "%d/%d";
|
||||||
|
|
||||||
public static final String AC_ACTIVATE = "ACTIVATE";
|
public static final String AC_ACTIVATE = "ACTIVATE";
|
||||||
|
|
||||||
//keeps track of generated sandbags.
|
//keeps track of generated sandbags.
|
||||||
|
@ -44,7 +56,24 @@ 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)){
|
||||||
//todo: add logic here
|
GameScene.show(
|
||||||
|
new WndOptions(TXT_HGLASS, TXT_STASIS, TXT_FREEZE, TXT_DESC) {
|
||||||
|
@Override
|
||||||
|
protected void onSelect(int index) {
|
||||||
|
if (index == 0){
|
||||||
|
GLog.i("WIP");
|
||||||
|
} else if (index == 1){
|
||||||
|
GLog.i("everything around you slows to a halt.");
|
||||||
|
GameScene.flash( 0xFFFFFF );
|
||||||
|
Sample.INSTANCE.play( Assets.SND_BLAST );
|
||||||
|
|
||||||
|
activeBuff = new timeFreeze();
|
||||||
|
activeBuff.attachTo(Dungeon.hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
} else
|
} else
|
||||||
super.execute(hero, action);
|
super.execute(hero, action);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +99,12 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String status() {
|
||||||
|
return Utils.format(TXT_CHARGE, charge, chargeCap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//needs to bundle chargecap as it is dynamic.
|
//needs to bundle chargecap as it is dynamic.
|
||||||
private static final String CHARGECAP = "chargecap";
|
private static final String CHARGECAP = "chargecap";
|
||||||
private static final String SANDBAGS = "sandbags";
|
private static final String SANDBAGS = "sandbags";
|
||||||
|
@ -117,7 +152,34 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class timeFreeze extends ArtifactBuff {
|
public class timeFreeze extends ArtifactBuff {
|
||||||
//todo: add logic here
|
//todo: add visual effects
|
||||||
|
|
||||||
|
float partialTime = 0f;
|
||||||
|
|
||||||
|
public boolean processTime(float time){
|
||||||
|
partialTime += time;
|
||||||
|
|
||||||
|
while (partialTime >= 1){
|
||||||
|
partialTime --;
|
||||||
|
charge --;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuickSlot.refresh();
|
||||||
|
|
||||||
|
if (charge <= 0){
|
||||||
|
detach();
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detach(){
|
||||||
|
charge = 0;
|
||||||
|
QuickSlot.refresh();
|
||||||
|
super.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class sandBag extends Item {
|
public static class sandBag extends Item {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user