mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'master' into 'master'
[Mobile] Update Avatar Life Loss/Gain Animation See merge request core-developers/forge!5435
This commit is contained in:
@@ -573,8 +573,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
life -= toLose;
|
||||
//for Avatar animation
|
||||
view.setAvatarWasDamaged(true);
|
||||
view.updateLife(this);
|
||||
lifeLost = toLose;
|
||||
if (manaBurn) {
|
||||
@@ -2639,7 +2637,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
public void updateAvatar() {
|
||||
view.updateAvatarIndex(this);
|
||||
view.updateAvatarCardImageKey(this);
|
||||
view.setAvatarWasDamaged(false);
|
||||
view.setAvatarLifeDifference(0);
|
||||
view.setHasLost(false);
|
||||
}
|
||||
|
||||
@@ -2857,8 +2855,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
view.setHasLost(b);
|
||||
}
|
||||
|
||||
public void setAvatarWasDamaged(boolean val) {
|
||||
view.setAvatarWasDamaged(val);
|
||||
public void setAvatarLifeDifference(int val) {
|
||||
view.setAvatarLifeDifference(val);
|
||||
}
|
||||
|
||||
public int getExtraTurnCount() {
|
||||
|
||||
@@ -224,14 +224,16 @@ public class PlayerView extends GameEntityView {
|
||||
set(TrackableProperty.HasLost, val);
|
||||
}
|
||||
|
||||
public boolean getAvatarWasDamaged() {
|
||||
if (get(TrackableProperty.WasAvatarDamaged) == null)
|
||||
return false;
|
||||
return get(TrackableProperty.WasAvatarDamaged);
|
||||
public int getAvatarLifeDifference() {
|
||||
return (int)get(TrackableProperty.AvatarLifeDifference);
|
||||
}
|
||||
|
||||
public void setAvatarWasDamaged(final boolean val) {
|
||||
set(TrackableProperty.WasAvatarDamaged, val);
|
||||
public boolean wasAvatarLifeChanged() {
|
||||
if ((int)get(TrackableProperty.AvatarLifeDifference) == 0)
|
||||
return false;
|
||||
return (int)get(TrackableProperty.AvatarLifeDifference) != 0;
|
||||
}
|
||||
public void setAvatarLifeDifference(final int val) {
|
||||
set(TrackableProperty.AvatarLifeDifference, val);
|
||||
}
|
||||
|
||||
public int getExtraTurnCount() {
|
||||
|
||||
@@ -204,7 +204,7 @@ public enum TrackableProperty {
|
||||
ExtraTurnCount(TrackableTypes.IntegerType),
|
||||
HasPriority(TrackableTypes.BooleanType, FreezeMode.IgnoresFreeze),
|
||||
HasDelirium(TrackableTypes.BooleanType),
|
||||
WasAvatarDamaged(TrackableTypes.BooleanType),
|
||||
AvatarLifeDifference(TrackableTypes.IntegerType, FreezeMode.IgnoresFreeze),
|
||||
HasLost(TrackableTypes.BooleanType),
|
||||
|
||||
//SpellAbility
|
||||
|
||||
@@ -24,7 +24,9 @@ public class VAvatar extends FDisplayObject {
|
||||
|
||||
private final PlayerView player;
|
||||
private final FImage image;
|
||||
private AvatarAnimation avatarAnimation;
|
||||
private final AvatarAnimation avatarAnimation;
|
||||
private static final FSkinFont LIFE_FONT = FSkinFont.get(18);
|
||||
private static final FSkinFont LIFE_FONT_ALT = FSkinFont.get(22);
|
||||
|
||||
public VAvatar(PlayerView player0) {
|
||||
player = player0;
|
||||
@@ -42,7 +44,6 @@ public class VAvatar extends FDisplayObject {
|
||||
private class AvatarAnimation extends ForgeAnimation {
|
||||
private static final float DURATION = 0.6f;
|
||||
private float progress = 0;
|
||||
private boolean finished;
|
||||
Texture splatter = FSkin.splatter;
|
||||
|
||||
private void drawAvatar(Graphics g, FImage image, float x, float y, float w, float h) {
|
||||
@@ -51,21 +52,34 @@ public class VAvatar extends FDisplayObject {
|
||||
percentage = 0;
|
||||
} else if (percentage > 1) {
|
||||
percentage = 1;
|
||||
//animation finished clear avatar red overlay
|
||||
player.setAvatarWasDamaged(false);
|
||||
}
|
||||
float mod = w/2f;
|
||||
if (splatter == null) {
|
||||
g.setColorRGBA(1, percentage, percentage, g.getfloatAlphaComposite());
|
||||
int amount = player.getAvatarLifeDifference();
|
||||
float oldAlpha = g.getfloatAlphaComposite();
|
||||
float fade = 1-(percentage*1);
|
||||
if (amount > 0) {
|
||||
g.drawAvatarImage(image, x, y, w, h, player.getHasLost());
|
||||
g.resetColorRGBA(g.getfloatAlphaComposite());
|
||||
drawPlayerIndicator(g, w, h, percentage);
|
||||
g.setAlphaComposite(fade);
|
||||
g.drawRect(w / 12f, Color.WHITE, 0, 0, w, h);
|
||||
g.drawText("+"+amount, Forge.altZoneTabs ? LIFE_FONT_ALT : LIFE_FONT, Color.WHITE, 0, (getHeight()/2)*fade, getWidth(), getHeight(), false, Align.center, true);
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
} else if (amount < 0) {
|
||||
if (splatter == null) {
|
||||
g.setColorRGBA(1, percentage, percentage, oldAlpha);
|
||||
g.drawAvatarImage(image, x, y, w, h, player.getHasLost());
|
||||
g.resetColorRGBA(oldAlpha);
|
||||
} else {
|
||||
g.drawAvatarImage(image, x, y, w, h, player.getHasLost());
|
||||
g.setAlphaComposite(1-(percentage*1));
|
||||
g.setAlphaComposite(fade);
|
||||
g.drawImage(splatter, x-mod/2, y-mod/2, w+mod, h+mod);
|
||||
g.resetAlphaComposite();
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
}
|
||||
drawPlayerIndicator(g, w, h, percentage);
|
||||
g.setAlphaComposite(fade);
|
||||
g.drawText(String.valueOf(amount), Forge.altZoneTabs ? LIFE_FONT_ALT : LIFE_FONT, Color.RED, 0, (getHeight()/2)*fade, getWidth(), getHeight(), false, Align.center, true);
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,7 +90,8 @@ public class VAvatar extends FDisplayObject {
|
||||
|
||||
@Override
|
||||
protected void onEnd(boolean endingAll) {
|
||||
finished = true;
|
||||
progress = 0;
|
||||
player.setAvatarLifeDifference(0);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@@ -115,11 +130,10 @@ public class VAvatar extends FDisplayObject {
|
||||
float h = getHeight();
|
||||
|
||||
if (avatarAnimation != null && !MatchController.instance.getGameView().isMatchOver()) {
|
||||
if (player.getAvatarWasDamaged() && avatarAnimation.progress < 1) {
|
||||
if (player.wasAvatarLifeChanged()) {
|
||||
avatarAnimation.start();
|
||||
avatarAnimation.drawAvatar(g, image, 0, 0, w, h);
|
||||
} else {
|
||||
avatarAnimation.progress = 0;
|
||||
g.drawAvatarImage(image, 0, 0, w, h, player.getHasLost());
|
||||
drawPlayerIndicator(g, w, h, 1);
|
||||
}
|
||||
|
||||
@@ -417,9 +417,9 @@ public class VPlayerPanel extends FContainer {
|
||||
private void update() {
|
||||
int vibrateDuration = 0;
|
||||
int delta = player.getLife() - life;
|
||||
player.setAvatarLifeDifference(player.getAvatarLifeDifference()+delta);
|
||||
if (delta != 0) {
|
||||
if (delta < 0) {
|
||||
//TODO: Show animation on avatar for life loss
|
||||
vibrateDuration += delta * -100;
|
||||
}
|
||||
life = player.getLife();
|
||||
|
||||
@@ -474,8 +474,6 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
@Override
|
||||
public Void visit(final GameEventPlayerDamaged event) {
|
||||
//for avatar animation
|
||||
event.target.setAvatarWasDamaged(event.amount > 0);
|
||||
return processEvent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user