v0.4.1: keys now display in the journal button
This commit is contained in:
parent
bc7d157b44
commit
df43c611e7
Binary file not shown.
Before Width: | Height: | Size: 330 B After Width: | Height: | Size: 617 B |
|
@ -43,7 +43,7 @@ public class SkeletonKey extends Key {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doPickUp(Hero hero) {
|
public boolean doPickUp(Hero hero) {
|
||||||
Dungeon.hero.belongings.specialKeys[Dungeon.depth]++;
|
Dungeon.hero.belongings.specialKeys[depth]++;
|
||||||
return super.doPickUp(hero);
|
return super.doPickUp(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class StatusPane extends Component {
|
||||||
private BossHealthBar bossHP;
|
private BossHealthBar bossHP;
|
||||||
|
|
||||||
private int lastLvl = -1;
|
private int lastLvl = -1;
|
||||||
private int lastKeys = -1;
|
|
||||||
|
|
||||||
private BitmapText level;
|
private BitmapText level;
|
||||||
private BitmapText depth;
|
private BitmapText depth;
|
||||||
|
@ -222,6 +221,7 @@ public class StatusPane extends Component {
|
||||||
private static class JournalButton extends Button {
|
private static class JournalButton extends Button {
|
||||||
|
|
||||||
private Image bg;
|
private Image bg;
|
||||||
|
//used to display key state to the player
|
||||||
private Image icon;
|
private Image icon;
|
||||||
|
|
||||||
public JournalButton() {
|
public JournalButton() {
|
||||||
|
@ -238,7 +238,7 @@ public class StatusPane extends Component {
|
||||||
bg = new Image( Assets.MENU, 2, 2, 13, 11 );
|
bg = new Image( Assets.MENU, 2, 2, 13, 11 );
|
||||||
add( bg );
|
add( bg );
|
||||||
|
|
||||||
icon = new Image( Assets.MENU, 32, 1, 10, 6);
|
icon = new Image( Assets.MENU, 31, 0, 11, 7);
|
||||||
add( icon );
|
add( icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,41 +249,69 @@ public class StatusPane extends Component {
|
||||||
bg.x = x + 13;
|
bg.x = x + 13;
|
||||||
bg.y = y + 2;
|
bg.y = y + 2;
|
||||||
|
|
||||||
icon.x = bg.x + 2;
|
icon.x = bg.x + (bg.width() - icon.width())/2f;
|
||||||
icon.y = bg.y + 3;
|
icon.y = bg.y + (bg.height() - icon.height())/2f;
|
||||||
|
PixelScene.align(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
updateKeyDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateKeyDisplay() {
|
||||||
|
boolean foundKeys = false;
|
||||||
|
boolean blackKey = false;
|
||||||
|
boolean specialKey = false;
|
||||||
|
int ironKeys = 0;
|
||||||
|
for (int i = 1; i <= Dungeon.depth; i++) {
|
||||||
|
if (Dungeon.hero.belongings.ironKeys[i] > 0 || Dungeon.hero.belongings.specialKeys[i] > 0) {
|
||||||
|
foundKeys = true;
|
||||||
|
|
||||||
for (int i = 1; i <= Dungeon.depth; i++){
|
if (i < Dungeon.depth){
|
||||||
if (Dungeon.hero.belongings.ironKeys[i] > 0){
|
blackKey = true;
|
||||||
|
|
||||||
if (i == Dungeon.depth){
|
|
||||||
icon.resetColor();
|
|
||||||
} else {
|
} else {
|
||||||
icon.brightness(0);
|
if (Dungeon.hero.belongings.specialKeys[i] > 0){
|
||||||
icon.alpha(1f);
|
specialKey = true;
|
||||||
|
}
|
||||||
|
ironKeys = Dungeon.hero.belongings.ironKeys[i];
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
icon.brightness(0);
|
if (!foundKeys){
|
||||||
icon.alpha(0.33f);
|
icon.frame(31, 0, 11, 7);
|
||||||
|
} else {
|
||||||
|
int left = 46, top = 0, width = 0, height = 7;
|
||||||
|
if (blackKey){
|
||||||
|
left = 43;
|
||||||
|
width += 3;
|
||||||
|
}
|
||||||
|
if (specialKey){
|
||||||
|
top = 8;
|
||||||
|
width += 3;
|
||||||
|
}
|
||||||
|
width += ironKeys*3;
|
||||||
|
width = Math.min( width, 9);
|
||||||
|
icon.frame(left, top, width, height);
|
||||||
|
}
|
||||||
|
layout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTouchDown() {
|
protected void onTouchDown() {
|
||||||
bg.brightness( 1.5f );
|
bg.brightness( 1.5f );
|
||||||
|
icon.brightness( 1.5f );
|
||||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTouchUp() {
|
protected void onTouchUp() {
|
||||||
bg.resetColor();
|
bg.resetColor();
|
||||||
|
icon.resetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user