v0.2.3c: attack indicator improvements, area now remains untouchable for 0.5seconds to prevent misclicks

This commit is contained in:
Evan Debenham 2015-01-08 23:24:46 -05:00
parent 24c244055a
commit f50445dc14

View File

@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.watabou.noosa.Game;
import com.watabou.utils.Random; import com.watabou.utils.Random;
public class AttackIndicator extends Tag { public class AttackIndicator extends Tag {
@ -32,6 +33,8 @@ public class AttackIndicator extends Tag {
private static final float ENABLED = 1.0f; private static final float ENABLED = 1.0f;
private static final float DISABLED = 0.3f; private static final float DISABLED = 0.3f;
private static float delay = 0.5f;
private static AttackIndicator instance; private static AttackIndicator instance;
private CharSprite sprite = null; private CharSprite sprite = null;
@ -69,6 +72,14 @@ public class AttackIndicator extends Tag {
public void update() { public void update() {
super.update(); super.update();
if (lastTarget == null){
if (delay > 0f) delay -= Game.elapsed;
if (delay <= 0f) active = false;
} else {
delay = 0.5f;
active = true;
}
if (Dungeon.hero.isAlive()) { if (Dungeon.hero.isAlive()) {
enable(Dungeon.hero.ready); enable(Dungeon.hero.ready);
@ -118,6 +129,7 @@ public class AttackIndicator extends Tag {
try { try {
sprite = lastTarget.spriteClass.newInstance(); sprite = lastTarget.spriteClass.newInstance();
active = true;
sprite.idle(); sprite.idle();
sprite.paused = true; sprite.paused = true;
add( sprite ); add( sprite );
@ -133,7 +145,6 @@ public class AttackIndicator extends Tag {
private boolean enabled = true; private boolean enabled = true;
private void enable( boolean value ) { private void enable( boolean value ) {
enabled = value; enabled = value;
active = value;
if (sprite != null) { if (sprite != null) {
sprite.alpha( value ? ENABLED : DISABLED ); sprite.alpha( value ? ENABLED : DISABLED );
} }
@ -148,7 +159,7 @@ public class AttackIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
if (enabled) { if (enabled && lastTarget != null) {
Dungeon.hero.handle( lastTarget.pos ); Dungeon.hero.handle( lastTarget.pos );
} }
} }