|
@ -68,10 +68,11 @@ public class Map { |
|
|
|
|
|
|
|
|
public Vector2 playerSpawn = new Vector2(2,2); |
|
|
public Vector2 playerSpawn = new Vector2(2,2); |
|
|
public char playerSpawnChar = 's'; |
|
|
public char playerSpawnChar = 's'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map(String[] mapData, GameManager gameManager) { |
|
|
public Map(String[] mapData, GameManager gameManager) { |
|
|
GenerateMap(mapData); |
|
|
|
|
|
this.gameManager = gameManager; |
|
|
this.gameManager = gameManager; |
|
|
|
|
|
GenerateMap(mapData); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void GenerateMap(String[] mapData) { |
|
|
public void GenerateMap(String[] mapData) { |
|
@ -82,6 +83,8 @@ public class Map { |
|
|
|
|
|
|
|
|
cells = new Cell[size.x][size.y]; |
|
|
cells = new Cell[size.x][size.y]; |
|
|
|
|
|
|
|
|
|
|
|
ghostSpawns = new Vector2[10]; |
|
|
|
|
|
|
|
|
for(int x = 0; x < size.x; x++) { |
|
|
for(int x = 0; x < size.x; x++) { |
|
|
for(int y = 0; y < size.y; y++) { |
|
|
for(int y = 0; y < size.y; y++) { |
|
|
Vector2 cellPos = new Vector2(x,y); |
|
|
Vector2 cellPos = new Vector2(x,y); |
|
@ -92,6 +95,12 @@ public class Map { |
|
|
|
|
|
|
|
|
cells[x][y] = new Cell(cellPos, cellType, this); |
|
|
cells[x][y] = new Cell(cellPos, cellType, this); |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < gameManager.ghosts.length; i++) { |
|
|
|
|
|
if(cellChar == ghostSpawnChars.charAt(i)) { |
|
|
|
|
|
ghostSpawns[i] = cellPos.Clone(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(cellChar == playerSpawnChar) { |
|
|
if(cellChar == playerSpawnChar) { |
|
|
playerSpawn = cellPos.Clone(); |
|
|
playerSpawn = cellPos.Clone(); |
|
|
} |
|
|
} |
|
@ -110,28 +119,7 @@ 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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String FindPath(Vector2 from, Vector2 to) |
|
|
public String FindPath(Vector2 from, Vector2 to) |
|
|
{ |
|
|
{ |
|
|
char[][] tempMap = new char[size.x][size.y]; |
|
|
char[][] tempMap = new char[size.x][size.y]; |
|
|