From 37ea6086bf0b5d4a1c7ee5af2ea3ee360ee50449 Mon Sep 17 00:00:00 2001 From: heurtet Date: Sat, 29 May 2021 11:10:54 +0200 Subject: [PATCH] ecran de fin --- core/src/sagittarius/view/CreditScreen.java | 17 ++++ core/src/sagittarius/view/EndScreen.java | 95 +++++++++++++++++++++ core/src/sagittarius/view/GameScreen.java | 2 +- 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 core/src/sagittarius/view/EndScreen.java diff --git a/core/src/sagittarius/view/CreditScreen.java b/core/src/sagittarius/view/CreditScreen.java index 0d22579..835c052 100644 --- a/core/src/sagittarius/view/CreditScreen.java +++ b/core/src/sagittarius/view/CreditScreen.java @@ -5,6 +5,8 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; import com.kotcrab.vis.ui.VisUI; import com.kotcrab.vis.ui.widget.VisTable; +import com.kotcrab.vis.ui.widget.VisTextButton; + import sagittarius.view.ButtonSounded.*; import sagittarius.SagittariusGame; @@ -33,6 +35,11 @@ public class CreditScreen extends BaseScreen { table.setFillParent(true); uiStage.addActor(table); + VisTextButton laurent = new VisTextButton("Laurent Fainsin"); + VisTextButton damien = new VisTextButton("Damien Guillotin"); + VisTextButton tom = new VisTextButton("Tom Heurtebise"); + VisTextButton pierre = new VisTextButton("Pierre-Eliot Jourdan"); + VisTextButton joan = new VisTextButton("Johan Guillemin"); // go back button @@ -45,6 +52,16 @@ public class CreditScreen extends BaseScreen { } }); + table.add(laurent).width(300); + table.row(); + table.add(damien).width(300); + table.row(); + table.add(tom).width(300); + table.row(); + table.add(pierre).width(300); + table.row(); + table.add(joan).width(300); + table.row(); table.add(returnButton).width(150); table.row(); } diff --git a/core/src/sagittarius/view/EndScreen.java b/core/src/sagittarius/view/EndScreen.java new file mode 100644 index 0000000..81f77b6 --- /dev/null +++ b/core/src/sagittarius/view/EndScreen.java @@ -0,0 +1,95 @@ +package sagittarius.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.TextArea; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.ui.TextField; +import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; +import com.badlogic.gdx.utils.FloatArray; +import com.kotcrab.vis.ui.VisUI; +import com.kotcrab.vis.ui.widget.VisTable; +import com.kotcrab.vis.ui.widget.VisTextArea; +import com.kotcrab.vis.ui.widget.VisTextButton; +import com.kotcrab.vis.ui.widget.VisTextField; +import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel; +import sagittarius.view.ButtonSounded.*; + + +import sagittarius.SagittariusGame; + +public class EndScreen extends BaseScreen { + + @Override + public void initialize() { + + if (!SagittariusGame.disableMusic) { + SagittariusGame.music.stop(); + SagittariusGame.music = + Gdx.audio.newMusic(Gdx.files.internal("sounds/music/resumeMenu_music.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.setVolume(SagittariusGame.musicVolume); + SagittariusGame.music.play(); + } + Gdx.input.setInputProcessor(uiStage); + + // Table creation + VisTable table = new VisTable(true); + table.setFillParent(true); + uiStage.addActor(table); + + // Winner display + String win = GameScreen.playerCurrent.getColor().toString(); + VisTextButton winnerDisplay = new VisTextButton(win); + + // Restart button + ButtonTextSounded restartButton = new ButtonTextSounded("Restart"); + restartButton.addListener(new ActorGestureListener() { + @Override + public void tap(InputEvent event, float x, float y, int count, int button) { + super.tap(event, x, y, count, button); + + if (!SagittariusGame.disableMusic) { + SagittariusGame.music.stop(); + SagittariusGame.music = + Gdx.audio.newMusic(Gdx.files.internal("sounds/music/game_music.mp3")); + SagittariusGame.music.setLooping(true); + SagittariusGame.music.setVolume(SagittariusGame.musicVolume); + SagittariusGame.music.play(); + } + SagittariusGame.setActiveScreen(new GameScreen()); + } + + }); + + // go back to main menu + ButtonTextSounded returnMain = new ButtonTextSounded("Main Menu"); + returnMain.addListener(new ActorGestureListener() { + @Override + public void tap(InputEvent event, float x, float y, int count, int button) { + super.tap(event, x, y, count, button); + SagittariusGame.setActiveScreen(new StartScreen()); + } + }); + + // Table structure + table.add(winnerDisplay).width(250); + table.row(); + table.add(restartButton).width(250); + table.row(); + table.add(returnMain).width(250); + } + + @Override + public void update(float dt) {} + + @Override + public void dispose() { + VisUI.dispose(); + super.dispose(); + } + +} diff --git a/core/src/sagittarius/view/GameScreen.java b/core/src/sagittarius/view/GameScreen.java index 934d98f..26d9483 100644 --- a/core/src/sagittarius/view/GameScreen.java +++ b/core/src/sagittarius/view/GameScreen.java @@ -130,7 +130,7 @@ public class GameScreen extends BaseScreen implements InputProcessor { worldCursor = new Vector2(unprojectedCursor.x, unprojectedCursor.y); if (players.getChildren().size <= 1) { - SagittariusGame.setActiveScreen(new StartScreen()); + SagittariusGame.setActiveScreen(new EndScreen()); } // camera zoom using keys