diff --git a/src/main/java/inf112/fiasko/roborally/elementproperties/WallType.java b/src/main/java/inf112/fiasko/roborally/elementproperties/WallType.java index 608b436..3a27b80 100644 --- a/src/main/java/inf112/fiasko/roborally/elementproperties/WallType.java +++ b/src/main/java/inf112/fiasko/roborally/elementproperties/WallType.java @@ -20,6 +20,10 @@ public enum WallType { * A wall with two lasers */ WALL_LASER_DOUBLE(4), + /** + * A wall with three lasers + */ + WALL_LASER_TRIPLE(7), /** * A pusher which pushes on every odd phase */ diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index 46397df..5cdddd8 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -544,7 +544,7 @@ public class Board { */ public void fireAllLasers() { List> listOfWallLasers = getPositionsOfWallOnBoard(WallType.WALL_LASER_SINGLE, - WallType.WALL_LASER_DOUBLE); + WallType.WALL_LASER_DOUBLE, WallType.WALL_LASER_TRIPLE); for (Robot robot : robots.values()) { fireRobotLaser(robot.getPosition(), robot.getFacingDirection()); } @@ -858,8 +858,20 @@ public class Board { * @param laserType The type of the laser shooting */ private void updateLaserBeamOnParticleGrid(Position addPosition, Direction laserDirection, WallType laserType) { - ParticleType laserParticleType = laserType == WallType.WALL_LASER_SINGLE ? ParticleType.LASER_BEAM_SINGLE : - ParticleType.LASER_BEAM_DOUBLE; + ParticleType laserParticleType; + switch (laserType) { + case WALL_LASER_SINGLE: + laserParticleType = ParticleType.LASER_BEAM_SINGLE; + break; + case WALL_LASER_DOUBLE: + laserParticleType = ParticleType.LASER_BEAM_DOUBLE; + break; + case WALL_LASER_TRIPLE: + laserParticleType = ParticleType.LASER_BEAM_TRIPLE; + break; + default: + throw new IllegalArgumentException("Invalid laser type encountered."); + } Particle laserParticle = new Particle(laserParticleType, laserDirection); int positionX = addPosition.getXCoordinate(); int positionY = addPosition.getYCoordinate(); diff --git a/src/main/java/inf112/fiasko/roborally/utility/IOUtil.java b/src/main/java/inf112/fiasko/roborally/utility/IOUtil.java index 7bb2d9f..441ccc4 100644 --- a/src/main/java/inf112/fiasko/roborally/utility/IOUtil.java +++ b/src/main/java/inf112/fiasko/roborally/utility/IOUtil.java @@ -150,7 +150,7 @@ public final class IOUtil { direction = tile.getDirection(); } else if (element.getClass().isAssignableFrom(Wall.class)) { Wall wall = (Wall) element; - hasRotatedTexture = true; + hasRotatedTexture = TextureConverterUtil.hasRotatedTexture(wall); direction = wall.getDirection(); } else if (element.getClass().isAssignableFrom(Particle.class)) { Particle particle = (Particle) element; diff --git a/src/main/java/inf112/fiasko/roborally/utility/TextureConverterUtil.java b/src/main/java/inf112/fiasko/roborally/utility/TextureConverterUtil.java index 21e2b61..7df0458 100644 --- a/src/main/java/inf112/fiasko/roborally/utility/TextureConverterUtil.java +++ b/src/main/java/inf112/fiasko/roborally/utility/TextureConverterUtil.java @@ -34,6 +34,7 @@ public final class TextureConverterUtil { private static Map tileSheetParticleTextureMappings; private static Map tileSheetParticleHasRotatedTextureMappings; private static Map tileSheetWallTextureMappings; + private static Map tileSheetWallHasRotatedTextureMappings; private TextureConverterUtil() { } @@ -186,6 +187,25 @@ public final class TextureConverterUtil { return tileSheetTileHasRotatedTextureMappings.get(tile.getTileType()); } + /** + * Checks whether a wall has textures for different rotations + * + *

For a wall without a rotated texture, the texture needs to be rotated when rendering.

+ * + * @param wall The wall to check + * @return True if rotated versions of the texture exists. False otherwise + */ + public static boolean hasRotatedTexture(Wall wall) { + if (tileSheetWallTextureMappings == null) { + try { + loadTileMappings(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return tileSheetWallHasRotatedTextureMappings.get(wall.getWallType()); + } + /** * Checks whether a particle has textures for different rotations * @@ -256,6 +276,7 @@ public final class TextureConverterUtil { */ private static synchronized void loadWallMappings() throws IOException { tileSheetWallTextureMappings = new HashMap<>(); + tileSheetWallHasRotatedTextureMappings = new HashMap<>(); InputStream fileStream = ResourceUtil.getResourceAsInputStream("texture_sheet_wall_mapping.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(fileStream)); String line; @@ -263,7 +284,7 @@ public final class TextureConverterUtil { String[] parameters = line.split(" "); WallType type = WallType.valueOf(parameters[0]); storeTextMappingInMap(parameters, type, tileSheetWallTextureMappings, - null); + tileSheetWallHasRotatedTextureMappings); } } diff --git a/src/main/resources/assets/tiles.png b/src/main/resources/assets/tiles.png index 9813cb7..6a2e3e0 100644 Binary files a/src/main/resources/assets/tiles.png and b/src/main/resources/assets/tiles.png differ diff --git a/src/main/resources/boards/all_tiles_test_board.txt b/src/main/resources/boards/all_tiles_test_board.txt index 86c8478..acf8922 100644 --- a/src/main/resources/boards/all_tiles_test_board.txt +++ b/src/main/resources/boards/all_tiles_test_board.txt @@ -1,4 +1,4 @@ -8 21 +8 22 01;1 01;3 01;5 01;7 02;1 02;3 02;5 02;7 03;1 03;3 03;5 03;7 04;1 04;3 04;5 04;7 05;1 05;3 05;5 05;7 06;1 06;3 06;5 06;7 @@ -20,6 +20,7 @@ 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 +01;1 01;1 01;1 01;1 01;1 01;1 01;1 01;1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 @@ -40,4 +41,5 @@ 0 0 0 0 0 0 0 0 1;1 1;3 1;5 1;7 2;2 2;4 2;6 2;8 3;1 3;3 3;5 3;7 4;1 4;3 4;5 4;7 -5;1 5;3 5;5 5;7 6;1 6;3 6;5 6;7 \ No newline at end of file +5;1 5;3 5;5 5;7 6;1 6;3 6;5 6;7 +7;1 7;3 7;5 7;7 0 0 0 0 \ No newline at end of file diff --git a/src/main/resources/texture_sheet_wall_mapping.txt b/src/main/resources/texture_sheet_wall_mapping.txt index d3ff803..68bb4e8 100644 --- a/src/main/resources/texture_sheet_wall_mapping.txt +++ b/src/main/resources/texture_sheet_wall_mapping.txt @@ -3,4 +3,5 @@ WALL_CORNER 7 1 7 0 7 3 7 2 WALL_LASER_SINGLE 4 5 5 5 4 4 5 4 WALL_LASER_DOUBLE 5 11 6 11 6 10 4 11 WALL_PUSHER_ODD 0 1 1 1 2 0 3 1 -WALL_PUSHER_EVEN 0 0 1 0 2 1 3 0 \ No newline at end of file +WALL_PUSHER_EVEN 0 0 1 0 2 1 3 0 +WALL_LASER_TRIPLE 6 13 \ No newline at end of file