mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-27 18:25:27 +02:00
Legger til triple lasere
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
@@ -544,7 +544,7 @@ public class Board {
|
||||
*/
|
||||
public void fireAllLasers() {
|
||||
List<BoardElementContainer<Wall>> 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();
|
||||
|
@@ -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;
|
||||
|
@@ -34,6 +34,7 @@ public final class TextureConverterUtil {
|
||||
private static Map<ParticleType, TextureConverterContainer> tileSheetParticleTextureMappings;
|
||||
private static Map<ParticleType, Boolean> tileSheetParticleHasRotatedTextureMappings;
|
||||
private static Map<WallType, TextureConverterContainer> tileSheetWallTextureMappings;
|
||||
private static Map<WallType, Boolean> 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
|
||||
*
|
||||
* <p>For a wall without a rotated texture, the texture needs to be rotated when rendering.</p>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user