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