mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Auto reformaterer alle klasser og tester for visuelt grensesnitt
This commit is contained in:
parent
afe9e67969
commit
a19e616257
@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import inf112.fiasko.roborally.networking.RoboRallyClient;
|
||||
import inf112.fiasko.roborally.networking.RoboRallyServer;
|
||||
import inf112.fiasko.roborally.objects.IRoboRallyGame;
|
||||
import inf112.fiasko.roborally.objects.RoboRallyGame;
|
||||
|
||||
/**
|
||||
* This class acts as a wrapper around the different screens of the game
|
||||
@ -15,7 +15,7 @@ public class RoboRallyWrapper extends Game {
|
||||
public SpriteBatch batch;
|
||||
public BitmapFont font;
|
||||
public ScreenManager screenManager;
|
||||
public IRoboRallyGame roboRallyGame;
|
||||
public RoboRallyGame roboRallyGame;
|
||||
public RoboRallyServer server;
|
||||
public RoboRallyClient client;
|
||||
|
||||
@ -35,6 +35,7 @@ public class RoboRallyWrapper extends Game {
|
||||
|
||||
/**
|
||||
* Quits the game after logging the input as an error
|
||||
*
|
||||
* @param string The error causing the game to quit
|
||||
*/
|
||||
public void quit(String string) {
|
||||
|
@ -1,7 +1,14 @@
|
||||
package inf112.fiasko.roborally.gamewrapper;
|
||||
|
||||
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.*;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.BoardActiveScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.CardChoiceScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.IPAddressScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.LoadingScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.LobbyScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.PowerDownScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.StartMenuScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.UsernameScreen;
|
||||
import inf112.fiasko.roborally.gamewrapper.screens.WinnerScreen;
|
||||
|
||||
/**
|
||||
* Keeps track of screen instances
|
||||
@ -26,6 +33,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the winner screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A winner screen instance
|
||||
*/
|
||||
@ -38,6 +46,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the power down screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A power down screen instance
|
||||
*/
|
||||
@ -50,6 +59,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the lobby screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A lobby screen instance
|
||||
*/
|
||||
@ -62,6 +72,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the ip address screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return An ip address screen instance
|
||||
*/
|
||||
@ -74,6 +85,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the username screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A username screen instance
|
||||
*/
|
||||
@ -86,6 +98,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the start menu screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A start menu screen instance
|
||||
*/
|
||||
@ -95,6 +108,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the loading screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A loading screen instance
|
||||
*/
|
||||
@ -107,6 +121,7 @@ public class ScreenManager {
|
||||
|
||||
/**
|
||||
* Gets an instance of the board active screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally launcher instance to use
|
||||
* @return A board active screen instance
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@ public class SimpleButton {
|
||||
|
||||
/**
|
||||
* Instantiates a new simple button
|
||||
*
|
||||
* @param text The text to display on the button
|
||||
* @param font The font to use to draw button text
|
||||
*/
|
||||
@ -29,6 +30,7 @@ public class SimpleButton {
|
||||
|
||||
/**
|
||||
* Gets the button generated
|
||||
*
|
||||
* @return A button
|
||||
*/
|
||||
public TextButton getButton() {
|
||||
|
@ -14,8 +14,8 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||
import inf112.fiasko.roborally.gamewrapper.RoboRallyWrapper;
|
||||
import inf112.fiasko.roborally.objects.IDrawableObject;
|
||||
import inf112.fiasko.roborally.objects.IRoboRallyGame;
|
||||
import inf112.fiasko.roborally.objects.DrawableObject;
|
||||
import inf112.fiasko.roborally.objects.RoboRallyGame;
|
||||
import inf112.fiasko.roborally.utility.IOUtil;
|
||||
import inf112.fiasko.roborally.utility.TextureConverterUtil;
|
||||
|
||||
@ -27,19 +27,19 @@ import java.util.List;
|
||||
public class BoardActiveScreen extends AbstractScreen implements InputProcessor {
|
||||
private final RoboRallyWrapper roboRallyWrapper;
|
||||
private final OrthographicCamera camera;
|
||||
private IRoboRallyGame debugGame;
|
||||
|
||||
private final int tileDimensions = 64;
|
||||
private final int viewPortWidth = 12 * tileDimensions;
|
||||
private final int viewPortHeight = 12 * tileDimensions;
|
||||
private final Viewport viewport;
|
||||
private RoboRallyGame debugGame;
|
||||
private float cameraZoom = 1;
|
||||
private int cameraX = 0;
|
||||
private int cameraY = 0;
|
||||
private Vector2 lastTouch;
|
||||
private final int viewPortWidth = 12 * tileDimensions;
|
||||
private final int viewPortHeight = 12 * tileDimensions;
|
||||
private final Viewport viewport;
|
||||
|
||||
/**
|
||||
* Instantiates a new board active screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public BoardActiveScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
@ -79,8 +79,7 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
|
||||
// Checks if there has been found a winning player and then changes the screen to display the winning screen
|
||||
if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.GAME_IS_WON) {
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getWinnerScreen(roboRallyWrapper));
|
||||
}
|
||||
else if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.CHOOSING_STAY_IN_POWER_DOWN){
|
||||
} else if (roboRallyWrapper.roboRallyGame.getGameState() == GameState.CHOOSING_STAY_IN_POWER_DOWN) {
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
|
||||
}
|
||||
}
|
||||
@ -100,7 +99,7 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
|
||||
@Override
|
||||
public boolean keyUp(int keyCode) {
|
||||
if (keyCode == Input.Keys.HOME) {
|
||||
IRoboRallyGame temp = roboRallyWrapper.roboRallyGame;
|
||||
RoboRallyGame temp = roboRallyWrapper.roboRallyGame;
|
||||
roboRallyWrapper.roboRallyGame = debugGame;
|
||||
this.debugGame = temp;
|
||||
return true;
|
||||
@ -170,12 +169,13 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
|
||||
|
||||
/**
|
||||
* Renders all drawable objects on the board
|
||||
*
|
||||
* @param batch The sprite batch to use for drawing
|
||||
*/
|
||||
private void drawBoard(SpriteBatch batch) {
|
||||
List<IDrawableObject> elementsToDraw =
|
||||
List<DrawableObject> elementsToDraw =
|
||||
IOUtil.getDrawableObjectsFromGame(roboRallyWrapper.roboRallyGame, tileDimensions, tileDimensions);
|
||||
for (IDrawableObject object : elementsToDraw) {
|
||||
for (DrawableObject object : elementsToDraw) {
|
||||
TextureRegion objectTextureRegion = object.getTexture();
|
||||
batch.draw(objectTextureRegion.getTexture(), object.getXPosition(), object.getYPosition(),
|
||||
(float) object.getWidth() / 2, (float) object.getHeight() / 2,
|
||||
@ -199,6 +199,7 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
|
||||
|
||||
/**
|
||||
* Translates x and y coordinates according to the camera's direction
|
||||
*
|
||||
* @param x The x coordinate to translate
|
||||
* @param y The y coordinate to translate
|
||||
* @return A list containing the translated coordinates of x and y
|
||||
|
@ -47,6 +47,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
|
||||
/**
|
||||
* Instantiates a new card choice screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public CardChoiceScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
@ -82,6 +83,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
|
||||
/**
|
||||
* Generates a listener for confirming cards
|
||||
*
|
||||
* @return An input listener
|
||||
*/
|
||||
private InputListener getConfirmListener() {
|
||||
@ -104,6 +106,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
|
||||
/**
|
||||
* Gets a list of programming cards from the player's chosen cards
|
||||
*
|
||||
* @return A list of programming cards
|
||||
*/
|
||||
private List<ProgrammingCard> getCards() {
|
||||
@ -114,6 +117,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
|
||||
/**
|
||||
* Calculates positions for cards in the given deck
|
||||
*
|
||||
* @param deck A deck containing cards which can be chosen
|
||||
*/
|
||||
private void generateCards(ProgrammingCardDeck deck) {
|
||||
@ -188,6 +192,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
|
||||
/**
|
||||
* Draws the symbol on a card
|
||||
*
|
||||
* @param cardRectangle The card rectangle to draw
|
||||
*/
|
||||
private void drawCardSymbol(CardRectangle cardRectangle) {
|
||||
|
@ -13,6 +13,7 @@ public class CardRectangle {
|
||||
|
||||
/**
|
||||
* Instantiates a new card rectangle
|
||||
*
|
||||
* @param rectangle The rectangle of this card rectangle
|
||||
* @param card The card of this card rectangle
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@ public class IPAddressScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new ip address screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public IPAddressScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
|
@ -19,6 +19,7 @@ public class LoadingScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new loading screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public LoadingScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
@ -50,6 +51,7 @@ public class LoadingScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Changes to another screen depending on which state the game is in
|
||||
*
|
||||
* @param gameState The current state of the game
|
||||
*/
|
||||
private void handleScreenChange(GameState gameState) {
|
||||
@ -62,7 +64,12 @@ public class LoadingScreen extends AbstractScreen {
|
||||
break;
|
||||
case CHOOSING_CARDS:
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getCardChoiceScreen(this.roboRallyWrapper));
|
||||
break; }
|
||||
break;
|
||||
default:
|
||||
if (gameState != GameState.LOADING) {
|
||||
System.out.println("Don't know what to do with " + gameState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,7 @@ public class LobbyScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new lobby screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public LobbyScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
|
@ -27,6 +27,7 @@ public class PowerDownScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new power down screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public PowerDownScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
@ -76,6 +77,7 @@ public class PowerDownScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Sends power down status to the server
|
||||
*
|
||||
* @param bool Whether the player wants to go/stay in power down
|
||||
*/
|
||||
private void sendPowerDownStatus(boolean bool) {
|
||||
|
@ -28,6 +28,7 @@ public class StartMenuScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new start menu screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public StartMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
|
@ -26,6 +26,7 @@ public class UsernameScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new username screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public UsernameScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
@ -70,6 +71,7 @@ public class UsernameScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Checks whether the username is invalid
|
||||
*
|
||||
* @param userName The username the user wants
|
||||
* @return False if the username can be used
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ public class WinnerScreen extends AbstractScreen {
|
||||
|
||||
/**
|
||||
* Instantiates a new winner screen
|
||||
*
|
||||
* @param roboRallyWrapper The Robo Rally wrapper which is parent of this screen
|
||||
*/
|
||||
public WinnerScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user