// Use this for initialization void Begin() { GameObject currLevel = Instantiate(level); StreamReader inp_strm = new StreamReader(filePath); started = true; board = new List <GameObject[]>(); tileTypes = new List <string[]> (); wallTypes = new List <string>(13); wallTypes.Add("VL"); wallTypes.Add("VR"); wallTypes.Add("HT"); wallTypes.Add("HB"); wallTypes.Add("W"); wallTypes.Add("G"); int boardHeight = 0; while (!inp_strm.EndOfStream) { string line = inp_strm.ReadLine(); board.Add(new GameObject[line.Length]); tileTypes.Add(new string[line.Length]); for (int i = 0; i < line.Length; ++i) { char c = line [i]; tileTypes [boardHeight] [i] = "."; if (c == 'W') { board [boardHeight] [i] = Instantiate(wall, currLevel.transform); tileTypes [boardHeight] [i] = "W"; } else if (c == 'G') { board [boardHeight] [i] = Instantiate(wall, currLevel.transform); tileTypes [boardHeight] [i] = "G"; } else if (c == 'w') { board [boardHeight] [i] = Instantiate(emptyWallCell, currLevel.transform); } else if (c == '.') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject pelletSpawned = Instantiate(pellet, currLevel.transform); pelletSpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'E') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject pelletSpawned = Instantiate(powerPellet, currLevel.transform); pelletSpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == ' ') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); } else if (c == 'I') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject inkySpawned = Instantiate(inky, currLevel.transform); inkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'P') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject pinkySpawned = Instantiate(pinky, currLevel.transform); pinkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'B') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject blinkySpawned = Instantiate(blinky, currLevel.transform); blinkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'C') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject clydeSpawned = Instantiate(clyde, currLevel.transform); clydeSpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'M') { board [boardHeight] [i] = Instantiate(emptyCell, currLevel.transform); GameObject pacmanSpawned = Instantiate(pacman, currLevel.transform); pacmanSpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); originalPacmanPosition = pacmanSpawned.transform.position; } board [boardHeight] [i].transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } boardHeight++; } inp_strm.Close(); /**/ OrientWalls(); ui.ReadHighScore(); // Send new board to pathfinding algo path.InitGraph(new List <GameObject[]>(board)); if (hive) { hive.Init(); } }