private void CreateNewCoin() { if (CoinsOnLevel < 10) { this.x = UnityEngine.Random.Range(0, Columns) * cellWidth; this.z = UnityEngine.Random.Range(0, Rows) * cellHeight; this.cell = mazeGenerator.GetMazeCell((int)x / 6, (int)z / 6); GameObject coin = Instantiate(GoalPrefab, new Vector3(this.x, 0.1f, this.z), Quaternion.Euler(90, 0, 0)) as GameObject; coin.transform.parent = transform; CoinsOnLevel++; } }
private void Start() { Enemies [1].SetActive(false); Enemies [2].SetActive(false); mazeGenerator = new MazeGen(Rows, Columns); mazeGenerator.GenerateMaze(); for (int row = 0; row < Rows; row++) { for (int column = 0; column < Columns; column++) { this.x = column * cellWidth; this.z = row * cellHeight; this.cell = mazeGenerator.GetMazeCell(row, column); GameObject tmp; tmp = Instantiate(Floor, new Vector3(x, 0, z), Quaternion.Euler(0, 0, 0)) as GameObject; tmp.transform.parent = transform; if (this.cell.WallRight) { tmp = Instantiate(Wall, new Vector3(x + cellWidth / 2, 0, z) + Wall.transform.position, Quaternion.Euler(0, 90, 0)) as GameObject; tmp.transform.parent = transform; } if (this.cell.WallFront) { tmp = Instantiate(Wall, new Vector3(x, 0, z + cellHeight / 2) + Wall.transform.position, Quaternion.Euler(0, 0, 0)) as GameObject; tmp.transform.parent = transform; } if (this.cell.WallLeft) { tmp = Instantiate(Wall, new Vector3(x - cellWidth / 2, 0, z) + Wall.transform.position, Quaternion.Euler(0, 270, 0)) as GameObject; tmp.transform.parent = transform; } if (this.cell.WallBack) { tmp = Instantiate(Wall, new Vector3(x, 0, z - cellHeight / 2) + Wall.transform.position, Quaternion.Euler(0, 180, 0)) as GameObject; tmp.transform.parent = transform; } } } }