|
|
@ -53,6 +53,7 @@ public class Map { |
|
|
|
this.put(i+"", "empty"); |
|
|
|
} |
|
|
|
}}; |
|
|
|
public GameManager gameManager; |
|
|
|
|
|
|
|
public Cell[][] cells; |
|
|
|
public Vector2 size; |
|
|
@ -60,12 +61,14 @@ public class Map { |
|
|
|
public Vector2 playerSpawn = new Vector2(2,2); |
|
|
|
public char playerSpawnChar = 's'; |
|
|
|
|
|
|
|
public Map() { |
|
|
|
public Map(GameManager gameManager) { |
|
|
|
initializeGhostSpawns(); |
|
|
|
GenerateMap(mapClassic); |
|
|
|
this.gameManager = gameManager; |
|
|
|
} |
|
|
|
|
|
|
|
public Map(String[] mapData) { |
|
|
|
public Map(String[] mapData,GameManager gameManager) { |
|
|
|
GenerateMap(mapData); |
|
|
|
this.gameManager = gameManager; |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateMap(String[] mapData) { |
|
|
@ -87,6 +90,8 @@ public class Map { |
|
|
|
|
|
|
|
cells[x][y] = new Cell(cellPos, cellType); |
|
|
|
|
|
|
|
//for(int i = 0; i < gameManager.ghosts.length; i++) |
|
|
|
|
|
|
|
if(cellChar == playerSpawnChar) { |
|
|
|
playerSpawn = cellPos.Clone(); |
|
|
|
} |
|
|
@ -105,4 +110,25 @@ public class Map { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
private void initializeGhostSpawns() { |
|
|
|
int count = 0; |
|
|
|
for (int y = 0; y < mapClassic.length; y++) { |
|
|
|
for (int x = 0; x < mapClassic[y].length(); x++) { |
|
|
|
char cellChar = mapClassic[y].charAt(x); |
|
|
|
if (ghostSpawnChars.indexOf(cellChar) != -1) { |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ghostSpawns = new Vector2[count]; |
|
|
|
count = 0; |
|
|
|
for (int y = 0; y < mapClassic.length; y++) { |
|
|
|
for (int x = 0; x < mapClassic[y].length(); x++) { |
|
|
|
char cellChar = mapClassic[y].charAt(x); |
|
|
|
if (ghostSpawnChars.indexOf(cellChar) != -1) { |
|
|
|
ghostSpawns[count++] = new Vector2(x, mapClassic.length - 1 - y); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |