v1.3.2: expanded the information shown in boss health bars

This commit is contained in:
Evan Debenham
2022-07-19 18:51:36 -04:00
parent 56d4a551bf
commit 3419bd4540
4 changed files with 98 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 428 B

View File

@@ -746,6 +746,7 @@ public class Hero extends Char {
ready = true;
AttackIndicator.updateState();
BuffIndicator.refreshBoss();
GameScene.ready();
}
@@ -1332,6 +1333,10 @@ public class Hero extends Char {
public Mob visibleEnemy( int index ) {
return visibleEnemies.get(index % visibleEnemies.size());
}
public ArrayList<Mob> getVisibleEnemies(){
return new ArrayList<>(visibleEnemies);
}
private boolean walkingToVisibleTrapInFog = false;

View File

@@ -25,6 +25,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.BloodParticle;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoMob;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Image;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.ui.Component;
@@ -36,6 +40,10 @@ public class BossHealthBar extends Component {
private Image rawShielding;
private Image shieldedHP;
private Image hp;
private BitmapText hpText;
private Button bossInfo;
private BuffIndicator buffs;
private static Mob boss;
@@ -53,6 +61,13 @@ public class BossHealthBar extends Component {
instance = this;
}
@Override
public synchronized void destroy() {
super.destroy();
if (instance == this) instance = null;
if (buffs != null) BuffIndicator.setBossInstance(null);
}
@Override
protected void createChildren() {
bar = new Image(asset, 0, 0, 64, 16);
@@ -71,6 +86,35 @@ public class BossHealthBar extends Component {
hp = new Image(asset, 15, 19, 47, 4);
add(hp);
hpText = new BitmapText(PixelScene.pixelFont);
hpText.alpha(0.6f);
add(hpText);
bossInfo = new Button(){
@Override
protected void onClick() {
super.onClick();
if (boss != null){
GameScene.show(new WndInfoMob(boss));
}
}
@Override
protected String hoverText() {
if (boss != null){
return boss.name();
}
return super.hoverText();
}
};
add(bossInfo);
if (boss != null) {
buffs = new BuffIndicator(boss, false);
BuffIndicator.setBossInstance(buffs);
add(buffs);
}
skull = new Image(asset, 5, 18, 6, 6);
add(skull);
@@ -88,7 +132,19 @@ public class BossHealthBar extends Component {
bar.y = y;
hp.x = shieldedHP.x = rawShielding.x = bar.x+15;
hp.y = shieldedHP.y = rawShielding.y = bar.y+6;
hp.y = shieldedHP.y = rawShielding.y = bar.y+3;
hpText.scale.set(PixelScene.align(0.5f));
hpText.x = hp.x + 1;
hpText.y = hp.y + (hp.height - (hpText.baseLine()+hpText.scale.y))/2f;
hpText.y -= 0.001f; //prefer to be slightly higher
PixelScene.align(hpText);
bossInfo.setRect(x, y, bar.width, bar.height);
if (buffs != null) {
buffs.setRect(hp.x, hp.y + 5, 110, 7);
}
skull.x = bar.x+5;
skull.y = bar.y+5;
@@ -103,13 +159,13 @@ public class BossHealthBar extends Component {
visible = active = false;
} else {
float health = boss.HP;
float shield = boss.shielding();
float max = boss.HT;
int health = boss.HP;
int shield = boss.shielding();
int max = boss.HT;
hp.scale.x = Math.max( 0, (health-shield)/max);
shieldedHP.scale.x = health/max;
rawShielding.scale.x = shield/max;
hp.scale.x = Math.max( 0, (health-shield)/(float)max);
shieldedHP.scale.x = health/(float)max;
rawShielding.scale.x = shield/(float)max;
if (hp.scale.x < 0.25f) bleed( true );
@@ -118,15 +174,34 @@ public class BossHealthBar extends Component {
else skull.resetColor();
blood.on = bleeding;
}
if (shield <= 0){
hpText.text(health + "/" + max);
} else {
hpText.text(health + "+" + shield + "/" + max);
}
}
}
}
public static void assignBoss(Mob boss){
if (BossHealthBar.boss == boss) {
return;
}
BossHealthBar.boss = boss;
bleed(false);
if (instance != null) {
instance.visible = instance.active = true;
if (boss != null){
if (instance.buffs != null){
instance.buffs.killAndErase();
}
instance.buffs = new BuffIndicator(boss, false);
BuffIndicator.setBossInstance(instance.buffs);
instance.add(instance.buffs);
instance.layout();
}
}
}

View File

@@ -115,6 +115,7 @@ public class BuffIndicator extends Component {
public static final int SIZE_LARGE = 16;
private static BuffIndicator heroInstance;
private static BuffIndicator bossInstance;
private LinkedHashMap<Buff, BuffButton> buffButtons = new LinkedHashMap<>();
private boolean needsRefresh;
@@ -302,4 +303,14 @@ public class BuffIndicator extends Component {
heroInstance.needsRefresh = true;
}
}
public static void refreshBoss(){
if (bossInstance != null) {
bossInstance.needsRefresh = true;
}
}
public static void setBossInstance(BuffIndicator boss){
bossInstance = boss;
}
}