v0.3.5: added an action indicator for new functionality
This commit is contained in:
parent
1f40d6289c
commit
2ed6fc9857
|
@ -58,6 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.PlantSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Banner;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator;
|
||||
|
@ -135,6 +136,7 @@ public class GameScene extends PixelScene {
|
|||
|
||||
private AttackIndicator attack;
|
||||
private LootIndicator loot;
|
||||
private ActionIndicator action;
|
||||
private ResumeIndicator resume;
|
||||
|
||||
@Override
|
||||
|
@ -265,6 +267,10 @@ public class GameScene extends PixelScene {
|
|||
loot.camera = uiCamera;
|
||||
add( loot );
|
||||
|
||||
action = new ActionIndicator();
|
||||
action.camera = uiCamera;
|
||||
add( action );
|
||||
|
||||
resume = new ResumeIndicator();
|
||||
resume.camera = uiCamera;
|
||||
add( resume );
|
||||
|
@ -408,25 +414,31 @@ public class GameScene extends PixelScene {
|
|||
log.newLine();
|
||||
}
|
||||
|
||||
if (tagAttack != attack.active || tagLoot != loot.visible || tagResume != resume.visible) {
|
||||
if (tagAttack != attack.active ||
|
||||
tagLoot != loot.visible ||
|
||||
tagAction != action.visible ||
|
||||
tagResume != resume.visible) {
|
||||
|
||||
boolean atkAppearing = attack.active && !tagAttack;
|
||||
boolean lootAppearing = loot.visible && !tagLoot;
|
||||
boolean resAppearing = resume.visible && !tagResume;
|
||||
//we only want to change the layout when new tags pop in, not when existing ones leave.
|
||||
boolean tagAppearing = (attack.active && !tagAttack) ||
|
||||
(loot.visible && !tagLoot) ||
|
||||
(action.visible && !tagAction) ||
|
||||
(resume.visible && !tagResume);
|
||||
|
||||
tagAttack = attack.active;
|
||||
tagLoot = loot.visible;
|
||||
tagAction = action.visible;
|
||||
tagResume = resume.visible;
|
||||
|
||||
if (atkAppearing || lootAppearing || resAppearing)
|
||||
layoutTags();
|
||||
if (tagAppearing) layoutTags();
|
||||
}
|
||||
|
||||
cellSelector.enable(Dungeon.hero.ready);
|
||||
}
|
||||
|
||||
private boolean tagAttack = false;
|
||||
private boolean tagLoot = false;
|
||||
private boolean tagLoot = false;
|
||||
private boolean tagAction = false;
|
||||
private boolean tagResume = false;
|
||||
|
||||
public static void layoutTags() {
|
||||
|
@ -455,6 +467,12 @@ public class GameScene extends PixelScene {
|
|||
pos = scene.loot.top();
|
||||
}
|
||||
|
||||
if (scene.tagAction) {
|
||||
scene.action.setPos( tagLeft, pos - scene.action.height() );
|
||||
scene.action.flip(tagLeft == 0);
|
||||
pos = scene.action.top();
|
||||
}
|
||||
|
||||
if (scene.tagResume) {
|
||||
scene.resume.setPos( tagLeft, pos - scene.resume.height() );
|
||||
scene.resume.flip(tagLeft == 0);
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
public class ActionIndicator extends Tag {
|
||||
|
||||
Image icon;
|
||||
|
||||
public static Action action;
|
||||
public static ActionIndicator instance;
|
||||
|
||||
public ActionIndicator() {
|
||||
super( 0xFFFF4C );
|
||||
|
||||
instance = this;
|
||||
|
||||
setSize( 24, 24 );
|
||||
visible = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
|
||||
if (icon != null){
|
||||
icon.x = x + (width - icon.width()) / 2;
|
||||
icon.y = y + (height - icon.height()) / 2;
|
||||
PixelScene.align(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (!Dungeon.hero.ready){
|
||||
if (icon != null) icon.alpha(0.5f);
|
||||
} else {
|
||||
if (icon != null) icon.alpha(1f);
|
||||
}
|
||||
|
||||
if (!visible && action != null){
|
||||
visible = true;
|
||||
flash();
|
||||
} else {
|
||||
visible = action != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (action != null && Dungeon.hero.ready)
|
||||
action.doAction();
|
||||
}
|
||||
|
||||
public static void setAction(Action action){
|
||||
ActionIndicator.action = action;
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
public static void clearAction(){
|
||||
action = null;
|
||||
}
|
||||
|
||||
public static void updateIcon(){
|
||||
if (instance != null){
|
||||
if (instance.icon != null){
|
||||
instance.icon.killAndErase();
|
||||
instance.icon = null;
|
||||
}
|
||||
if (action != null){
|
||||
instance.icon = action.getIcon();
|
||||
instance.layout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface Action{
|
||||
|
||||
public Image getIcon();
|
||||
|
||||
public void doAction();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -36,7 +36,7 @@ public class AttackIndicator extends Tag {
|
|||
private static final float ENABLED = 1.0f;
|
||||
private static final float DISABLED = 0.3f;
|
||||
|
||||
private static float delay = 0.75f;
|
||||
private static float delay;
|
||||
|
||||
private static AttackIndicator instance;
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
|
||||
public class Tag extends Button {
|
||||
|
||||
|
@ -48,6 +48,7 @@ public class Tag extends Button {
|
|||
super.createChildren();
|
||||
|
||||
bg = Chrome.get( Chrome.Type.TAG );
|
||||
bg.hardlight( r, g, b );
|
||||
add( bg );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user