Spielscreen (#17)
parent
dbcc91cd61
commit
17cb0190c9
@ -0,0 +1,110 @@
|
|||||||
|
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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,124 @@
|
|||||||
|
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)));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
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)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
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();
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
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)));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
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