@ -0,0 +1,36 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.utils.Pool;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import lombok.Setter;
|
||||
|
||||
/** Removes an actor from the stage.
|
||||
* @author Nathan Sweet */
|
||||
public class ChangeParentAction extends Action {
|
||||
private final Pool<Vector2> vectorPool = Pools.get(Vector2.class);
|
||||
|
||||
@Setter
|
||||
private Group parent;
|
||||
private boolean finished;
|
||||
|
||||
public boolean act (float delta) {
|
||||
if (!finished) {
|
||||
finished = true;
|
||||
var pos = vectorPool.obtain();
|
||||
pos.set(0, 0);
|
||||
target.localToStageCoordinates(pos);
|
||||
parent.stageToLocalCoordinates(pos);
|
||||
target.setPosition(pos.x, pos.y);
|
||||
parent.addActor(target);
|
||||
vectorPool.free(pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void restart () {
|
||||
finished = false;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
|
||||
public class MyActions extends Actions {
|
||||
public static ChangeParentAction changeParent(Group parent) {
|
||||
var action = action(ChangeParentAction.class);
|
||||
action.setParent(parent);
|
||||
return action;
|
||||
}
|
||||
|
||||
public static <T extends Action> T target(T action, Actor target) {
|
||||
action.setTarget(target);
|
||||
return action;
|
||||
}
|
||||
|
||||
static public SilentlyRemoveActorAction removeActorSilently () {
|
||||
return action(SilentlyRemoveActorAction.class);
|
||||
}
|
||||
|
||||
static public SilentlyRemoveActorAction removeActorSilently(Actor removeActor) {
|
||||
var action = action(SilentlyRemoveActorAction.class);
|
||||
action.setTarget(removeActor);
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actions;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||
|
||||
/** Removes an actor from the stage without immediately invalidating its parents. */
|
||||
public class SilentlyRemoveActorAction extends Action {
|
||||
private boolean removed;
|
||||
|
||||
public boolean act (float delta) {
|
||||
if (!removed) {
|
||||
removed = true;
|
||||
if (target.getParent() != null) {
|
||||
target.getParent().getChildren().removeValue(target, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void restart () {
|
||||
removed = false;
|
||||
}
|
||||
}
|
@ -103,12 +103,15 @@ public class CardActor extends Actor {
|
||||
|
||||
private Card card;
|
||||
private TextureRegion background;
|
||||
private TextureRegion border;
|
||||
|
||||
public CardActor(Card card, TextureAtlas atlas) {
|
||||
this.atlas = atlas;
|
||||
setCard(card);
|
||||
setWidth(PREF_WIDTH);
|
||||
setHeight(PREF_HEIGHT);
|
||||
setColor(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
border = atlas.findRegion(GameAtlas.CARDS_BORDER2);
|
||||
}
|
||||
|
||||
public void setCard(Card card) {
|
||||
@ -122,6 +125,7 @@ public class CardActor extends Actor {
|
||||
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
|
||||
|
||||
float height = getWidth() * ASPECT_RATIO;
|
||||
batch.draw(background, getX(), getY() + getHeight() - height, getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
|
||||
batch.draw(background, getX(), getY() + getHeight() - height, getOriginX(), getOriginY(), getWidth(), height, getScaleX(), getScaleY(), getRotation());
|
||||
batch.draw(border, getX(), getY() + getHeight() - height, getOriginX(), getOriginY(), getWidth(), height, getScaleX(), getScaleY(), getRotation());
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class CardStack extends Group {
|
||||
private static final float EXPAND_DURATION = 0.25f;
|
||||
private static final float EXPANDED_ROTATION_DEVIATION = 20;
|
||||
private static final float EXPANDED_ROTATION_DEVIATION = 10;
|
||||
private static final float COLLAPSE_DURATION = 0.25f;
|
||||
private static final float COLLAPSED_ROTATION_DEVIATION = 60;
|
||||
private static final float COLLAPSED_POSITION_DEVIATION = 15;
|
||||
@ -25,13 +25,11 @@ public class CardStack extends Group {
|
||||
|
||||
public CardStack() {
|
||||
this.addActor(hover);
|
||||
this.addListener(new ClickListener() {
|
||||
this.addListener(new InputListener() {
|
||||
|
||||
@Override
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
|
||||
super.exit(event, x, y, pointer, toActor);
|
||||
|
||||
if (event.getTarget() == hover && expanded) {
|
||||
if (pointer == -1 && event.getTarget() == hover && expanded) {
|
||||
expanded = false;
|
||||
cards.forEach(Entry::collapse);
|
||||
}
|
||||
@ -39,9 +37,7 @@ public class CardStack extends Group {
|
||||
|
||||
@Override
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||
super.enter(event, x, y, pointer, fromActor);
|
||||
|
||||
if (event.getTarget() == hover && !expanded) {
|
||||
if (pointer == -1 && event.getTarget() == hover && !expanded) {
|
||||
expanded = true;
|
||||
cards.forEach(Entry::expand);
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
||||
@ -26,13 +28,13 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
import static eu.jonahbauer.wizard.client.libgdx.actions.MyActions.*;
|
||||
|
||||
public class GameScreen extends MenuScreen {
|
||||
private final WizardGame game;
|
||||
|
||||
private TextureAtlas atlas;
|
||||
private TextureRegion background;
|
||||
private Drawable overlay;
|
||||
|
||||
private final List<UUID> players;
|
||||
|
||||
@ -56,6 +58,8 @@ public class GameScreen extends MenuScreen {
|
||||
private CardStack cardStack;
|
||||
private PadOfTruth padOfTruth;
|
||||
private CardActor trumpCardActor;
|
||||
private VerticalGroup messages;
|
||||
|
||||
private Map<UUID, Seat> seats = new HashMap<>();
|
||||
private Map<UUID, Label> nameLabels = new HashMap<>();
|
||||
|
||||
@ -87,7 +91,7 @@ public class GameScreen extends MenuScreen {
|
||||
public void show() {
|
||||
super.show();
|
||||
atlas = new TextureAtlas(Gdx.files.internal(GameAtlas.$PATH));
|
||||
background = atlas.findRegion(GameAtlas.BACKGROUND);
|
||||
overlay = new TextureRegionDrawable(data.uiskinAtlas.findRegion(UiskinAtlas.WHITE)).tint(new Color(0,0,0,0.5f));
|
||||
|
||||
seat();
|
||||
prepareLabels();
|
||||
@ -96,9 +100,14 @@ public class GameScreen extends MenuScreen {
|
||||
handCards.setOnClickListener(card -> playCard(self, card.getCard()));
|
||||
var container = new Container<>(handCards);
|
||||
container.setPosition(360, 75);
|
||||
container.setSize(1200, 210);
|
||||
container.setSize(1200, CardActor.PREF_HEIGHT);
|
||||
container.fillX();
|
||||
|
||||
messages = new VerticalGroup().columnCenter().bottom();
|
||||
messages.setPosition(360, 85 + CardActor.PREF_HEIGHT);
|
||||
messages.setSize(1200, 0);
|
||||
messages.setTouchable(Touchable.disabled);
|
||||
|
||||
padOfTruth = new PadOfTruth(data.skin, new TextureRegionDrawable(atlas.findRegion(GameAtlas.PAD_OF_TRUTH)));
|
||||
padOfTruth.setPosition(1910 - 636f, 10);
|
||||
padOfTruth.setOrigin(636f, 0);
|
||||
@ -108,63 +117,77 @@ public class GameScreen extends MenuScreen {
|
||||
|
||||
setNames();
|
||||
|
||||
var trump = new TextButton("Trump", data.skin);
|
||||
Gdx.input.setInputProcessor(data.stage);
|
||||
data.stage.addActor(container);
|
||||
data.stage.addActor(cardStack);
|
||||
data.stage.addActor(padOfTruth);
|
||||
data.stage.addActor(messages);
|
||||
data.stage.addActor(debugButtons());
|
||||
}
|
||||
|
||||
private Group debugButtons() {
|
||||
var trump = new TextButton("Trump", data.skin, "simple");
|
||||
trump.align(Align.left);
|
||||
trump.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
setTrumpCard(Card.values()[(int)(Math.random() * Card.values().length)]);
|
||||
onMessage(new GameMessage(new TrumpMessage(
|
||||
Card.values()[(int)(Math.random() * Card.values().length)],
|
||||
Card.Suit.values()[(int)(Math.random() * Card.Suit.values().length)]
|
||||
)));
|
||||
}
|
||||
});
|
||||
|
||||
var playCard = new TextButton("Play Card", data.skin);
|
||||
var playCard = new TextButton("Play Card", data.skin, "simple");
|
||||
playCard.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
var hand = hands.get(self);
|
||||
if (hand != null && hand.size() > 0) {
|
||||
playCard(self, hand.get((int) (Math.random() * hand.size())));
|
||||
onMessage(new GameMessage(new CardMessage(
|
||||
self,
|
||||
hand.get((int) (Math.random() * hand.size()))
|
||||
)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var deal = new TextButton("Deal", data.skin);
|
||||
var deal = new TextButton("Deal", data.skin, "simple");
|
||||
deal.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
var hand = Stream.of(Card.values()).limit(20).toList();
|
||||
setHand(self, hand);
|
||||
onMessage(new GameMessage(new HandMessage(self, hand)));
|
||||
}
|
||||
});
|
||||
|
||||
var round = new TextButton("Round", data.skin);
|
||||
var round = new TextButton("Round", data.skin, "simple");
|
||||
round.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
startRound();
|
||||
onMessage(new GameMessage(new StateMessage("starting_round")));
|
||||
round.setText("Round " + GameScreen.this.round);
|
||||
}
|
||||
});
|
||||
|
||||
var scores = new TextButton("Scores", data.skin);
|
||||
var scores = new TextButton("Scores", data.skin, "simple");
|
||||
scores.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
var scores = players.stream().collect(Collectors.toMap(p -> p, p -> (int) (Math.random() * 5) * 10));
|
||||
addScores(scores);
|
||||
onMessage(new GameMessage(new ScoreMessage(scores)));
|
||||
}
|
||||
});
|
||||
|
||||
var predictions = new TextButton("Predictions", data.skin);
|
||||
var predictions = new TextButton("Predictions", data.skin, "simple");
|
||||
predictions.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
var predictions = players.stream().collect(Collectors.toMap(p -> p, p -> (int) (Math.random() * 5)));
|
||||
predictions.forEach((player, prediction) -> addPrediction(player, prediction));
|
||||
players.forEach(player -> onMessage(new GameMessage(new PredictionMessage(player, (int) (Math.random() * 5)))));
|
||||
}
|
||||
});
|
||||
|
||||
var playOtherCard = new TextButton("Play Other Card", data.skin);
|
||||
var playOtherCard = new TextButton("Play Other Card", data.skin, "simple");
|
||||
playOtherCard.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@ -172,8 +195,8 @@ public class GameScreen extends MenuScreen {
|
||||
UUID player;
|
||||
do {
|
||||
player = players.get((int) (Math.random() * players.size()));
|
||||
} while (player.equals(self));
|
||||
playCard(player, card);
|
||||
} while (self.equals(player));
|
||||
onMessage(new GameMessage(new CardMessage(player, card)));
|
||||
}
|
||||
});
|
||||
|
||||
@ -186,12 +209,7 @@ public class GameScreen extends MenuScreen {
|
||||
buttons.addActor(playCard);
|
||||
buttons.addActor(playOtherCard);
|
||||
buttons.addActor(scores);
|
||||
|
||||
Gdx.input.setInputProcessor(data.stage);
|
||||
data.stage.addActor(container);
|
||||
data.stage.addActor(cardStack);
|
||||
data.stage.addActor(padOfTruth);
|
||||
data.stage.addActor(buttons);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -200,8 +218,8 @@ public class GameScreen extends MenuScreen {
|
||||
data.extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
||||
data.extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
||||
);
|
||||
game.batch.draw(data.background, 0,0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
||||
game.batch.setColor(1, 1, 1, 0.25f);
|
||||
game.batch.draw(data.background, 0,0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
||||
game.batch.draw(
|
||||
data.title,
|
||||
(data.extendViewport.getWorldWidth() - data.title.getRegionWidth() * 0.75f) / 2f,
|
||||
@ -233,7 +251,7 @@ public class GameScreen extends MenuScreen {
|
||||
|
||||
private void prepareLabels() {
|
||||
for (UUID player : players) {
|
||||
if (player.equals(self)) continue;
|
||||
if (self.equals(player)) continue;
|
||||
var label = new Label("", data.skin);
|
||||
var seat = seats.get(player);
|
||||
label.setX(seat.getLabelX());
|
||||
@ -257,16 +275,55 @@ public class GameScreen extends MenuScreen {
|
||||
|
||||
private void startRound() {
|
||||
round++;
|
||||
hands.clear();
|
||||
tricks.clear();
|
||||
predictions.clear();
|
||||
|
||||
trumpSuit = null;
|
||||
trumpCard = null;
|
||||
handCards.clearChildren();
|
||||
cardStack.clearChildren();
|
||||
if (trumpCardActor != null) {
|
||||
trumpCardActor.remove();
|
||||
}
|
||||
|
||||
trick = -1;
|
||||
|
||||
handCards.clearChildren();
|
||||
hands.clear();
|
||||
|
||||
cardStack.clearChildren();
|
||||
stack.clear();
|
||||
|
||||
var group = new VerticalGroup().columnCenter().space(10f);
|
||||
|
||||
var overlay = new Container<>(group);
|
||||
overlay.setBackground(this.overlay);
|
||||
overlay.setBounds(0, 0, WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
overlay.setTouchable(Touchable.enabled);
|
||||
|
||||
var label = new Label("Round " + (round + 1), data.skin, "enchanted");
|
||||
label.setFontScale(1.5f);
|
||||
group.addActor(label);
|
||||
|
||||
data.stage.addActor(overlay);
|
||||
data.stage.addAction(sequence(
|
||||
delay(2.0f),
|
||||
target(alpha(0.0f, .1f, Interpolation.pow2Out), overlay),
|
||||
removeActor(overlay)
|
||||
));
|
||||
}
|
||||
|
||||
private void startTrick() {
|
||||
trick++;
|
||||
|
||||
setActivePlayer(null, null);
|
||||
|
||||
cardStack.clearChildren();
|
||||
stack.clear();
|
||||
}
|
||||
|
||||
private void finishTrick(UUID player, List<Card> cards) {
|
||||
stack.clear();
|
||||
tricks.computeIfAbsent(player, p -> new ArrayList<>()).add(cards);
|
||||
// TODO
|
||||
}
|
||||
|
||||
private void setHand(UUID player, List<Card> cards) {
|
||||
@ -274,11 +331,14 @@ public class GameScreen extends MenuScreen {
|
||||
hand.clear();
|
||||
hand.addAll(cards);
|
||||
|
||||
if (self.equals(player)) {
|
||||
handCards.update(hand);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTrumpCard(Card trumpCard) {
|
||||
private void setTrump(Card trumpCard, Card.Suit trumpSuit) {
|
||||
this.trumpCard = trumpCard;
|
||||
this.trumpSuit = trumpSuit;
|
||||
if (trumpCardActor != null) {
|
||||
trumpCardActor.remove();
|
||||
}
|
||||
@ -291,42 +351,53 @@ public class GameScreen extends MenuScreen {
|
||||
trumpCardActor = new CardActor(trumpCard, atlas);
|
||||
}
|
||||
|
||||
var background = new Container<>();
|
||||
background.setBackground(new TextureRegionDrawable(data.uiskinAtlas.findRegion(UiskinAtlas.WHITE)));
|
||||
background.setColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
background.setFillParent(true);
|
||||
var group = new VerticalGroup().columnCenter().space(10f);
|
||||
|
||||
var screen = new Stack();
|
||||
screen.setFillParent(true);
|
||||
screen.add(background);
|
||||
var overlay = new Container<>(group);
|
||||
overlay.setBackground(this.overlay);
|
||||
overlay.setBounds(0, 0, WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
overlay.setTouchable(Touchable.enabled);
|
||||
|
||||
var group = new VerticalGroup().align(Align.center);
|
||||
screen.add(group);
|
||||
String text = switch (trumpSuit) {
|
||||
case YELLOW -> "The trump suit is [#ffff00]yellow[#ffffff].";
|
||||
case GREEN -> "The trump suit is [#00ff00]green[#ffffff].";
|
||||
case BLUE -> "The trump suit is [#0000ff]blue[#ffffff].";
|
||||
case RED -> "The trump suit is [#ff0000]red[#ffffff].";
|
||||
default -> "There is no trump suit.";
|
||||
};
|
||||
|
||||
var label = new Label("Determining trump", data.skin);
|
||||
var label = new Label(text, data.skin);
|
||||
label.getStyle().font.getData().markupEnabled = true;
|
||||
label.setFontScale(1.5f);
|
||||
group.addActor(label);
|
||||
group.addActor(trumpCardActor);
|
||||
|
||||
data.stage.addActor(overlay);
|
||||
data.stage.addAction(sequence(
|
||||
run(() -> data.stage.addActor(screen)),
|
||||
delay(5.0f),
|
||||
removeActor(label),
|
||||
addAction(moveTo(10,10, .25f), trumpCardActor),
|
||||
delay(.25f),
|
||||
addAction(alpha(0.0f, .1f, Interpolation.pow2Out), background),
|
||||
delay(.1f),
|
||||
run(() -> data.stage.addActor(trumpCardActor)),
|
||||
removeActor(screen)
|
||||
delay(2.0f),
|
||||
parallel(
|
||||
sequence(
|
||||
target(alpha(0.0f, .1f, Interpolation.pow2Out), overlay),
|
||||
removeActor(overlay)
|
||||
),
|
||||
sequence(
|
||||
removeActorSilently(trumpCardActor),
|
||||
target(changeParent(data.stage.getRoot()), trumpCardActor),
|
||||
target(moveTo(10,10, .25f), trumpCardActor)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
private void addPrediction(UUID player, int prediction) {
|
||||
addMessage(names.get(player) + " predicted " + prediction + ".");
|
||||
predictions.put(player, prediction);
|
||||
padOfTruth.setPrediction(players.indexOf(player), round, prediction);
|
||||
}
|
||||
|
||||
private void playCard(UUID player, Card card) {
|
||||
addMessage(names.get(player) + " played a card.");
|
||||
|
||||
var handCard = switch (card) {
|
||||
case CHANGELING_JESTER, CHANGELING_WIZARD -> Card.CHANGELING;
|
||||
case CLOUD_BLUE, CLOUD_RED, CLOUD_GREEN, CLOUD_YELLOW -> Card.CLOUD;
|
||||
@ -341,7 +412,7 @@ public class GameScreen extends MenuScreen {
|
||||
|
||||
CardActor actor;
|
||||
Seat seat;
|
||||
if (player.equals(self)) {
|
||||
if (self.equals(player)) {
|
||||
actor = handCards.remove(handCard);
|
||||
seat = Seat.BOTTOM;
|
||||
} else {
|
||||
@ -363,6 +434,28 @@ public class GameScreen extends MenuScreen {
|
||||
}
|
||||
}
|
||||
|
||||
private void setActivePlayer(UUID player, UserInputMessage.Action action) {
|
||||
if (activePlayer != null) {
|
||||
nameLabels.get(activePlayer.getKey()).getStyle().fontColor = Color.WHITE;
|
||||
}
|
||||
if (player == null && action == null) {
|
||||
activePlayer = null;
|
||||
} else {
|
||||
activePlayer = Pair.of(player, action);
|
||||
nameLabels.get(activePlayer.getKey()).getStyle().fontColor = Color.RED;
|
||||
}
|
||||
}
|
||||
|
||||
private void addMessage(String text) {
|
||||
var label = new Label(text, data.skin);
|
||||
label.addAction(sequence(
|
||||
delay(1.5f),
|
||||
alpha(0, 0.25f),
|
||||
removeActor()
|
||||
));
|
||||
messages.addActor(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
@ -373,45 +466,26 @@ public class GameScreen extends MenuScreen {
|
||||
if (serverMessage instanceof GameMessage gameMessage) {
|
||||
var observerMessage = gameMessage.getObserverMessage();
|
||||
if (observerMessage instanceof CardMessage card) {
|
||||
stack.add(Pair.of(card.getPlayer(), card.getCard()));
|
||||
playCard(card.getPlayer(), card.getCard());
|
||||
} else if (observerMessage instanceof TrickMessage trick) {
|
||||
stack.clear();
|
||||
tricks.computeIfAbsent(trick.getPlayer(), p -> new ArrayList<>()).add(trick.getCards());
|
||||
finishTrick(trick.getPlayer(), trick.getCards());
|
||||
} else if (observerMessage instanceof HandMessage hand) {
|
||||
var cards = hands.computeIfAbsent(hand.getPlayer(), p -> new ArrayList<>());
|
||||
cards.clear();
|
||||
cards.addAll(hand.getHand());
|
||||
setHand(hand.getPlayer(), hand.getHand());
|
||||
} else if (observerMessage instanceof ScoreMessage score) {
|
||||
var roundScores = scores.computeIfAbsent(round, r -> new HashMap<>());
|
||||
roundScores.putAll(score.getPoints());
|
||||
addScores(score.getPoints());
|
||||
} else if (observerMessage instanceof TrumpMessage trump) {
|
||||
trumpCard = trump.getCard();
|
||||
trumpSuit = trump.getSuit();
|
||||
//Todo update TrumpCardActor if trumpSuit != null and trumpCard != null
|
||||
setTrump(trump.getCard(), trump.getSuit());
|
||||
} else if (observerMessage instanceof PredictionMessage prediction) {
|
||||
predictions.put(prediction.getPlayer(), prediction.getPrediction());
|
||||
//TODO update table and label
|
||||
addPrediction(prediction.getPlayer(), prediction.getPrediction());
|
||||
} else if (observerMessage instanceof UserInputMessage userInput) {
|
||||
activePlayer = Pair.of(userInput.getPlayer(), userInput.getAction());
|
||||
setActivePlayer(userInput.getPlayer(), userInput.getAction());
|
||||
if (self.equals(userInput.getPlayer())) {
|
||||
// TODO do something
|
||||
}
|
||||
} else if (observerMessage instanceof StateMessage state) {
|
||||
switch (state.getState()) {
|
||||
case "starting_round" -> {
|
||||
round++;
|
||||
trick = -1;
|
||||
hands.clear();
|
||||
predictions.clear();
|
||||
tricks.clear();
|
||||
trumpSuit = null;
|
||||
trumpCard = null;
|
||||
}
|
||||
case "starting_trick" -> {
|
||||
trick++;
|
||||
stack.clear();
|
||||
activePlayer = null;
|
||||
}
|
||||
case "starting_round" -> startRound();
|
||||
case "starting_trick" -> startTrick();
|
||||
case "finished", "error" -> {
|
||||
// TODO do something
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ public abstract class MenuScreen implements Screen {
|
||||
|
||||
@Override
|
||||
public final void render(float delta) {
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
|
||||
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
data.extendViewport.apply(true);
|
||||
game.batch.setProjectionMatrix(data.extendViewport.getCamera().combined);
|
||||
|
@ -49,6 +49,12 @@
|
||||
"downFontColor": "dark_gold",
|
||||
"disabledFontColor" : "darker_gold"
|
||||
},
|
||||
"simple": {
|
||||
"font": "default-font",
|
||||
"fontColor": "white",
|
||||
"downFontColor": "light_gray",
|
||||
"disabledFontColor": "light_gray"
|
||||
},
|
||||
"toggle": {
|
||||
"down": "default-round-down",
|
||||
"up": "default-round",
|
||||
@ -125,6 +131,10 @@
|
||||
"font": "default-font",
|
||||
"fontColor": "white"
|
||||
},
|
||||
"enchanted": {
|
||||
"font": "enchanted",
|
||||
"fontColor": "gold"
|
||||
},
|
||||
"textfield": {
|
||||
"background": "textfield",
|
||||
"font": "default-font",
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 45 KiB |
@ -10,6 +10,7 @@ public class DesktopLauncher {
|
||||
config.setTitle("Wizard Jubilaeumsedition 2021");
|
||||
config.setForegroundFPS(60);
|
||||
config.setWindowSizeLimits(853, 480, -1, -1);
|
||||
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 32);
|
||||
new Lwjgl3Application(new WizardGame(), config);
|
||||
}
|
||||
}
|
||||
|