From f50445dc14d5fd1b5478d3a414d2eec7b9395946 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 8 Jan 2015 23:24:46 -0500 Subject: [PATCH] v0.2.3c: attack indicator improvements, area now remains untouchable for 0.5seconds to prevent misclicks --- .../shatteredpixeldungeon/ui/AttackIndicator.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java index 034e18af8..c25d228b8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/AttackIndicator.java @@ -25,12 +25,15 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; +import com.watabou.noosa.Game; import com.watabou.utils.Random; public class AttackIndicator extends Tag { private static final float ENABLED = 1.0f; private static final float DISABLED = 0.3f; + + private static float delay = 0.5f; private static AttackIndicator instance; @@ -68,6 +71,14 @@ public class AttackIndicator extends Tag { @Override public void 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()) { @@ -118,6 +129,7 @@ public class AttackIndicator extends Tag { try { sprite = lastTarget.spriteClass.newInstance(); + active = true; sprite.idle(); sprite.paused = true; add( sprite ); @@ -133,7 +145,6 @@ public class AttackIndicator extends Tag { private boolean enabled = true; private void enable( boolean value ) { enabled = value; - active = value; if (sprite != null) { sprite.alpha( value ? ENABLED : DISABLED ); } @@ -148,7 +159,7 @@ public class AttackIndicator extends Tag { @Override protected void onClick() { - if (enabled) { + if (enabled && lastTarget != null) { Dungeon.hero.handle( lastTarget.pos ); } }