From b36db88c8c6a2a2b1eca4085d2ec8daab02371af Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 4 Feb 2020 01:15:03 -0500 Subject: [PATCH] v0.8.0: added shielding to boss health bars --- core/src/main/assets/boss_hp.png | Bin 413 -> 439 bytes .../ui/BossHealthBar.java | 24 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/core/src/main/assets/boss_hp.png b/core/src/main/assets/boss_hp.png index 40734a580f34583159873ddeb47fba7828bfee26..fcec8e0d155b443762dc3bedbf7c8701e58a3590 100644 GIT binary patch delta 280 zcmV+z0q6dm1GfW^Bmt0-C5V66*x0G5sgIA3czAdo2C@GD0007XQchC<8jJBXLI3~& z)Ja4^RCoc*(=`GWK@bJNdegHwq_}hc3*qkWd|6_`#w#9a4FSNaD-r;*Up38S1VFT3 zm}CIhWbC!96A56=!LLKhexeevuA5EwzKQyJ2z)unQ7!LHR0^c1Xb683%eMv8!tzeT z2_~uvRIzL2uw!D>05zP-gH{4#H!+uQV3}TSO2^hjjsV!$>R2V`pKJk)Y*#&z34r!} z{dNBD1h|ab=nJ?UmEwa?|R_&<-tt|=)1yI|3>`i`*cXteuaSr!$8si eEesfW003AcF|24p+3*Yi00000=$ zF%$;S^CkIlXmMx%8^Yb)842ao7ngVH$kh-#Q&l7YWIGj&qy<2fUl^nTSfy>1%z*?j zv;T8bvK{CNm~*wN-Z#)c9{`{Bb6Ck+13ew2)1x2^EMFGT7nU~)jxll2dk4L00000NkvXXu0mjf Dueokr diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java index 9878b59fd..37c744b03 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/BossHealthBar.java @@ -32,6 +32,9 @@ import com.watabou.noosa.ui.Component; public class BossHealthBar extends Component { private Image bar; + + private Image rawShielding; + private Image shieldedHP; private Image hp; private static Mob boss; @@ -58,6 +61,13 @@ public class BossHealthBar extends Component { width = bar.width; height = bar.height; + rawShielding = new Image(asset, 15, 25, 47, 4); + rawShielding.alpha(0.5f); + add(rawShielding); + + shieldedHP = new Image(asset, 15, 25, 47, 4); + add(shieldedHP); + hp = new Image(asset, 15, 19, 47, 4); add(hp); @@ -77,8 +87,8 @@ public class BossHealthBar extends Component { bar.x = x; bar.y = y; - hp.x = bar.x+15; - hp.y = bar.y+6; + hp.x = shieldedHP.x = rawShielding.x = bar.x+15; + hp.y = shieldedHP.y = rawShielding.y = bar.y+6; skull.x = bar.x+5; skull.y = bar.y+5; @@ -92,7 +102,15 @@ public class BossHealthBar extends Component { boss = null; visible = active = false; } else { - hp.scale.x = (float)boss.HP/boss.HT; + + float health = boss.HP; + float shield = boss.shielding(); + float max = boss.HT; + + hp.scale.x = Math.max( 0, (health-shield)/max); + shieldedHP.scale.x = health/max; + rawShielding.scale.x = shield/max; + if (hp.scale.x < 0.25f) bleed( true ); if (bleeding != blood.on){