mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Legger til triple lasere
This commit is contained in:
parent
2f7e9cf1fb
commit
efb1e4c03f
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 17 MiB After Width: | Height: | Size: 17 MiB |
@ -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
|
||||
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
|
@ -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
|
||||
WALL_PUSHER_EVEN 0 0 1 0 2 1 3 0
|
||||
WALL_LASER_TRIPLE 6 13
|
Loading…
x
Reference in New Issue
Block a user