diff --git a/src/main/java/dk/sdu/mmmi/Main.java b/src/main/java/dk/sdu/mmmi/Main.java index e3288fe8..72533b1c 100644 --- a/src/main/java/dk/sdu/mmmi/Main.java +++ b/src/main/java/dk/sdu/mmmi/Main.java @@ -3,6 +3,7 @@ import dk.sdu.mmmi.modulemon.BattleScene.BattleView; import dk.sdu.mmmi.modulemon.BattleSimulation.BattleSimulation; import dk.sdu.mmmi.modulemon.Collision.CollisionProcessing; +import dk.sdu.mmmi.modulemon.CustomBattleView.CustomBattleView; import dk.sdu.mmmi.modulemon.Game; import dk.sdu.mmmi.modulemon.Interaction.InteractProcessing; import dk.sdu.mmmi.modulemon.MCTSBattleAI.MCTSBattleAIFactory; @@ -30,9 +31,10 @@ public static void main(String[] args) throws IOException, URISyntaxException { var settings = new Settings(); var monsterRegistry = new MonsterRegistry(); var battleMonsterProcessor = new BattleMonsterProcessor(); - var battleAI = new MCTSBattleAIFactory(); - //var battleAI = new dk.sdu.mmmi.modulemon.BattleAI.BattleAIFactory(); -// var battleAI = new dk.sdu.mmmi.modulemon.SimpleAI.BattleAIFactory(); // Uncomment for Simple AI + + var battleAI = new dk.sdu.mmmi.modulemon.BattleAI.BattleAIFactory(); + var mctsBattleAI = new MCTSBattleAIFactory(); + var simpleBattleAI = new dk.sdu.mmmi.modulemon.SimpleAI.BattleAIFactory(); // Uncomment for Simple AI var battleSimulation = new BattleSimulation(); battleSimulation.setAIFactory(battleAI); @@ -43,6 +45,16 @@ public static void main(String[] args) throws IOException, URISyntaxException { battle.setSettingsService(settings); battle.setMonsterRegistry(monsterRegistry); + var customBattle = new CustomBattleView(); + customBattle.setSettings(settings); + customBattle.setBattleSimulation(battleSimulation); + customBattle.setBattleView(battle); + customBattle.setMonsterRegistry(monsterRegistry); + customBattle.addBattleAI(battleAI); + customBattle.addBattleAI(mctsBattleAI); + customBattle.addBattleAI(simpleBattleAI); + + // Map stuff var map = new MapView(); map.setSettingsService(settings); @@ -77,6 +89,7 @@ public static void main(String[] args) throws IOException, URISyntaxException { var game = new Game(); game.setSettingsService(settings); game.addGameViewServiceList(battle); + game.addGameViewServiceList(customBattle); game.addGameViewServiceList(map); } } \ No newline at end of file diff --git a/src/main/java/dk/sdu/mmmi/modulemon/BattleAI/BattleAIFactory.java b/src/main/java/dk/sdu/mmmi/modulemon/BattleAI/BattleAIFactory.java index 35bf10c6..e2c9b478 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/BattleAI/BattleAIFactory.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/BattleAI/BattleAIFactory.java @@ -34,4 +34,9 @@ public void setSettingsService(IGameSettings settings) { public void removeSettingsService(IGameSettings settings) { this.settings = null; } + + @Override + public String toString() { + return "Minimax"; + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/BattleSimulation/BattleSimulation.java b/src/main/java/dk/sdu/mmmi/modulemon/BattleSimulation/BattleSimulation.java index f99c55ba..617469e4 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/BattleSimulation/BattleSimulation.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/BattleSimulation/BattleSimulation.java @@ -278,12 +278,7 @@ public void removeMonsterProcessor(IBattleMonsterProcessor monsterProcessor) { } public void setAIFactory(IBattleAIFactory factory) { - this.AIFactory = factory; - } - - public void removeAIFactory(IBattleAIFactory factory) { - this.AIFactory = null; this.AI = null; + this.AIFactory = factory; } - } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleScene.java b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleScene.java new file mode 100644 index 00000000..b5321c38 --- /dev/null +++ b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleScene.java @@ -0,0 +1,305 @@ +package dk.sdu.mmmi.modulemon.CustomBattleView; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import dk.sdu.mmmi.modulemon.CommonMonster.IMonster; +import dk.sdu.mmmi.modulemon.Game; +import dk.sdu.mmmi.modulemon.common.AssetLoader; +import dk.sdu.mmmi.modulemon.common.data.GameData; +import dk.sdu.mmmi.modulemon.common.drawing.DrawingUtils; +import dk.sdu.mmmi.modulemon.common.drawing.Position; +import dk.sdu.mmmi.modulemon.common.drawing.Rectangle; +import dk.sdu.mmmi.modulemon.common.drawing.TextUtils; +import dk.sdu.mmmi.modulemon.common.services.IGameSettings; + +public class CustomBattleScene { + + // LibGDX Drawing stuff + private String teamAAIText = ""; + private boolean showTeamAAIArrow = false; + private Color teamATextColor = Color.WHITE; + private boolean showTeamBAIArrow = false; + private String teamBAIText = ""; + private Color teamBTextColor = Color.WHITE; + private Color startBattleColor = Color.WHITE; + + private Position errorPosition = new Position(0,0); + private float errorSize = 0; + private float errorOpacity = 0; + private String errorText = ""; + private ShapeRenderer shapeRenderer; + private SpriteBatch spriteBatch; + + private boolean isTeamA = false; + private int changingMonsterIndex = -1; + private int selectedMonsterIndex = -1; + + public static final Color SelectColor = Color.valueOf("2a75bb"); + + private int screenWidth = 1280; + private int screenHeight = 720; + + private Rectangle teamAContainer; + private Rectangle teamBContainer; + private Rectangle[] teamAMonsterBoxes; + private Rectangle[] teamBMonsterBoxes; + private IMonster[] teamAMonsters; + private IMonster[] teamBMonsters; + + public CustomBattleScene(IGameSettings settings) { + spriteBatch = new SpriteBatch(); + shapeRenderer = new ShapeRenderer(); + + teamAContainer = DrawingUtils.createRectangle(Rectangle.class, 0, 0, 0, 0); + teamBContainer = DrawingUtils.createRectangle(Rectangle.class, 0, 0, 0, 0); + int teamSize = 6; + teamAMonsters = new IMonster[teamSize]; + teamBMonsters = new IMonster[teamSize]; + teamAMonsterBoxes = new Rectangle[teamSize]; + teamBMonsterBoxes = new Rectangle[teamSize]; + + for (int i = 0; i < teamSize; i++) { + teamAMonsterBoxes[i] = DrawingUtils.createRectangle(settings, 0, 0, 0, 0); + teamBMonsterBoxes[i] = DrawingUtils.createRectangle(settings, 0, 0, 0, 0); + } + } + + private static TextUtils text = TextUtils.getInstance(); + + public void draw(GameData gameData) { + float dt = gameData.getDelta(); + screenWidth = gameData.getDisplayWidth(); + screenHeight = gameData.getDisplayHeight(); + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + spriteBatch.setProjectionMatrix(Game.cam.combined); + spriteBatch.begin(); + + text.setCoordinateMode(TextUtils.CoordinateMode.CENTER); + final int textTopMargin = 60; + text.drawTitleFont(spriteBatch, "Custom Battle", Color.valueOf("ffcb05"), gameData.getDisplayWidth() / 2f, gameData.getDisplayHeight() - textTopMargin); + text.setCoordinateMode(TextUtils.CoordinateMode.TOP_LEFT); // Reset + spriteBatch.end(); + + //DRAW THE BOXES + + if (teamBContainer.getWidth() <= 0) { + calculateBoxSizes(gameData); + } + + spriteBatch.begin(); + shapeRenderer.setAutoShapeType(true); + shapeRenderer.setColor(Color.WHITE); + + Gdx.gl.glEnable(GL20.GL_BLEND); //Alows for opacity + if (gameData.getCamera() != null) + shapeRenderer.setProjectionMatrix(gameData.getCamera().combined); + shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); + + teamAContainer.draw(shapeRenderer, dt); + teamBContainer.draw(shapeRenderer, dt); + + for (int i = 0; i < teamAMonsterBoxes.length; i++) { + if(selectedMonsterIndex == i){ + if(isTeamA){ + teamAMonsterBoxes[i].setBorderColor(SelectColor); + teamAMonsterBoxes[i].setBorderWidth(4); + }else{ + teamBMonsterBoxes[i].setBorderColor(SelectColor); + teamBMonsterBoxes[i].setBorderWidth(4); + } + }else{ + teamAMonsterBoxes[i].setBorderColor(Color.BLACK); + teamAMonsterBoxes[i].setBorderWidth(2); + teamBMonsterBoxes[i].setBorderColor(Color.BLACK); + teamBMonsterBoxes[i].setBorderWidth(2); + } + teamAMonsterBoxes[i].draw(shapeRenderer, dt); + teamBMonsterBoxes[i].draw(shapeRenderer, dt); + } + + spriteBatch.end(); + shapeRenderer.end(); + + spriteBatch.begin(); + final int gapAboveContainersText = 20; + text.setCoordinateMode(TextUtils.CoordinateMode.CENTER); + text.drawNormalBoldRoboto(spriteBatch, "Your Team", Color.WHITE, teamAContainer.getX() + teamAContainer.getWidth() / 2f, teamAContainer.getY() + teamAContainer.getHeight() + gapAboveContainersText); + text.drawNormalBoldRoboto(spriteBatch, "Opponent Team", Color.WHITE, teamBContainer.getX() + teamBContainer.getWidth() / 2f, teamBContainer.getY() + teamBContainer.getHeight() + gapAboveContainersText); + + for (int i = 0; i < teamAMonsterBoxes.length; i++) { + drawMonsterWithName(teamAMonsters[i], teamAMonsterBoxes[i], changingMonsterIndex == i && isTeamA); + drawMonsterWithName(teamBMonsters[i], teamBMonsterBoxes[i], changingMonsterIndex == i && !isTeamA); + } + + + final float arrowSpacingFromEdge = 20; + final float controllerSelectorY = teamAContainer.getY() - gapAboveContainersText; + + if(showTeamAAIArrow) { + text.drawNormalRoboto(spriteBatch, "<", Color.WHITE, teamAContainer.getX() + arrowSpacingFromEdge, controllerSelectorY); + text.drawNormalRoboto(spriteBatch, ">", Color.WHITE, teamAContainer.getX() - arrowSpacingFromEdge + teamAContainer.getWidth(), controllerSelectorY); + } + text.drawSmallRoboto(spriteBatch, teamAAIText, teamATextColor, teamAContainer.getX() + teamAContainer.getWidth() / 2f, controllerSelectorY); + + if(showTeamBAIArrow) { + text.drawNormalRoboto(spriteBatch, "<", Color.WHITE, teamBContainer.getX() + arrowSpacingFromEdge, controllerSelectorY); + text.drawNormalRoboto(spriteBatch, ">", Color.WHITE, teamBContainer.getX() - arrowSpacingFromEdge + teamBContainer.getWidth(), controllerSelectorY); + } + text.drawSmallRoboto(spriteBatch, teamBAIText, teamBTextColor, teamBContainer.getX() + teamBContainer.getWidth() / 2f, controllerSelectorY); + + text.drawBigBoldRoboto(spriteBatch, "START BATTLE!", startBattleColor, gameData.getDisplayWidth() / 2f, 50 ); + + text.drawBigBoldRoboto(spriteBatch, errorText, new Color(1,0,0, errorOpacity), errorPosition.getX(), errorPosition.getY() ); + text.setCoordinateMode(TextUtils.CoordinateMode.TOP_LEFT); + spriteBatch.end(); + } + + private void drawMonsterWithName(IMonster monster, Rectangle rectangle, boolean drawMonsterSwitcher) { + final int monsterSpriteGap = 10; + final float monsterSpriteSize = rectangle.getWidth() - monsterSpriteGap * 2; + + if (monster == null) { + text.drawSmallRoboto(spriteBatch, "No monster", Color.LIGHT_GRAY, + rectangle.getX() + rectangle.getWidth() / 2f, + rectangle.getY() + rectangle.getHeight() / 2f); + } else { + //Draw the monster + var sprite = AssetLoader.getInstance().getImageAsset(monster.getFrontSprite(), getClass()); + sprite.setPosition(rectangle.getX() + monsterSpriteGap, rectangle.getY() + monsterSpriteGap * 2); + sprite.setSize(monsterSpriteSize, monsterSpriteSize); + sprite.draw(spriteBatch, 1); + text.drawSmallRoboto(spriteBatch, monster.getName(), Color.BLACK, + rectangle.getX() + rectangle.getWidth() / 2f, + rectangle.getY() + monsterSpriteGap); + } + + if(drawMonsterSwitcher){ + final float arrowSpacingFromEdge = 10; + text.drawNormalRoboto(spriteBatch, "<", Color.BLACK, + rectangle.getX() + arrowSpacingFromEdge, + rectangle.getY() + rectangle.getHeight() / 2f ); + text.drawNormalRoboto(spriteBatch, ">", Color.BLACK, + rectangle.getX() - arrowSpacingFromEdge + rectangle.getWidth(), + rectangle.getY() + rectangle.getHeight() / 2f ); + } + } + + public void setTeamAMonsters(IMonster[] teamAMonsters) { + if (teamAMonsters.length != this.teamAMonsters.length) { + throw new IllegalArgumentException("The monster array must be exactly %d entries long.".formatted(this.teamAMonsters.length)); + } + this.teamAMonsters = teamAMonsters; + } + + public void setTeamBMonsters(IMonster[] teamBMonsters) { + if (teamBMonsters.length != this.teamBMonsters.length) { + throw new IllegalArgumentException("The monster array must be exactly %d entries long.".formatted(this.teamBMonsters.length)); + } + this.teamBMonsters = teamBMonsters; + } + + public void setTeamA(boolean teamA) { + isTeamA = teamA; + } + + public void setChangingMonsterIndex(int changingMonsterIndex) { + this.changingMonsterIndex = changingMonsterIndex; + } + + public void setSelectedMonsterIndex(int selectedMonsterIndex) { + this.selectedMonsterIndex = selectedMonsterIndex; + } + + public void setTeamAAIText(String teamAAIText) { + this.teamAAIText = teamAAIText; + } + + public void setTeamBAIText(String teamBAIText) { + this.teamBAIText = teamBAIText; + } + + public void setTeamATextColor(Color teamATextColor) { + this.teamATextColor = teamATextColor; + } + + public void setTeamBTextColor(Color teamBTextColor) { + this.teamBTextColor = teamBTextColor; + } + + public void setShowTeamAAIArrow(boolean showTeamAAIArrow) { + this.showTeamAAIArrow = showTeamAAIArrow; + } + + public void setShowTeamBAIArrow(boolean showTeamBAIArrow) { + this.showTeamBAIArrow = showTeamBAIArrow; + } + + public void setStartBattleColor(Color startBattleColor) { + this.startBattleColor = startBattleColor; + } + + public void setErrorPosition(Position errorPosition) { + this.errorPosition = errorPosition; + } + + public void setErrorOpacity(float errorOpacity) { + this.errorOpacity = errorOpacity; + } + + public void setErrorText(String errorText) { + this.errorText = errorText; + } + + public void setErrorSize(float errorSize) { + this.errorSize = errorSize; + } + + public int getScreenWidth() { + return screenWidth; + } + + public int getScreenHeight() { + return screenHeight; + } + + private void calculateBoxSizes(GameData gameData) { + final int monsterContainerBottomOffset = 130; + final int monsterContainerCenterOffset = 20; + final int freeSpaceToLeaveAtTop = 150; // Estimated size of text + mer' + final int containerGap = 20; + final float containerWidth = 300; + final float containerHeight = gameData.getDisplayHeight() - monsterContainerBottomOffset - containerGap - freeSpaceToLeaveAtTop; + teamAContainer.setPosition(new Position((gameData.getDisplayWidth() / 2f) - monsterContainerCenterOffset - containerWidth, monsterContainerBottomOffset)); + teamBContainer.setPosition(new Position((gameData.getDisplayWidth() / 2f) + monsterContainerCenterOffset, monsterContainerBottomOffset)); + teamAContainer.setWidth(containerWidth); + teamBContainer.setWidth(containerWidth); + teamAContainer.setHeight(containerHeight); + teamBContainer.setHeight(containerHeight); + + final float monsterBoxSize = 110; + final float topOfContainers = teamAContainer.getY() + teamAContainer.getHeight(); + final float monsterGap = 20; + for (int i = 0; i < teamAMonsterBoxes.length; i++) { + teamAMonsterBoxes[i].setHeight(monsterBoxSize); + teamAMonsterBoxes[i].setWidth(monsterBoxSize); + teamBMonsterBoxes[i].setHeight(monsterBoxSize); + teamBMonsterBoxes[i].setWidth(monsterBoxSize); + + final float rowCount = i % 2 == 0 ? i + 1 : i; + float boxY = topOfContainers - monsterBoxSize - monsterGap - (monsterGap / 2f * (rowCount - 1)) - (monsterBoxSize / 2f * (rowCount - 1)); + if (i % 2 == 0) { + // Even + teamAMonsterBoxes[i].setPosition(new Position(teamAContainer.getX() + monsterGap, boxY)); + teamBMonsterBoxes[i].setPosition(new Position(teamBContainer.getX() + monsterGap, boxY)); + } else { + // Odd + teamAMonsterBoxes[i].setPosition(new Position(teamAContainer.getX() + teamAContainer.getWidth() - monsterGap - teamAMonsterBoxes[i].getWidth(), boxY)); + teamBMonsterBoxes[i].setPosition(new Position(teamBContainer.getX() + teamBContainer.getWidth() - monsterGap - teamBMonsterBoxes[i].getWidth(), boxY)); + } + } + } +} diff --git a/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleView.java b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleView.java new file mode 100644 index 00000000..2d4c8335 --- /dev/null +++ b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/CustomBattleView.java @@ -0,0 +1,347 @@ +package dk.sdu.mmmi.modulemon.CustomBattleView; + +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Color; +import dk.sdu.mmmi.modulemon.CommonBattleClient.IBattleView; +import dk.sdu.mmmi.modulemon.CommonBattleSimulation.IBattleAIFactory; +import dk.sdu.mmmi.modulemon.CommonBattleSimulation.IBattleSimulation; +import dk.sdu.mmmi.modulemon.CommonMonster.IMonster; +import dk.sdu.mmmi.modulemon.CommonMonster.IMonsterRegistry; +import dk.sdu.mmmi.modulemon.common.AssetLoader; +import dk.sdu.mmmi.modulemon.common.SettingsRegistry; +import dk.sdu.mmmi.modulemon.common.animations.BaseAnimation; +import dk.sdu.mmmi.modulemon.common.data.GameData; +import dk.sdu.mmmi.modulemon.common.data.GameKeys; +import dk.sdu.mmmi.modulemon.common.data.IGameViewManager; +import dk.sdu.mmmi.modulemon.common.drawing.MathUtils; +import dk.sdu.mmmi.modulemon.common.services.IGameSettings; +import dk.sdu.mmmi.modulemon.common.services.IGameViewService; + +import java.util.*; + +public class CustomBattleView implements IGameViewService { + private IGameSettings settings; + private SettingsRegistry settingsRegistry = SettingsRegistry.getInstance(); + private List battleAIFactoryList = new ArrayList<>(); + private IBattleView battleView; + private IMonsterRegistry monsterRegistry; + private IBattleSimulation battleSimulation; + + private Queue backgroundAnimations; + private CustomBattleScene scene; + + // LibGDX Sound stuff + private Sound selectSound; + private Sound chooseSound; + private Sound wrongSound; + private Music customBattleMusic; + + @Override + public void init(IGameViewManager gameViewManager) { + selectSound = AssetLoader.getInstance().getSoundAsset("/sounds/select.ogg", this.getClass()); + chooseSound = AssetLoader.getInstance().getSoundAsset("/sounds/choose.ogg", this.getClass()); + wrongSound = AssetLoader.getInstance().getSoundAsset("/sounds/metal-pipe.ogg", this.getClass()); + customBattleMusic = AssetLoader.getInstance().getMusicAsset("/music/customBattleMenu.ogg", this.getClass()); + customBattleMusic.setVolume((int) settings.getSetting(settingsRegistry.getMusicVolumeSetting()) / 100f); + customBattleMusic.setLooping(true); + customBattleMusic.play(); + + scene = new CustomBattleScene(settings); + backgroundAnimations = new LinkedList<>(); + redrawRoulettes = true; + } + + private Integer selectedTeamAAI = null; + private Integer selectedTeamBAI = 1; + private Integer[] selectedTeamAIndicies = new Integer[6]; + private Integer[] selectedTeamBIndicies = new Integer[6]; + private int cursorPosition = 0; + private boolean editingMode = false; + private boolean redrawRoulettes = true; + + + @Override + public void update(GameData gameData, IGameViewManager gameViewManager) { + cursorPosition = MathUtils.clamp(cursorPosition, 0, 14); + + var nextAnimation = backgroundAnimations.peek(); + if(nextAnimation != null){ + nextAnimation.update(gameData); + if(nextAnimation.isFinished()){ + backgroundAnimations.poll(); + } + } + + if (redrawRoulettes) { + var teamAAI = getSelectedAI(selectedTeamAAI); + var teamBAI = getSelectedAI(selectedTeamBAI); + if (teamAAI != null) { + scene.setTeamAAIText(teamAAI.toString()); + } else { + scene.setTeamAAIText("Player controlled"); + } + if (teamBAI != null) { + scene.setTeamBAIText(getSelectedAI(selectedTeamBAI).toString()); + } else { + scene.setTeamBAIText(""); + } + scene.setTeamAMonsters(getMonsterArray(selectedTeamAIndicies)); + scene.setTeamBMonsters(getMonsterArray(selectedTeamBIndicies)); + redrawRoulettes = false; + } + + // Reset all selection + scene.setSelectedMonsterIndex(-1); + scene.setChangingMonsterIndex(-1); + scene.setTeamATextColor(Color.WHITE); + scene.setTeamBTextColor(Color.WHITE); + scene.setStartBattleColor(Color.WHITE); + scene.setShowTeamAAIArrow(false); + scene.setShowTeamBAIArrow(false); + + if (cursorPosition >= 0 && cursorPosition <= 11) { + var adjustedCursor = getGridAdjustedCursor(cursorPosition); + scene.setSelectedMonsterIndex(adjustedCursor % 6); + if (editingMode) { + scene.setChangingMonsterIndex(adjustedCursor % 6); + } + } else if (cursorPosition == 12) { + scene.setTeamATextColor(CustomBattleScene.SelectColor); + scene.setShowTeamAAIArrow(editingMode); + } else if (cursorPosition == 13) { + scene.setTeamBTextColor(CustomBattleScene.SelectColor); + scene.setShowTeamBAIArrow(editingMode); + } else if (cursorPosition == 14) { + scene.setStartBattleColor(CustomBattleScene.SelectColor); + if (editingMode) { + startBattle(gameViewManager); + editingMode = false; + } + } + } + + @Override + public void draw(GameData gameData) { + scene.draw(gameData); + } + + @Override + public void handleInput(GameData gameData, IGameViewManager gameViewManager) { + if (gameData.getKeys().isPressed(GameKeys.BACK)) { + chooseSound.play(getSoundVolume()); + if (editingMode) { + editingMode = false; + } else { + gameViewManager.setDefaultView(); + } + } + + if (gameData.getKeys().isPressed(GameKeys.ACTION)) { + editingMode = !editingMode; + chooseSound.play(getSoundVolume()); + } + + if (gameData.getKeys().isPressed(GameKeys.DELETE) && cursorPosition < 13) { + addToSelectedIndicies(null); + editingMode = false; + chooseSound.play(getSoundVolume()); + } + + // This is a hardcoded mess. Don't think too hard about it, it just works with the current setup. + if (gameData.getKeys().isPressed(GameKeys.UP) && !editingMode) { + selectSound.play(getSoundVolume()); + if (cursorPosition <= 12) { + cursorPosition -= 4; + } else { + cursorPosition -= 2; + } + } else if (gameData.getKeys().isPressed(GameKeys.DOWN) && !editingMode) { + selectSound.play(getSoundVolume()); + if (cursorPosition < 12) { + if (cursorPosition >= 8) { + cursorPosition = cursorPosition % 4 < 2 ? 12 : 13; + } else { + cursorPosition += 4; + } + } else { + cursorPosition += 2; + } + } else if (gameData.getKeys().isPressed(GameKeys.RIGHT)) { + selectSound.play(getSoundVolume()); + + if (!editingMode) { + if (cursorPosition == 14) { + cursorPosition = 13; + } else { + cursorPosition += 1; + } + } else { + addToSelectedIndicies(1); + } + } else if (gameData.getKeys().isPressed(GameKeys.LEFT)) { + selectSound.play(getSoundVolume()); + + if (!editingMode) { + if (cursorPosition == 14) { + cursorPosition = 12; + } else if (cursorPosition == 12) { + cursorPosition -= 4; + } else { + cursorPosition -= 1; + } + } else { + addToSelectedIndicies(-1); + } + } + } + + private void startBattle(IGameViewManager gameViewManager){ + var teamA = Arrays.stream(getMonsterArray(selectedTeamAIndicies)).filter(Objects::nonNull).toList(); + var teamB = Arrays.stream(getMonsterArray(selectedTeamBIndicies)).filter(Objects::nonNull).toList(); + + var teamAAI = getSelectedAI(selectedTeamAAI); + var teamBAI = getSelectedAI(selectedTeamBAI); + + if(teamA.isEmpty() || teamB.isEmpty() || teamBAI == null){ + wrongSound.play(1); + var anim = new ErrorTextAnimation(scene, "Add some monsters to both teams you dork!"); + anim.start(); + backgroundAnimations.add(anim); + return; + } + + System.out.println("Using Team A AI: " + teamAAI); + System.out.println("Using Team B AI: " + teamBAI); + battleSimulation.setAIFactory(teamBAI); + + gameViewManager.setView(battleView.getGameView(), false); // Do not dispose the map + customBattleMusic.stop(); + battleView.startBattle(teamA, teamB, result -> { + customBattleMusic.play(); + gameViewManager.setView(this); + boolean teamAWon = result.getWinner() == result.getPlayer(); + System.out.println("The winner is team: " + (teamAWon ? "A" : "B") + "!"); + cursorPosition = 0; + editingMode = false; + }); + + // Set the battle AI after the startBattle method to override the configs. + battleSimulation.setAIFactory(teamBAI); + } + + private void addToSelectedIndicies(Integer a) { + redrawRoulettes = true; + if (cursorPosition < 12) { + var numMonsters = this.monsterRegistry.getMonsterAmount() - 1; + if (isTeamA(cursorPosition)) { + selectedTeamAIndicies[getGridAdjustedCursor(cursorPosition)] = scrollIndexWithNull(selectedTeamAIndicies[getGridAdjustedCursor(cursorPosition)],a , numMonsters); + } else { + selectedTeamBIndicies[getGridAdjustedCursor(cursorPosition)] = scrollIndexWithNull(selectedTeamBIndicies[getGridAdjustedCursor(cursorPosition)],a, numMonsters); + } + } else if (cursorPosition == 12) { + selectedTeamAAI = scrollIndexWithNull(selectedTeamAAI, a, this.battleAIFactoryList.size() - 1); + } else if (cursorPosition == 13) { + var newBValue = scrollIndexWithNull(selectedTeamBAI, a, this.battleAIFactoryList.size() - 1); + if(newBValue == null){ + newBValue = selectedTeamBAI == 0 ? this.battleAIFactoryList.size() - 1 : 0; + } + selectedTeamBAI = newBValue; + } + } + + private Integer scrollIndexWithNull(Integer input, Integer a, int maxValue) { + if (a == null) { + return a; + } + + if (input == null) { + if (a > 0){ + return 0; + }else{ + return maxValue; + } + } + + var out = input + a; + + if (out < 0 + || out > maxValue) { + return null; + } + + return out; + } + + private boolean isTeamA(int cursorPosition) { + return cursorPosition % 4 < 2; + } + + private int getGridAdjustedCursor(int cursorPosition) { + boolean isTeamA = isTeamA(cursorPosition); + int offsetPerSide = cursorPosition / (isTeamA ? 4 : 2); + scene.setTeamA(isTeamA); + var adjustedCursor = cursorPosition - 2 * offsetPerSide; + if (!isTeamA) { + adjustedCursor += 2 * (cursorPosition / 4); + } + return adjustedCursor; + } + + private IBattleAIFactory getSelectedAI(Integer index) { + if (index == null) { + return null; + } + return this.battleAIFactoryList.get(index % battleAIFactoryList.size()); + } + + private IMonster[] getMonsterArray(Integer[] indicies) { + var monsters = new IMonster[indicies.length]; + for (int i = 0; i < indicies.length; i++) { + if (indicies[i] != null) { + monsters[i] = monsterRegistry.getMonster(indicies[i] % monsterRegistry.getMonsterAmount()); + } + } + return monsters; + } + + @Override + public void dispose() { + customBattleMusic.stop(); + customBattleMusic.dispose(); + customBattleMusic = null; + } + + public void addBattleAI(IBattleAIFactory battleAIFactory) { + battleAIFactoryList.add(battleAIFactory); + } + + public void setBattleView(IBattleView battleView) { + this.battleView = battleView; + } + + public void setBattleSimulation(IBattleSimulation battleSimulation) { + this.battleSimulation = battleSimulation; + } + + public void setMonsterRegistry(IMonsterRegistry monsterRegistry) { + this.monsterRegistry = monsterRegistry; + } + + public void setSettings(IGameSettings settings) { + this.settings = settings; + } + + private float getMusicVolume() { + return ((int) settings.getSetting(settingsRegistry.getMusicVolumeSetting()) / 100f); + } + + private float getSoundVolume() { + return ((int) settings.getSetting(settingsRegistry.getSoundVolumeSetting()) / 100f); + } + + @Override + public String toString() { + return "Custom Battle"; + } +} diff --git a/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/ErrorTextAnimation.java b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/ErrorTextAnimation.java new file mode 100644 index 00000000..a45b5184 --- /dev/null +++ b/src/main/java/dk/sdu/mmmi/modulemon/CustomBattleView/ErrorTextAnimation.java @@ -0,0 +1,52 @@ +package dk.sdu.mmmi.modulemon.CustomBattleView; + +import dk.sdu.mmmi.modulemon.common.animations.AnimationCurves; +import dk.sdu.mmmi.modulemon.common.animations.BaseAnimation; +import dk.sdu.mmmi.modulemon.common.data.GameData; +import dk.sdu.mmmi.modulemon.common.drawing.Position; + +import java.util.ArrayList; + +public class ErrorTextAnimation extends BaseAnimation { + private CustomBattleScene battleScene; + public ErrorTextAnimation(CustomBattleScene battleScene, String errorText){ + super(); + this.battleScene = battleScene; + super.animationCurve = AnimationCurves.EaseIn(); + + Timeline = new int[]{0, 400, 1900, 2300}; + States = new ArrayList<>(Timeline.length); + + States.add(new float[]{ + battleScene.getScreenWidth()/2f, battleScene.getScreenHeight()+100, //Position x,y + 0 // Opacity + }); + + States.add(new float[]{ + battleScene.getScreenWidth()/2f, (battleScene.getScreenHeight()/2f)+5, //Position x,y + 1 // Opacity + }); + + States.add(new float[]{ + battleScene.getScreenWidth()/2f, (battleScene.getScreenHeight()/2f)-5, //Position x,y + 1 // Opacity + }); + + States.add(new float[]{ + battleScene.getScreenWidth()/2f, -100, //Position x,y + 0 // Opacity + }); + + battleScene.setErrorText(errorText); + battleScene.setErrorPosition(new Position(States.get(0)[0], States.get(0)[1])); + battleScene.setErrorOpacity(States.get(0)[2]); + } + + @Override + public void update(GameData gameData) { + super.tick(); + float[] states = super.getCurrentStates(); + battleScene.setErrorPosition(new Position(states[0], states[1])); + battleScene.setErrorOpacity(states[2]); + } +} diff --git a/src/main/java/dk/sdu/mmmi/modulemon/Map/MapView.java b/src/main/java/dk/sdu/mmmi/modulemon/Map/MapView.java index 56e0cf44..ce85cbe5 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/Map/MapView.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/Map/MapView.java @@ -31,10 +31,7 @@ import dk.sdu.mmmi.modulemon.common.data.GameData; import dk.sdu.mmmi.modulemon.common.data.GameKeys; import dk.sdu.mmmi.modulemon.common.data.IGameViewManager; -import dk.sdu.mmmi.modulemon.common.drawing.MathUtils; -import dk.sdu.mmmi.modulemon.common.drawing.PersonaRectangle; -import dk.sdu.mmmi.modulemon.common.drawing.Rectangle; -import dk.sdu.mmmi.modulemon.common.drawing.TextUtils; +import dk.sdu.mmmi.modulemon.common.drawing.*; import dk.sdu.mmmi.modulemon.common.services.IGameSettings; import dk.sdu.mmmi.modulemon.common.services.IGameViewService; @@ -141,17 +138,6 @@ private void initializeCameraDrawing(GameData gameData) { cam.position.set(mapRight / 2f, mapTop / 2f, 0); } - private Rectangle createRectangle(Class clazz, float x, float y, float width, float height) { - try { - return (Rectangle) clazz.getDeclaredConstructors()[0].newInstance(x, y, width, height); - } catch (Exception ex) { - System.out.println("[WARNING] Failed to create rectangles of type: " + clazz.getName()); - } - //Default to regular rectangle - return new Rectangle(x, y, width, height); - } - - @Override public void update(GameData gameData, IGameViewManager gameViewManager) { while (!gdxThreadTasks.isEmpty()) { @@ -183,23 +169,23 @@ public void update(GameData gameData, IGameViewManager gameViewManager) { if ((Boolean) settings.getSetting(SettingsRegistry.getInstance().getRectangleStyleSetting()) && !(pauseMenu instanceof PersonaRectangle)) { rectToUse = PersonaRectangle.class; - summaryMenu = createRectangle(rectToUse, 100, 100, 380, 300); - pauseMenu = createRectangle(rectToUse, 100, 100, 200, 250); - monsterTeamMenu = createRectangle(rectToUse, 100, 100, 400, 550); - teamActionMenu = createRectangle(rectToUse, 100, 100, 200, 200); + summaryMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 380, 300); + pauseMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 200, 250); + monsterTeamMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 400, 550); + teamActionMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 200, 200); } else if (!(Boolean) settings.getSetting(SettingsRegistry.getInstance().getRectangleStyleSetting()) && (pauseMenu instanceof PersonaRectangle || pauseMenu == null)) { rectToUse = Rectangle.class; - summaryMenu = createRectangle(rectToUse, 100, 100, 380, 300); - pauseMenu = createRectangle(rectToUse, 100, 100, 200, 250); - monsterTeamMenu = createRectangle(rectToUse, 100, 100, 400, 550); - teamActionMenu = createRectangle(rectToUse, 100, 100, 200, 200); + summaryMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 380, 300); + pauseMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 200, 250); + monsterTeamMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 400, 550); + teamActionMenu = DrawingUtils.createRectangle(rectToUse, 100, 100, 200, 200); } } else { mapMusic.setVolume(0.3f); - summaryMenu = createRectangle(Rectangle.class, 100, 100, 380, 300); - pauseMenu = createRectangle(Rectangle.class, 100, 100, 200, 250); - monsterTeamMenu = createRectangle(Rectangle.class, 100, 100, 400, 550); - teamActionMenu = createRectangle(Rectangle.class, 100, 100, 200, 200); + summaryMenu = DrawingUtils.createRectangle(Rectangle.class, 100, 100, 380, 300); + pauseMenu = DrawingUtils.createRectangle(Rectangle.class, 100, 100, 200, 250); + monsterTeamMenu = DrawingUtils.createRectangle(Rectangle.class, 100, 100, 400, 550); + teamActionMenu = DrawingUtils.createRectangle(Rectangle.class, 100, 100, 200, 200); } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/SimpleAI/BattleAIFactory.java b/src/main/java/dk/sdu/mmmi/modulemon/SimpleAI/BattleAIFactory.java index 588a5110..e03cf470 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/SimpleAI/BattleAIFactory.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/SimpleAI/BattleAIFactory.java @@ -14,4 +14,9 @@ public BattleAIFactory() { public IBattleAI getBattleAI(IBattleSimulation battleSimulation, IBattleParticipant participantToControl) { return new BattleAI(battleSimulation, participantToControl); } + + @Override + public String toString() { + return "Simple AI"; + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/common/data/GameKeys.java b/src/main/java/dk/sdu/mmmi/modulemon/common/data/GameKeys.java index 816b8359..315e225b 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/common/data/GameKeys.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/common/data/GameKeys.java @@ -5,7 +5,7 @@ public class GameKeys { private static boolean[] keys; private static boolean[] pkeys; - private static final int NUM_KEYS = 9; + private static final int NUM_KEYS = 11; public static final int UP = 0; public static final int LEFT = 1; public static final int DOWN = 2; @@ -15,6 +15,9 @@ public class GameKeys { public static final int K = 6; public static final int LEFT_CTRL = 7; public static final int BACK = 8; + public static final int ESCAPE = 9; + + public static final int DELETE = 10; public GameKeys() { keys = new boolean[NUM_KEYS]; diff --git a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/DrawingUtils.java b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/DrawingUtils.java index ea5e73ea..9fcff5de 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/DrawingUtils.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/DrawingUtils.java @@ -2,6 +2,8 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import dk.sdu.mmmi.modulemon.common.SettingsRegistry; +import dk.sdu.mmmi.modulemon.common.services.IGameSettings; public class DrawingUtils { @@ -25,5 +27,21 @@ public static void borderedRect(ShapeRenderer shapeRenderer, float x, float y, f ); } + public static Rectangle createRectangle(Class clazz, float x, float y, float width, float height) { + try { + return (Rectangle) clazz.getDeclaredConstructors()[0].newInstance(x, y, width, height); + } catch (Exception ex) { + System.out.println("[WARNING] Failed to create rectangles of type: " + clazz.getName()); + } + //Default to regular rectangle + return new Rectangle(x, y, width, height); + } + public static Rectangle createRectangle(IGameSettings settings, float x, float y, float width, float height) { + if((Boolean) settings.getSetting(SettingsRegistry.getInstance().getRectangleStyleSetting())){ + return createRectangle(PersonaRectangle.class, x, y, width, height); + }else{ + return createRectangle(Rectangle.class, x, y, width, height); + } + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/MathUtils.java b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/MathUtils.java index 0383767e..a9f932a3 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/MathUtils.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/MathUtils.java @@ -19,4 +19,12 @@ public static float moveTowards(float initial, float target, float animationSpee return initial + animationSpeed * dt; } } + + public static float clamp(float value, float min, float max) { + return Math.max(min, Math.min(max, value)); + } + + public static int clamp(int value, int min, int max) { + return Math.max(min, Math.min(max, value)); + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/Position.java b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/Position.java index 4614e6a8..3c524aae 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/Position.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/Position.java @@ -30,4 +30,9 @@ public float getY() { public void setY(float y) { this.y = y; } + + @Override + public String toString() { + return "Position(" + x + "," + y + ")"; + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/TextUtils.java b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/TextUtils.java index ce073c5e..753743c8 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/TextUtils.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/common/drawing/TextUtils.java @@ -11,15 +11,19 @@ public class TextUtils { private static final Object _instanceLock = new Object(); private static TextUtils _instance; private GlyphLayout glyphLayout; + private BitmapFont titleFont; private BitmapFont bigRobotoFont; private BitmapFont normalRobotoFont; private BitmapFont smallRobotoFont; private BitmapFont bigBoldRobotoFont; private BitmapFont normalBoldRobotoFont; private BitmapFont smallBoldRobotoFont; + + private CoordinateMode currentCoordinateMode = CoordinateMode.TOP_LEFT; + private TextUtils() { glyphLayout = new GlyphLayout(); - + FreeTypeFontGenerator titleFontGenerator = new FreeTypeFontGenerator(new OSGiFileHandle("/fonts/Modulemon-Solid.ttf", this.getClass())); FreeTypeFontGenerator fontGenerator = new FreeTypeFontGenerator(new OSGiFileHandle("/fonts/Roboto-Medium.ttf", this.getClass())); // Since we are using Roboto Medium, which looks a lot like Roboto-Bold, // the font size for the "bold" version is set to 2 higher, to give the feeling of it appearing bigger/bold. @@ -27,6 +31,9 @@ private TextUtils() { // Font size FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); + parameter.size = 80; + titleFont = titleFontGenerator.generateFont(parameter); + parameter.size = 34; bigRobotoFont = fontGenerator.generateFont(parameter); parameter.size = 36; @@ -44,10 +51,10 @@ private TextUtils() { fontGenerator.dispose(); } - public static TextUtils getInstance(){ - if(_instance == null){ - synchronized (_instanceLock){ - if(_instance == null){ + public static TextUtils getInstance() { + if (_instance == null) { + synchronized (_instanceLock) { + if (_instance == null) { _instance = new TextUtils(); } } @@ -55,69 +62,109 @@ public static TextUtils getInstance(){ return _instance; } + public void setCoordinateMode(CoordinateMode currentCoordinateMode) { + this.currentCoordinateMode = currentCoordinateMode; + } - public void drawBigRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + public CoordinateMode getCoordinateMode() { + return currentCoordinateMode; + } + + public void drawTitleFont(SpriteBatch batch, String text, Color color, float x, float y) { + glyphLayout.setText(titleFont, text); + titleFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); + titleFont.draw( + batch, + text, + adjusted.getX(), + adjusted.getY() + ); + } + + public void drawBigRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(bigRobotoFont, text); bigRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); bigRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } - public void drawBigBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + + public void drawBigBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(bigBoldRobotoFont, text); bigBoldRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); bigBoldRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } - public void drawNormalRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + public void drawNormalRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(normalRobotoFont, text); normalRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); normalRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } - public void drawNormalBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + public void drawNormalBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(normalBoldRobotoFont, text); normalBoldRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); normalBoldRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } - public void drawSmallRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + public void drawSmallRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(smallRobotoFont, text); smallRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); smallRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } - public void drawSmallBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y){ + public void drawSmallBoldRoboto(SpriteBatch batch, String text, Color color, float x, float y) { glyphLayout.setText(smallBoldRobotoFont, text); smallBoldRobotoFont.setColor(color); + var adjusted = getAdjustedCoordinates(glyphLayout, x, y); smallBoldRobotoFont.draw( batch, text, - x, - y + adjusted.getX(), + adjusted.getY() ); } + + private Position getAdjustedCoordinates(GlyphLayout layout, float x, float y) { + return switch (currentCoordinateMode) { + case TOP_LEFT -> new Position(x, y); + case BOTTOM_RIGHT -> new Position(x - layout.width, y - layout.height); + case CENTER -> new Position(x - (layout.width / 2f), y + (layout.height/2f)); + }; + } + + public enum CoordinateMode { + TOP_LEFT, + BOTTOM_RIGHT, + CENTER + } } diff --git a/src/main/java/dk/sdu/mmmi/modulemon/gameviews/MenuView.java b/src/main/java/dk/sdu/mmmi/modulemon/gameviews/MenuView.java index c51b3d68..0489d6ae 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/gameviews/MenuView.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/gameviews/MenuView.java @@ -333,6 +333,7 @@ private void selectOption(IGameViewManager gvm) { gvm.setView(selectedView); if (selectedView instanceof IBattleView battleView) { chooseSound.play(getSoundVolumeAsFloat()); + battleView.startBattle(null, null, null); } } else { diff --git a/src/main/java/dk/sdu/mmmi/modulemon/managers/GameInputManager.java b/src/main/java/dk/sdu/mmmi/modulemon/managers/GameInputManager.java index 78520c54..dab6f50b 100644 --- a/src/main/java/dk/sdu/mmmi/modulemon/managers/GameInputManager.java +++ b/src/main/java/dk/sdu/mmmi/modulemon/managers/GameInputManager.java @@ -54,5 +54,11 @@ private void handleButtons(int k, boolean state) { || k == Input.Keys.BUTTON_START) { gameData.getKeys().setKey(GameKeys.BACK, state); } + if(k == Input.Keys.ESCAPE){ + gameData.getKeys().setKey(GameKeys.ESCAPE, state); + } + if(k == Input.Keys.FORWARD_DEL){ + gameData.getKeys().setKey(GameKeys.DELETE, state); + } } } diff --git a/src/main/resources/music/customBattleMenu.ogg b/src/main/resources/music/customBattleMenu.ogg new file mode 100644 index 00000000..6285579e Binary files /dev/null and b/src/main/resources/music/customBattleMenu.ogg differ diff --git a/src/main/resources/sounds/metal-pipe.ogg b/src/main/resources/sounds/metal-pipe.ogg new file mode 100644 index 00000000..80b709cf Binary files /dev/null and b/src/main/resources/sounds/metal-pipe.ogg differ