diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameMode.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameMode.java new file mode 100644 index 0000000000000000000000000000000000000000..1979fc24fa3fbaf955b93b4b53942edfd080080c --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameMode.java @@ -0,0 +1,6 @@ +package de.hdm_stuttgart.battlearena.Controller.Enum; + +public enum GameMode { + LOCAL, + NETWORK +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java new file mode 100644 index 0000000000000000000000000000000000000000..1ea713b41a90fa593348760d6a6be8c9f0ed1a62 --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/Enum/GameState.java @@ -0,0 +1,9 @@ +package de.hdm_stuttgart.battlearena.Controller.Enum; + +public enum GameState { + MENU, + PAUSE, + PLAYING, + LOST, + WON +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java index 2d90bb00e2c3503261084d7acf6b1dfd98593c61..42f1f0f879960aba93f5d68cb53aaec6be3116ca 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -1,5 +1,8 @@ package de.hdm_stuttgart.battlearena.Controller; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameMode; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; +import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; import de.hdm_stuttgart.battlearena.Model.Entity.EntityType; @@ -30,11 +33,15 @@ public class GameSceneController implements Initializable { InputHandler inputHandler = InputHandler.getInstance(); + RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); + + GameMode gameMode = runtimeInfo.getGameMode(); + IEntity player; IEntity enemy; - EntityClass playerClass = EntityClass.HUMAN; - EntityClass enemyClass = EntityClass.HUMAN; + EntityClass playerOneClass = runtimeInfo.getPlayerOneClass(); + EntityClass playerTwoClass = runtimeInfo.getPlayerTwoClass(); TileManager tileManager; @@ -68,11 +75,17 @@ public class GameSceneController implements Initializable { graphicsContext2D = canvas2D.getGraphicsContext2D(); graphicsContext2D.setImageSmoothing(false); - player = EntityFactory.createEntity(EntityType.PLAYER, graphicsContext2D, inputHandler, playerClass, this); - enemy = EntityFactory.createEntity(EntityType.ENEMY_PLAYER, graphicsContext2D, inputHandler, enemyClass, this); + player = EntityFactory.createEntity(EntityType.PLAYER, graphicsContext2D, inputHandler, playerOneClass, this); + if (gameMode == GameMode.NETWORK) { + enemy = EntityFactory.createEntity(EntityType.NETWORK_PLAYER_TWO, graphicsContext2D, inputHandler, playerTwoClass, this); + } else { + enemy = EntityFactory.createEntity(EntityType.LOKAL_PLAYER_TWO, graphicsContext2D, inputHandler, playerTwoClass, this); + } tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, verticalTileCount, mapString); + runtimeInfo.setGameState(GameState.PLAYING); + AnimationTimer gameLoop = new AnimationTimer() { @Override public void handle(long l) { diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java index 641449a5164e3aaa72e5aef97324569ec1c7b3c2..1a3b403f8265b7a8e086c9350c10f8a6b7f2434e 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/DataStorage/Classes/RuntimeInfo.java @@ -1,8 +1,11 @@ package de.hdm_stuttgart.battlearena.Model.DataStorage.Classes; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameMode; +import de.hdm_stuttgart.battlearena.Controller.Enum.GameState; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Exceptions.ParserException; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.HashGenerator; import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.Utilities.Parser; +import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -19,6 +22,13 @@ public class RuntimeInfo { protected String mapDataGame; protected boolean offlineMode; //if Account-Type is online but no SQL connection: start game without stats tracking + private GameState gameState = GameState.MENU; //Default value: MENU + private GameMode gameMode = GameMode.LOCAL; //Default value: LOCAL + + //Default value: HUMAN + private EntityClass playerOneClass = EntityClass.HUMAN; + private EntityClass playerTwoClass = EntityClass.HUMAN; + private RuntimeInfo(){}; @@ -86,4 +96,35 @@ public class RuntimeInfo { } } -} + public GameState getGameState() { + return gameState; + } + + public void setGameState(GameState gameState) { + this.gameState = gameState; + } + + public GameMode getGameMode() { + return gameMode; + } + + public void setGameMode(GameMode gameMode) { + this.gameMode = gameMode; + } + + public EntityClass getPlayerOneClass() { + return playerOneClass; + } + + public void setPlayerOneClass(EntityClass playerOneClass) { + this.playerOneClass = playerOneClass; + } + + public EntityClass getPlayerTwoClass() { + return playerTwoClass; + } + + public void setPlayerTwoClass(EntityClass playerTwoClass) { + this.playerTwoClass = playerTwoClass; + } +} \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java index d5b4b382213c197e503a598e855940aa18821998..25f326f94ebea2f7f27dc33ec7cad176f466cd45 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityFactory.java @@ -16,9 +16,12 @@ public class EntityFactory { if (entityType == EntityType.PLAYER) { log.debug("Entity " + entityType + " created"); return new Player(gameScene, inputHandler, entityClass, gameSceneController); - } else if (entityType == EntityType.ENEMY_PLAYER) { + } else if (entityType == EntityType.NETWORK_PLAYER_TWO) { log.debug("Entity " + entityType + " created"); - return new EnemyHandler(); + return new NetworkPlayerTwo(); + } else if (entityType == EntityType.LOKAL_PLAYER_TWO) { + log.debug("Entity " + entityType + " created"); + return new LocalPlayerTwo(); } throw new IllegalArgumentException ("Entity type not supported " + entityType); diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java index 3e8560772b2e9f049e217bdeca99c30c24150e11..108c4c2037dbcb53d090dc19a59b9b79450d6b68 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EntityType.java @@ -2,5 +2,6 @@ package de.hdm_stuttgart.battlearena.Model.Entity; public enum EntityType { PLAYER, - ENEMY_PLAYER + NETWORK_PLAYER_TWO, + LOKAL_PLAYER_TWO } \ No newline at end of file diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/LocalPlayerTwo.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/LocalPlayerTwo.java new file mode 100644 index 0000000000000000000000000000000000000000..cf51c0fc5cc0272bef91dfaca1a168f63b0fc0dd --- /dev/null +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/LocalPlayerTwo.java @@ -0,0 +1,72 @@ +package de.hdm_stuttgart.battlearena.Model.Entity; + +import de.hdm_stuttgart.battlearena.Controller.GameSceneController; +import javafx.geometry.BoundingBox; +import javafx.scene.canvas.GraphicsContext; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class LocalPlayerTwo implements IEntity{ + + private static final Logger log = LogManager.getLogger(LocalPlayerTwo.class); + + @Override + public void initializeEntity() { + + } + + @Override + public void loadEntitySprites() { + + } + + @Override + public void updateEntityMovement(GameSceneController gameScene) { + + } + + @Override + public void attack(IEntity entity, GraphicsContext graphicsContext) { + + } + + @Override + public void updateEntityWalkAnimation() { + + } + + @Override + public void renderEntity(GraphicsContext graphicsContext) { + + } + + @Override + public BoundingBox getBoxCollider() { + return null; + } + + @Override + public EntityDirection getEntityDirection() { + return null; + } + + @Override + public int getEntitySpeed() { + return 0; + } + + @Override + public int gotHit(int damageDone) { + return 0; + } + + @Override + public int getMapPosX() { + return 0; + } + + @Override + public int getMapPosY() { + return 0; + } +} diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java similarity index 92% rename from src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java rename to src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java index c8fc714cc5aa2eefe30e616b5211fe76e6457ff2..61aecddf8bd0c378ddab114851b9d4527df5ae5b 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/EnemyHandler.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Model/Entity/NetworkPlayerTwo.java @@ -9,9 +9,9 @@ import javafx.scene.paint.Color; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; -class EnemyHandler implements IEntity{ +class NetworkPlayerTwo implements IEntity{ - private static final Logger log = LogManager.getLogger(EnemyHandler.class); + private static final Logger log = LogManager.getLogger(NetworkPlayerTwo.class); private final BoundingBox boxCollider = new BoundingBox(300, 200, 48, 48);