|
|
@ -91,6 +91,7 @@ public class TrumpOverlay extends Overlay {
|
|
|
|
private final @NotNull CardActor trumpSuitActor;
|
|
|
|
private final @NotNull CardActor trumpSuitActor;
|
|
|
|
|
|
|
|
|
|
|
|
private boolean animateCard = true;
|
|
|
|
private boolean animateCard = true;
|
|
|
|
|
|
|
|
private boolean animateSuit = true;
|
|
|
|
|
|
|
|
|
|
|
|
public TrumpOverlay(@NotNull GameScreen gameScreen, @Nullable String player, @Nullable Card card, @Nullable Card.Suit suit) {
|
|
|
|
public TrumpOverlay(@NotNull GameScreen gameScreen, @Nullable String player, @Nullable Card card, @Nullable Card.Suit suit) {
|
|
|
|
super(gameScreen, Long.MAX_VALUE);
|
|
|
|
super(gameScreen, Long.MAX_VALUE);
|
|
|
@ -133,7 +134,7 @@ public class TrumpOverlay extends Overlay {
|
|
|
|
var cardGroup = new HorizontalGroup().space(20);
|
|
|
|
var cardGroup = new HorizontalGroup().space(20);
|
|
|
|
root.addActor(cardGroup);
|
|
|
|
root.addActor(cardGroup);
|
|
|
|
|
|
|
|
|
|
|
|
if (trumpCardActor.getParent() != null && trumpCardActor.getCard() == card && suit != null) {
|
|
|
|
if (trumpCardActor.hasParent() && trumpCardActor.getCard() == card && suit != null) {
|
|
|
|
// if card actor is already correct then dont change it
|
|
|
|
// if card actor is already correct then dont change it
|
|
|
|
animateCard = false;
|
|
|
|
animateCard = false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -141,7 +142,8 @@ public class TrumpOverlay extends Overlay {
|
|
|
|
trumpCardActor.setCard(card != null ? card : Card.HIDDEN);
|
|
|
|
trumpCardActor.setCard(card != null ? card : Card.HIDDEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (suit != null && suit != DEFAULT_SUITES.get(card)) {
|
|
|
|
animateSuit = suit != null && suit != DEFAULT_SUITES.get(card);
|
|
|
|
|
|
|
|
if (animateSuit) {
|
|
|
|
trumpSuitActor.setRotation(0);
|
|
|
|
trumpSuitActor.setRotation(0);
|
|
|
|
trumpSuitActor.setOrigin(0, 0);
|
|
|
|
trumpSuitActor.setOrigin(0, 0);
|
|
|
|
cardGroup.addActor(trumpSuitActor);
|
|
|
|
cardGroup.addActor(trumpSuitActor);
|
|
|
@ -157,36 +159,60 @@ public class TrumpOverlay extends Overlay {
|
|
|
|
public void show(Group parent) {
|
|
|
|
public void show(Group parent) {
|
|
|
|
super.show(parent);
|
|
|
|
super.show(parent);
|
|
|
|
|
|
|
|
|
|
|
|
ParallelAction cardAnimation = parallel();
|
|
|
|
boolean cardVisible = trumpCardActor.hasParent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cardAnimation = sequence();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// remove from parent
|
|
|
|
|
|
|
|
var parallel = parallel();
|
|
|
|
|
|
|
|
if (animateSuit) {
|
|
|
|
|
|
|
|
parallel.addAction(targeting(trumpSuitActor, removeActorSilently()));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (animateCard) {
|
|
|
|
if (animateCard) {
|
|
|
|
cardAnimation.addAction(sequence(
|
|
|
|
parallel.addAction(targeting(trumpCardActor, removeActorSilently()));
|
|
|
|
targeting(trumpCardActor, removeActorSilently()),
|
|
|
|
|
|
|
|
targeting(trumpSuitActor, changeParent(screen.getContentRoot())),
|
|
|
|
|
|
|
|
targeting(trumpCardActor, moveTo(10, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT))
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cardAnimation.addAction(parallel);
|
|
|
|
|
|
|
|
|
|
|
|
if (suit != null && suit != DEFAULT_SUITES.get(card)) {
|
|
|
|
// change parent in correct order
|
|
|
|
cardAnimation.addAction(sequence(
|
|
|
|
parallel = parallel();
|
|
|
|
targeting(trumpSuitActor, removeActorSilently()),
|
|
|
|
if (animateSuit) {
|
|
|
|
targeting(trumpSuitActor, changeParent(screen.getContentRoot())),
|
|
|
|
parallel.addAction(targeting(trumpSuitActor, changeParent(screen.getOverlayRoot())));
|
|
|
|
run(trumpCardActor::toFront),
|
|
|
|
}
|
|
|
|
parallel(
|
|
|
|
if (cardVisible) {
|
|
|
|
targeting(trumpSuitActor, rotateTo(-90, AnimationTimings.OVERLAY_SHARED_ELEMENT)),
|
|
|
|
parallel.addAction(targeting(trumpCardActor, changeParent(screen.getOverlayRoot())));
|
|
|
|
targeting(trumpSuitActor,
|
|
|
|
}
|
|
|
|
moveTo(10, 10 + (trumpSuitActor.getHeight() + trumpSuitActor.getWidth()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT)
|
|
|
|
cardAnimation.addAction(parallel);
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// animate
|
|
|
|
|
|
|
|
parallel = parallel();
|
|
|
|
|
|
|
|
if (animateSuit) {
|
|
|
|
|
|
|
|
parallel.addAction(targeting(trumpSuitActor, rotateTo(-90, AnimationTimings.OVERLAY_SHARED_ELEMENT)));
|
|
|
|
|
|
|
|
parallel.addAction(
|
|
|
|
|
|
|
|
targeting(trumpSuitActor,
|
|
|
|
|
|
|
|
moveTo(10, 10 + (trumpSuitActor.getHeight() + trumpSuitActor.getWidth()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
));
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animateCard) {
|
|
|
|
|
|
|
|
parallel.addAction(targeting(trumpCardActor, moveTo(10, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cardAnimation.addAction(parallel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// change parent in correct order
|
|
|
|
|
|
|
|
parallel = parallel();
|
|
|
|
|
|
|
|
if (animateSuit) {
|
|
|
|
|
|
|
|
parallel.addAction(targeting(trumpSuitActor, changeParent(screen.getContentRoot())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cardVisible) {
|
|
|
|
|
|
|
|
parallel.addAction(targeting(trumpCardActor, changeParent(screen.getContentRoot())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cardAnimation.addAction(parallel);
|
|
|
|
|
|
|
|
|
|
|
|
var root = getRoot();
|
|
|
|
var root = getRoot();
|
|
|
|
root.addAction(sequence(
|
|
|
|
root.addAction(sequence(
|
|
|
|
delay(AnimationTimings.OVERLAY_HOLD),
|
|
|
|
delay(AnimationTimings.OVERLAY_HOLD),
|
|
|
|
parallel(
|
|
|
|
cardAnimation,
|
|
|
|
cardAnimation,
|
|
|
|
run(this::close)
|
|
|
|
run(this::close)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|