parent
7c3fa7d0d6
commit
d5bece96d1
@ -0,0 +1,29 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
public class ChangePredictionOverlay extends MakePredictionOverlay {
|
||||
|
||||
public ChangePredictionOverlay(GameScreen gameScreen, int round, int oldPrediction) {
|
||||
super(
|
||||
gameScreen,
|
||||
oldPrediction == 0 ? new int[] {oldPrediction + 1}
|
||||
: oldPrediction == round + 1 ? new int[] {oldPrediction - 1}
|
||||
: new int[] {oldPrediction - 1, oldPrediction + 1}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VerticalGroup createContent() {
|
||||
var root = super.createContent();
|
||||
|
||||
var card = new CardActor(Card.CLOUD, atlas);
|
||||
root.addActorAt(0, card);
|
||||
root.padTop(- CardActor.PREF_HEIGHT);
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class MakePredictionOverlay extends Overlay {
|
||||
|
||||
private final int[] values;
|
||||
private final TextButton[] buttons;
|
||||
|
||||
public MakePredictionOverlay(GameScreen gameScreen, int round) {
|
||||
this(gameScreen, IntStream.range(0, round + 2).toArray());
|
||||
}
|
||||
|
||||
protected MakePredictionOverlay(GameScreen gameScreen, int[] values) {
|
||||
super(gameScreen);
|
||||
this.values = values;
|
||||
this.buttons = new TextButton[values.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public VerticalGroup createContent() {
|
||||
var root = new VerticalGroup().columnCenter().space(10);
|
||||
|
||||
var prompt = new Label("Please make your prediction:", data.skin);
|
||||
var buttonGroup = new HorizontalGroup().space(20);
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
buttons[i] = new TextButton(String.valueOf(i), data.skin);
|
||||
buttonGroup.addActor(buttons[i]);
|
||||
}
|
||||
|
||||
buttonGroup.addListener(new ClickListener() {
|
||||
private boolean finished = false;
|
||||
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (finished) return;
|
||||
|
||||
finished = true;
|
||||
var target = event.getTarget();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (buttons[i] == target) {
|
||||
System.out.println(values[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getRoot().remove();
|
||||
}
|
||||
});
|
||||
|
||||
root.addActor(prompt);
|
||||
root.addActor(buttonGroup);
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
|
||||
public abstract class Overlay {
|
||||
|
||||
protected final MenuScreen.Data data;
|
||||
protected final TextureAtlas atlas;
|
||||
|
||||
private Container<?> root;
|
||||
private final Drawable background;
|
||||
|
||||
public Overlay(GameScreen gameScreen) {
|
||||
this.data = gameScreen.getData();
|
||||
this.atlas = gameScreen.getAtlas();
|
||||
this.background = gameScreen.getOverlay();
|
||||
}
|
||||
|
||||
protected abstract Actor createContent();
|
||||
|
||||
protected Container<?> getRoot() {
|
||||
if (root == null) {
|
||||
root = new Container<>(createContent());
|
||||
root.setBackground(background);
|
||||
root.setSize(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||
root.setTouchable(Touchable.enabled);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public void show(Stage stage) {
|
||||
stage.addActor(getRoot());
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class PickTrumpOverlay extends Overlay {
|
||||
|
||||
private final boolean allowNone;
|
||||
|
||||
private final EnumMap<Card.Suit, CardActor> cards = new EnumMap<>(Card.Suit.class);
|
||||
|
||||
public PickTrumpOverlay(GameScreen gameScreen, boolean allowNone) {
|
||||
super(gameScreen);
|
||||
this.allowNone = allowNone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor createContent() {
|
||||
var root = new VerticalGroup().columnCenter().space(10);
|
||||
|
||||
var prompt = new Label("Please choose the trump suit:", data.skin);
|
||||
var cardGroup = new HorizontalGroup().space(20);
|
||||
|
||||
cards.put(Card.Suit.RED, new CardActor(Card.Suit.RED, atlas));
|
||||
cards.put(Card.Suit.GREEN, new CardActor(Card.Suit.GREEN, atlas));
|
||||
cards.put(Card.Suit.BLUE, new CardActor(Card.Suit.BLUE, atlas));
|
||||
cards.put(Card.Suit.YELLOW, new CardActor(Card.Suit.YELLOW, atlas));
|
||||
if (allowNone) {
|
||||
cards.put(Card.Suit.NONE, new CardActor(Card.Suit.NONE, atlas));
|
||||
}
|
||||
|
||||
cards.values().forEach(cardGroup::addActor);
|
||||
|
||||
cardGroup.addListener(new ClickListener() {
|
||||
private boolean finished = false;
|
||||
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (finished) return;
|
||||
|
||||
finished = true;
|
||||
var target = event.getTarget();
|
||||
for (Card.Suit suit : Card.Suit.values()) {
|
||||
if (cards.get(suit) == target) {
|
||||
// TODO
|
||||
System.out.println(suit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
getRoot().remove();
|
||||
}
|
||||
});
|
||||
|
||||
root.addActor(prompt);
|
||||
root.addActor(cardGroup);
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
import static eu.jonahbauer.wizard.client.libgdx.actions.MyActions.*;
|
||||
|
||||
public class StartRoundOverlay extends Overlay {
|
||||
|
||||
private final int round;
|
||||
|
||||
public StartRoundOverlay(GameScreen gameScreen, int round) {
|
||||
super(gameScreen);
|
||||
this.round = round;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor createContent() {
|
||||
var root = new VerticalGroup().columnCenter().space(10f);
|
||||
|
||||
var label = new Label("Round " + (round + 1), data.skin, "enchanted");
|
||||
label.setFontScale(1.5f);
|
||||
root.addActor(label);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Stage stage) {
|
||||
var root = getRoot();
|
||||
stage.addActor(root);
|
||||
stage.addAction(sequence(
|
||||
delay(2.0f),
|
||||
target(alpha(0.0f, .1f, Interpolation.pow2Out), root),
|
||||
removeActor(root)
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.actors.game.overlay;
|
||||
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
import static eu.jonahbauer.wizard.client.libgdx.actions.MyActions.*;
|
||||
|
||||
public class TrumpOverlay extends Overlay {
|
||||
|
||||
private final String player;
|
||||
private final Card card;
|
||||
private final Card.Suit suit;
|
||||
|
||||
private final CardActor trumpCardActor;
|
||||
|
||||
public TrumpOverlay(GameScreen gameScreen, String player, Card card, Card.Suit suit) {
|
||||
super(gameScreen);
|
||||
this.player = player;
|
||||
this.card = card;
|
||||
this.suit = suit;
|
||||
this.trumpCardActor = gameScreen.getTrumpCardActor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor createContent() {
|
||||
var root = new VerticalGroup().columnCenter().space(10f);
|
||||
|
||||
String text;
|
||||
|
||||
if (player == null) {
|
||||
text = switch (suit) {
|
||||
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.";
|
||||
};
|
||||
} else {
|
||||
text = player + switch (suit) {
|
||||
case YELLOW -> " chose the trump suit [#ffff00]yellow[#ffffff].";
|
||||
case GREEN -> " chose the trump suit [#00ff00]green[#ffffff].";
|
||||
case BLUE -> " chose the trump suit [#0000ff]blue[#ffffff].";
|
||||
case RED -> " chose the trump suit [#ff0000]red[#ffffff].";
|
||||
default -> " has decided there will be no trump suit this round.";
|
||||
};
|
||||
}
|
||||
|
||||
var label = new Label(text, data.skin);
|
||||
label.getStyle().font.getData().markupEnabled = true;
|
||||
label.setFontScale(1.5f);
|
||||
|
||||
root.addActor(label);
|
||||
root.addActor(trumpCardActor);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Stage stage) {
|
||||
var root = getRoot();
|
||||
|
||||
trumpCardActor.setCard(card);
|
||||
|
||||
stage.addActor(root);
|
||||
stage.addAction(sequence(
|
||||
delay(2.0f),
|
||||
parallel(
|
||||
sequence(
|
||||
target(alpha(0.0f, .1f, Interpolation.pow2Out), root),
|
||||
removeActor(root)
|
||||
),
|
||||
sequence(
|
||||
removeActorSilently(trumpCardActor),
|
||||
target(changeParent(stage.getRoot()), trumpCardActor),
|
||||
target(moveTo(10, 10, .25f), trumpCardActor)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
import eu.jonahbauer.wizard.common.messages.client.InteractionMessage;
|
||||
import eu.jonahbauer.wizard.common.messages.player.PredictMessage;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.removeActor;
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.run;
|
||||
|
||||
public class ChangePredictionScreen extends EventScreen {
|
||||
|
||||
final int round;
|
||||
final UUID player;
|
||||
final Map<UUID, Integer> predictions;
|
||||
public ChangePredictionScreen(MenuScreen.Data data, int round, UUID player, Map<UUID, Integer> predictions) {
|
||||
super(data);
|
||||
this.round = round;
|
||||
this.player = player;
|
||||
this.predictions = predictions;
|
||||
var labelTop = new Label("One of your tricks contains the Card Cloud.", data.skin);
|
||||
labelTop.setFontScale(2.0f);
|
||||
group.addActor(labelTop);
|
||||
showEventScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEventScreen() {
|
||||
|
||||
ChangeListener changeListener = new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if(actor instanceof TextButton textButton) {
|
||||
int chosenPrediction = Integer.parseInt(textButton.getText().toString());
|
||||
//Nur zur Demo - eigtl. Senden von predictMessage und Auswerten vin predictionMessage
|
||||
predictions.put(player, Integer.parseInt(textButton.getText().toString()));
|
||||
data.stage.addAction(removeActor(screen));
|
||||
new InteractionMessage(new PredictMessage(chosenPrediction));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (predictions.get(player) != null) {
|
||||
int i = predictions.get(player);
|
||||
var labelZeroPrediction = new Label("Your original prediction is", data.skin);
|
||||
labelZeroPrediction.setFontScale(2.0f);
|
||||
group.addActor(labelZeroPrediction);
|
||||
var originalPrediction = new Label(i + "", data.skin, "enchanted");
|
||||
group.addActor(originalPrediction);
|
||||
var labelPredictionUpper = new Label("According to the game rules your prediction", data.skin);
|
||||
labelPredictionUpper.setFontScale(2.0f);
|
||||
group.addActor(labelPredictionUpper);
|
||||
if (i == 0 || i == round) {
|
||||
var labelPredictionLower = new Label("must " + (i == 0 ? "increase" : "decrease") + " by one to", data.skin);
|
||||
labelPredictionLower.setFontScale(2.0f);
|
||||
group.addActor(labelPredictionLower);
|
||||
var newPrediction = new Label((i == 0 ? (i + 1) : (i - 1)) + "", data.skin, "enchanted");
|
||||
group.addActor(newPrediction);
|
||||
var okButton = new TextButton("OK", data.skin);
|
||||
okButton.addListener(
|
||||
new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
data.stage.addAction(removeActor(screen));
|
||||
}
|
||||
}
|
||||
);
|
||||
group.addActor(okButton);
|
||||
screen.addActor(group);
|
||||
if (i == 0) {
|
||||
//nur Demo
|
||||
predictions.put(player, ++i);
|
||||
//eigtl.
|
||||
new InteractionMessage(new PredictMessage(i));
|
||||
} else {
|
||||
//nur Demo
|
||||
predictions.put(player, --i);
|
||||
//eigtl.
|
||||
new InteractionMessage(new PredictMessage(i));
|
||||
}
|
||||
} else {
|
||||
var labelPredictionMiddle = new Label("must increase or decrease by one.", data.skin);
|
||||
labelPredictionMiddle.setFontScale(2.0f);
|
||||
group.addActor(labelPredictionMiddle);
|
||||
var labelPredictionLower = new Label("Please choose one of these two options", data.skin);
|
||||
labelPredictionLower.setFontScale(2.0f);
|
||||
group.addActor(labelPredictionLower);
|
||||
var horizontalGroup = new HorizontalGroup();
|
||||
horizontalGroup.space(50.0f);
|
||||
var decreaseButton = new TextButton((i - 1) + "", data.skin);
|
||||
var increaseButton = new TextButton((i + 1) + "", data.skin);
|
||||
decreaseButton.addListener(changeListener);
|
||||
increaseButton.addListener(changeListener);
|
||||
horizontalGroup.addActor(decreaseButton);
|
||||
horizontalGroup.addActor(increaseButton);
|
||||
group.addActor(horizontalGroup);
|
||||
screen.addActor(group);
|
||||
}
|
||||
data.stage.addAction(run(() -> data.stage.addActor(screen)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,124 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
import eu.jonahbauer.wizard.common.messages.client.InteractionMessage;
|
||||
import eu.jonahbauer.wizard.common.messages.player.PickTrumpMessage;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class ChooseTrumpScreen extends EventScreen {
|
||||
|
||||
private CardActor trumpCardActor;
|
||||
private Card trumpCard;
|
||||
private TextureAtlas atlas;
|
||||
public ChooseTrumpScreen(MenuScreen.Data data, CardActor trumpCardActor, Card trumpCard, TextureAtlas atlas) {
|
||||
super(data);
|
||||
this.trumpCardActor = trumpCardActor;
|
||||
this.trumpCard = trumpCard;
|
||||
this.atlas = atlas;
|
||||
showEventScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEventScreen() {
|
||||
BitmapFont font = data.skin.getFont("default-font");
|
||||
font.getData().setScale(1.5f);
|
||||
|
||||
var verticalGroup = new VerticalGroup().align(Align.center);
|
||||
screen.add(verticalGroup);
|
||||
|
||||
var labelTop = new Label("The determined Trump Card Actor is: ", data.skin);
|
||||
verticalGroup.addActor(labelTop);
|
||||
verticalGroup.addActor(trumpCardActor);
|
||||
|
||||
var labelMiddle = new Label("Please choose a Trump Color", data.skin);
|
||||
var horizontalGroupBottom = new HorizontalGroup();
|
||||
horizontalGroupBottom.space(40.0f);
|
||||
horizontalGroupBottom.padTop(30.0f);
|
||||
font.getData().setScale(2.5f);
|
||||
var chooseGreen = new TextButton("Green", data.skin, "toggle");
|
||||
chooseGreen.setColor(Card.Suit.GREEN.getRed(), Card.Suit.GREEN.getGreen(), Card.Suit.GREEN.getBlue(),Card.Suit.GREEN.getAlpha());
|
||||
horizontalGroupBottom.addActor(chooseGreen);
|
||||
var chooseBlue = new TextButton("Blue", data.skin, "toggle");
|
||||
chooseBlue.setColor(Card.Suit.BLUE.getRed(), Card.Suit.BLUE.getGreen(), Card.Suit.BLUE.getBlue(),Card.Suit.BLUE.getAlpha());
|
||||
horizontalGroupBottom.addActor(chooseBlue);
|
||||
var chooseYellow = new TextButton("Yellow", data.skin, "toggle");
|
||||
chooseYellow.setColor(Card.Suit.YELLOW.getRed(), Card.Suit.YELLOW.getGreen(), Card.Suit.YELLOW.getBlue(),Card.Suit.YELLOW.getAlpha());
|
||||
horizontalGroupBottom.addActor(chooseYellow);
|
||||
var chooseRed = new TextButton("Red", data.skin, "toggle");
|
||||
chooseRed.setColor(Card.Suit.RED.getRed(), Card.Suit.RED.getGreen(), Card.Suit.RED.getBlue(),Card.Suit.RED.getAlpha());
|
||||
horizontalGroupBottom.addActor(chooseRed);
|
||||
if(trumpCard == Card.WEREWOLF) {
|
||||
var chooseNone = new Label("Kein Trumpf", data.skin);
|
||||
chooseNone.setColor(Card.Suit.NONE.getRed(), Card.Suit.NONE.getGreen(), Card.Suit.NONE.getBlue(),Card.Suit.NONE.getAlpha());
|
||||
horizontalGroupBottom.addActor(chooseNone);
|
||||
}
|
||||
verticalGroup.addActor(labelMiddle);
|
||||
verticalGroup.addActor(horizontalGroupBottom);
|
||||
|
||||
var chosenLabel = new Label("Sie haben gewählt", data.skin);
|
||||
|
||||
ChangeListener changeListener = new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Card.Suit suit;
|
||||
if(actor instanceof TextButton textButton) {
|
||||
switch (textButton.getLabel().getText().toString()) {
|
||||
//TODO - Eigene Karte nur mit Trumpfarbe? - Karte für keinen Trumpf?
|
||||
//trumpCardActor.setCard(Card.values()[Card.XY.ordinal()]);
|
||||
case "Green" -> {
|
||||
trumpCardActor.setCard(Card.values()[0]);
|
||||
suit = Card.Suit.GREEN;
|
||||
}
|
||||
case "Yellow" -> {
|
||||
trumpCardActor.setCard(Card.values()[1]);
|
||||
suit = Card.Suit.YELLOW;
|
||||
}
|
||||
case "Blue" -> {
|
||||
trumpCardActor.setCard(Card.values()[2]);
|
||||
suit = Card.Suit.BLUE;
|
||||
}
|
||||
case "Red" -> {
|
||||
trumpCardActor.setCard(Card.values()[3]);
|
||||
suit = Card.Suit.RED;
|
||||
}
|
||||
case "None" -> {
|
||||
trumpCardActor.setCard(Card.values()[4]);
|
||||
suit = Card.Suit.NONE;
|
||||
}
|
||||
default -> throw new AssertionError();
|
||||
}
|
||||
data.stage.addAction(sequence(
|
||||
removeActor(horizontalGroupBottom),
|
||||
removeActor(labelMiddle),
|
||||
removeActor(labelTop),
|
||||
run(() -> verticalGroup.addActorAt(0, chosenLabel)),
|
||||
delay(2.0f),
|
||||
removeActor(chosenLabel),
|
||||
addAction(moveTo(10,10, 0.25f), trumpCardActor),
|
||||
delay(.1f),
|
||||
addAction(alpha(0.0f, .1f, Interpolation.pow2Out), background),
|
||||
delay(.1f),
|
||||
run(() -> data.stage.addActor(trumpCardActor)),
|
||||
removeActor(screen)));
|
||||
|
||||
new InteractionMessage(new PickTrumpMessage(suit));
|
||||
}
|
||||
}
|
||||
};
|
||||
horizontalGroupBottom.addListener(changeListener);
|
||||
data.stage.addAction(run(() -> data.stage.addActor(screen)));
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import eu.jonahbauer.wizard.client.libgdx.actors.game.CardActor;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
import eu.jonahbauer.wizard.common.model.Card;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class ChosenTrumpByOtherScreen extends EventScreen {
|
||||
|
||||
private final UUID player;
|
||||
private final Map<UUID, String> names;
|
||||
private final Card.Suit suit;
|
||||
private CardActor trumpCardActor;
|
||||
private final TextureAtlas atlas;
|
||||
public ChosenTrumpByOtherScreen(MenuScreen.Data data, UUID player, Map<UUID, String> names, Card.Suit suit,
|
||||
CardActor trumpCardActor, TextureAtlas atlas) {
|
||||
super(data);
|
||||
this.player = player;
|
||||
this.names = names;
|
||||
this.suit = suit;
|
||||
this.trumpCardActor = trumpCardActor;
|
||||
this.atlas = atlas;
|
||||
showEventScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEventScreen() {
|
||||
var playerName = new Label(names.get(player) + " has chosen the trump color: ", data.skin);
|
||||
playerName.setFontScale(1.5f);
|
||||
group.addActor(playerName);
|
||||
Label colorLabel;
|
||||
switch (suit) {
|
||||
case GREEN -> {
|
||||
colorLabel = new Label(Card.Suit.GREEN.toString(), data.skin);
|
||||
colorLabel.setColor(Card.Suit.GREEN.getRed(), Card.Suit.GREEN.getGreen(), Card.Suit.GREEN.getBlue(),Card.Suit.GREEN.getAlpha());
|
||||
}
|
||||
case BLUE -> {
|
||||
colorLabel = new Label(Card.Suit.BLUE.toString(), data.skin);
|
||||
colorLabel.setColor(Card.Suit.BLUE.getRed(), Card.Suit.BLUE.getGreen(), Card.Suit.BLUE.getBlue(),Card.Suit.BLUE.getAlpha());
|
||||
}
|
||||
case YELLOW -> {
|
||||
colorLabel = new Label(Card.Suit.YELLOW.toString(), data.skin);
|
||||
colorLabel.setColor(Card.Suit.YELLOW.getRed(), Card.Suit.YELLOW.getGreen(), Card.Suit.YELLOW.getBlue(),Card.Suit.YELLOW.getAlpha());
|
||||
}
|
||||
case RED -> {
|
||||
colorLabel = new Label(Card.Suit.RED.toString(), data.skin);
|
||||
colorLabel.setColor(Card.Suit.RED.getRed(), Card.Suit.RED.getGreen(), Card.Suit.RED.getBlue(),Card.Suit.RED.getAlpha());
|
||||
}
|
||||
case NONE -> {
|
||||
colorLabel = new Label(Card.Suit.NONE.toString(), data.skin);
|
||||
colorLabel.setColor(Card.Suit.NONE.getRed(), Card.Suit.NONE.getGreen(), Card.Suit.NONE.getBlue(),Card.Suit.NONE.getAlpha());
|
||||
}
|
||||
default -> throw new AssertionError();
|
||||
}
|
||||
group.addActor(colorLabel);
|
||||
|
||||
//TODO - Bild/Region für ausgewählte Farbe
|
||||
//Card trumpCard = Card.values()[suit.ordinal()];
|
||||
//trumpCardActor.setCard(Card.values()[suit.ordinal()]);
|
||||
Card trumpCard = Card.BLUE_1;
|
||||
|
||||
if (trumpCardActor != null) {
|
||||
trumpCardActor.setCard(trumpCard);
|
||||
} else {
|
||||
trumpCardActor = new CardActor(trumpCard, atlas);
|
||||
}
|
||||
|
||||
group.addActor(trumpCardActor);
|
||||
screen.addActor(group);
|
||||
|
||||
data.stage.addAction(sequence(
|
||||
run(() -> data.stage.addActor(screen)),
|
||||
delay(2.0f),
|
||||
removeActor(playerName),
|
||||
removeActor(colorLabel),
|
||||
addAction(moveTo(10,10, 0.25f), trumpCardActor),
|
||||
delay(.1f),
|
||||
addAction(alpha(0.0f, .1f, Interpolation.pow2Out), background),
|
||||
delay(.1f),
|
||||
run(() -> data.stage.addActor(trumpCardActor)),
|
||||
removeActor(screen)
|
||||
));
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
|
||||
public abstract class EventScreen {
|
||||
|
||||
protected Container<Actor> background;
|
||||
protected Stack screen;
|
||||
protected VerticalGroup group;
|
||||
protected MenuScreen.Data data;
|
||||
|
||||
public EventScreen(MenuScreen.Data data) {
|
||||
this.data = data;
|
||||
this.background = createBackground();
|
||||
this.screen = createStack(background);
|
||||
this.group = createGroup();
|
||||
}
|
||||
|
||||
public Container<Actor> createBackground() {
|
||||
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);
|
||||
background.setTouchable(Touchable.enabled);
|
||||
return background;
|
||||
}
|
||||
|
||||
public Stack createStack(Container<Actor> background) {
|
||||
var stack = new Stack();
|
||||
stack.setFillParent(true);
|
||||
stack.add(background);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public VerticalGroup createGroup() {
|
||||
return new VerticalGroup().align(Align.center);
|
||||
}
|
||||
|
||||
public abstract void showEventScreen();
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
import eu.jonahbauer.wizard.common.messages.client.InteractionMessage;
|
||||
import eu.jonahbauer.wizard.common.messages.player.PredictMessage;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.removeActor;
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.run;
|
||||
|
||||
public class MakePredictionScreen extends EventScreen {
|
||||
|
||||
int round;
|
||||
private UUID player;
|
||||
private final Map<UUID, Integer> predictions;
|
||||
public MakePredictionScreen(MenuScreen.Data data, int round, UUID player,Map<UUID, Integer> predictions) {
|
||||
super(data);
|
||||
this.round = round;
|
||||
this.player = player;
|
||||
this.predictions = predictions;
|
||||
showEventScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEventScreen() {
|
||||
|
||||
if(round == -1)
|
||||
return;
|
||||
|
||||
var label = new Label("Please chose your prediction", data.skin);
|
||||
label.setFontScale(2.0f);
|
||||
group.addActor(label);
|
||||
|
||||
var changeListener = new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if(actor instanceof TextButton textButton) {
|
||||
int chosenPrediction = Integer.parseInt(textButton.getText().toString());
|
||||
predictions.put(player, chosenPrediction);
|
||||
data.stage.addAction(removeActor(screen));
|
||||
new InteractionMessage(new PredictMessage(chosenPrediction));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var horizontalGroup = new HorizontalGroup();
|
||||
horizontalGroup.space(30.0f);
|
||||
for(int i = 0; i <= round; i++) {
|
||||
var button = new TextButton(i + "", data.skin);
|
||||
horizontalGroup.addActor(button);
|
||||
button.addListener(changeListener);
|
||||
}
|
||||
group.addActor(horizontalGroup);
|
||||
screen.addActor(group);
|
||||
data.stage.addAction(run(() -> data.stage.addActor(screen)));
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.screens.eventscreens;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import eu.jonahbauer.wizard.client.libgdx.screens.MenuScreen;
|
||||
|
||||
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
||||
|
||||
public class PredictionByOtherScreen extends EventScreen {
|
||||
|
||||
private String name;
|
||||
private int prediction;
|
||||
|
||||
public PredictionByOtherScreen(MenuScreen.Data data, String name, int prediction) {
|
||||
super(data);
|
||||
this.name = name;
|
||||
this.prediction = prediction;
|
||||
group.space(10.0f);
|
||||
BitmapFont font = data.skin.getFont("default-font");
|
||||
font.getData().setScale(1.5f);
|
||||
showEventScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEventScreen() {
|
||||
var playerName = new Label(name + "'s preditction is: ", data.skin);
|
||||
group.addActor(playerName);
|
||||
var predictionLabel = new Label(prediction + "", data.skin, "enchanted");
|
||||
group.addActor(predictionLabel);
|
||||
screen.addActor(group);
|
||||
|
||||
data.stage.addAction(sequence(
|
||||
run(() -> data.stage.addActor(screen)),
|
||||
delay(2.5f),
|
||||
removeActor(screen)
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue