import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import java.io.*; import java.util.ArrayList; import java.util.Arrays; public class MapReader implements Serializable { public static int x = 0; public static int y = 0; public static int TileX = 0; public static int TileY = 0; //Input game map /* 1: Normal Grass 2: Left Grass: 3: Right Grass: Grass Tiling: qwe asd zxc !: Slime v= background Grass: */ //o = steel // u // h k Shooting // m public static void inputMap(String filePath) throws IOException, SpriteException, UnsupportedAudioFileException, LineUnavailableException { x = 0; y = 0; GameFrame.game.enemy.clear(); GameFrame.game.particleTiles.clear(); GameFrame.game.shootingTiles.clear(); GameFrame.game.fireballs.clear(); for(int i=0; i0&&GameFrame.game.map[x][y-1]==null) { GameFrame.game.particleTiles.add(GameFrame.game.map[x][y]); } } else if(file.charAt(i)=='o'){ newTile("img/tiles/boxes/steel.png"); GameFrame.game.map[x][y].movable = true; } else if(file.charAt(i)=='h'){ newTile("img/tiles/boxes/boxShootLeft.png"); GameFrame.game.map[x][y].shootingDir = "left"; GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]); } else if(file.charAt(i)=='u'){ newTile("img/tiles/boxes/boxShootUp.png"); GameFrame.game.map[x][y].shootingDir = "up"; GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]); } else if(file.charAt(i)=='k'){ newTile("img/tiles/boxes/boxShootRight.png"); GameFrame.game.map[x][y].shootingDir = "right"; GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]); } else if(file.charAt(i)=='m'){ newTile("img/tiles/boxes/boxShootDown.png"); GameFrame.game.map[x][y].shootingDir = "down"; GameFrame.game.shootingTiles.add(GameFrame.game.map[x][y]); } x+=1; } } public static String[] inputDialogue(String mapFilePath) throws IOException { String filePath = mapFilePath.replace(".txt", "-dialogue.txt"); return FileManager.readFile(filePath).split("\n"); } public static ArrayList inputSign(String signFilePath) throws IOException { String filePath = signFilePath.replace(".txt", "-signs.txt"); String[] temporaryStringArray = FileManager.readFile(filePath).split("\n"); ArrayList returnArray = new ArrayList(); for (String s: temporaryStringArray) { returnArray.add(s.split(" ", 3)); } return returnArray; } public static void newTile(String filePath) throws IOException, SpriteException { GameFrame.game.map[x][y]=(new SingleTile(TileX,TileY, new BufferedImageWrapper((filePath)))); } }