Skip to content
Snippets Groups Projects
Commit 8035eae5 authored by Schlütter Yannik's avatar Schlütter Yannik Committed by Gehrung Jonas
Browse files

TileManager destroyableboxes fix, added destroyable boxes to every Biom, added new map

# Conflicts:
#	src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java
#	src/main/java/de/hdm_stuttgart/battlearena/Model/Map/TileManager.java
parent 9b6b929c
No related branches found
No related tags found
3 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development
...@@ -7,8 +7,10 @@ import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo; ...@@ -7,8 +7,10 @@ import de.hdm_stuttgart.battlearena.Model.DataStorage.Classes.RuntimeInfo;
import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass; import de.hdm_stuttgart.battlearena.Model.Entity.EntityClass;
import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory; import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory;
import de.hdm_stuttgart.battlearena.Model.Entity.EntityType; import de.hdm_stuttgart.battlearena.Model.Entity.EntityType;
import de.hdm_stuttgart.battlearena.Model.Entity.GameplayObjects.ObjectStatus;
import de.hdm_stuttgart.battlearena.Model.Entity.IEntity; import de.hdm_stuttgart.battlearena.Model.Entity.IEntity;
import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler; import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import de.hdm_stuttgart.battlearena.Model.Map.Biom;
import de.hdm_stuttgart.battlearena.Model.Map.TileManager; import de.hdm_stuttgart.battlearena.Model.Map.TileManager;
import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects; import de.hdm_stuttgart.battlearena.Model.Sound.SoundEffects;
...@@ -23,7 +25,9 @@ import org.apache.logging.log4j.LogManager; ...@@ -23,7 +25,9 @@ import org.apache.logging.log4j.LogManager;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.stream.Collectors;
public class GameSceneController implements Initializable { public class GameSceneController implements Initializable {
...@@ -38,8 +42,6 @@ public class GameSceneController implements Initializable { ...@@ -38,8 +42,6 @@ public class GameSceneController implements Initializable {
RuntimeInfo runtimeInfo = RuntimeInfo.getInstance(); RuntimeInfo runtimeInfo = RuntimeInfo.getInstance();
GameMode gameMode = runtimeInfo.getGameMode(); GameMode gameMode = runtimeInfo.getGameMode();
IEntity player; IEntity player;
...@@ -51,29 +53,70 @@ public class GameSceneController implements Initializable { ...@@ -51,29 +53,70 @@ public class GameSceneController implements Initializable {
TileManager tileManager; TileManager tileManager;
//map data //map data
String mapString = "4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 " +
"4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + String mapString = "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 " +
"4 2 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 3 " + "10 1 1 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 " +
"4 1 1 1 2 2 4 3 3 1 4 3 3 3 3 2 2 3 " + "10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 20 1 10 " +
"4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 1 2 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 1 1 2 2 4 1 3 3 3 1 1 1 3 2 2 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 1 2 2 4 1 1 1 1 1 1 1 3 2 1 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 5 1 2 2 4 3 3 1 4 3 3 3 3 2 1 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 1 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 1 1 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 1 1 1 2 4 3 3 1 3 3 3 3 3 2 2 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 1 1 1 4 3 3 1 3 3 3 3 3 1 2 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 2 1 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 20 10 " +
"4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + "10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"4 1 1 1 2 2 4 3 3 1 3 3 3 3 3 2 2 3 " + "10 1 20 1 20 1 20 1 20 1 20 1 20 1 20 1 1 10 " +
"4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3"; "10 1 1 20 10 20 10 20 10 20 10 20 10 20 10 1 1 10 " +
"10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ";
/*String mapString = "10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 " +
"10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 " +
"10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 20 10 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 20 10 20 10 20 10 20 10 10 20 10 20 10 20 10 20 10 " +
"10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 10 " +
"10 1 10 20 10 20 10 20 10 10 20 10 20 10 20 10 1 10 " +
"10 1 1 20 20 20 20 20 20 20 20 20 20 20 20 1 1 10 " +
"10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ";*/
/*String mapString = "11 10 13 10 13 10 10 12 14 14 11 10 10 13 10 13 10 12 " +
"11 0 0 0 0 0 16 0 2 2 0 3 0 0 0 3 0 12 " +
"11 0 16 0 0 0 0 0 1 2 0 0 0 0 16 0 1 12 " +
"11 16 0 0 3 0 16 0 2 2 0 0 3 0 0 0 0 12 " +
"11 0 3 0 0 16 0 1 1 2 0 0 0 0 16 0 0 12 " +
"11 0 0 16 16 0 0 0 1 2 0 0 0 0 3 16 0 12 " +
"11 16 0 0 12 10 10 15 12 2 11 15 16 15 15 11 0 12 " +
"11 0 0 0 12 0 1 1 0 2 0 0 0 0 0 11 0 12 " +
"11 0 0 16 12 5 5 5 5 4 5 5 5 5 0 11 1 12 " +
"11 0 0 0 12 11 10 10 10 2 12 0 0 1 0 11 0 12 " +
"11 0 0 0 12 1 0 0 11 2 12 16 0 1 0 11 0 12 " +
"11 0 0 0 12 0 1 0 11 2 12 0 16 0 0 11 0 12 " +
"11 0 1 0 12 0 0 12 11 2 12 11 13 10 13 11 0 12 " +
"11 0 0 0 12 0 0 0 0 2 0 0 0 0 0 0 0 12 " +
"11 0 0 0 12 15 13 10 12 14 11 10 13 10 13 12 0 12 " +
"11 1 0 0 1 0 0 0 0 2 0 0 1 1 0 0 0 12 " +
"11 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 12 " +
"11 10 15 15 10 10 15 10 12 14 11 10 10 15 10 15 10 12";*/
int horizontalTileCount = 18; int horizontalTileCount = 18;
int verticalTileCount = 18; int verticalTileCount = 18;
int diffTileCount = 6; int diffTileCount = 30;
int scaledTileSize = 48; int scaledTileSize = 48;
private final Biom biom = runtimeInfo.getMapBiom();
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
...@@ -90,7 +133,7 @@ public class GameSceneController implements Initializable { ...@@ -90,7 +133,7 @@ public class GameSceneController implements Initializable {
playerTwoClass, this, PlayerMode.PLAYER_TWO); playerTwoClass, this, PlayerMode.PLAYER_TWO);
} }
tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, verticalTileCount, mapString); tileManager = new TileManager(graphicsContext2D, diffTileCount, horizontalTileCount, verticalTileCount, mapString, biom);
SoundEffects soundEffects = new SoundEffects(); SoundEffects soundEffects = new SoundEffects();
...@@ -108,9 +151,11 @@ public class GameSceneController implements Initializable { ...@@ -108,9 +151,11 @@ public class GameSceneController implements Initializable {
AnimationTimer gameLoop = new AnimationTimer() { AnimationTimer gameLoop = new AnimationTimer() {
@Override @Override
public void handle(long l) { public void handle(long l) {
graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); if (!inputHandler.isPause()) {
renderContent(graphicsContext2D); graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight());
updateContent(); renderContent(graphicsContext2D);
updateContent();
}
} }
}; };
gameLoop.start(); gameLoop.start();
...@@ -122,14 +167,33 @@ public class GameSceneController implements Initializable { ...@@ -122,14 +167,33 @@ public class GameSceneController implements Initializable {
enemy.updateEntityMovement(this); enemy.updateEntityMovement(this);
player.attack(enemy, graphicsContext2D); player.attack(enemy, graphicsContext2D);
enemy.attack(player, graphicsContext2D); enemy.attack(player, graphicsContext2D);
updateGameplayObjects();
player.checkGameplayObjectInteraction(player, graphicsContext2D);
enemy.checkGameplayObjectInteraction(enemy, graphicsContext2D);
player.placeBomb(player, enemy, graphicsContext2D);
enemy.placeBomb(enemy, player, graphicsContext2D);
} }
private void renderContent(GraphicsContext graphicsContext) { private void renderContent(GraphicsContext graphicsContext) {
tileManager.renderMap(); tileManager.renderMap();
player.renderEntity(graphicsContext); player.renderEntity(graphicsContext);
enemy.renderEntity(graphicsContext); enemy.renderEntity(graphicsContext);
player.checkHealTile(player, graphicsContext2D); renderGameplayObjects(graphicsContext);
enemy.checkHealTile(enemy, graphicsContext2D); }
private void renderGameplayObjects(GraphicsContext graphicsContext) {
List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects();
for (IEntity gameplayObject : gameplayObjects) {
gameplayObject.renderEntity(graphicsContext);
}
}
private void updateGameplayObjects() {
List<IEntity> gameplayObjects = runtimeInfo.getGameplayObjects();
List<IEntity> updateList = gameplayObjects.stream().filter(obj -> obj.getOBJECT_STATUS() != ObjectStatus.USED)
.collect(Collectors.toList());
runtimeInfo.setGameplayObjects(updateList);
log.debug("Gameplay objects updated");
} }
public IEntity getEnemy() { public IEntity getEnemy() {
...@@ -147,4 +211,4 @@ public class GameSceneController implements Initializable { ...@@ -147,4 +211,4 @@ public class GameSceneController implements Initializable {
public int getScaledTileSize() { public int getScaledTileSize() {
return scaledTileSize; return scaledTileSize;
} }
} }
\ No newline at end of file
src/main/resources/textures/map/dark_lands_biom/building/box.png

210 B

src/main/resources/textures/map/grass_biom/building/box.png

210 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment