private void loadLevel(bool isLevel2) { GameObject topLeft = new GameObject(); topLeft.transform.SetParent(gameObject.transform); topLeft.name = "topLeft"; LevelMap levelMap = new LevelMap(); int tileID; float angle; for (int y = 14; y >= 0; y--) { for (int x = 0; x < 14; x++) { if (levelMap.isNothing(tileID = levelMap.getValue(y, x))) { continue; } angle = levelMap.getAngle(y, x); Instantiate( tiles[tileID - 1], new Vector3(x, 14 - y, 0), Quaternion.Euler(new Vector3(0, 0, angle)), topLeft.transform); } } string[] names = { "topRight", "bottomLeft", "bottomRight" }; Vector3[] positions = { new Vector3(27, 0, 0), new Vector3(0, 0, 0), new Vector3(27, 0, 0) }; Vector3[] rots = { new Vector3(0, 180, 0), new Vector3(180, 0, 0), new Vector3(180, 180, 0) }; GameObject[] levelParts = new GameObject[3]; for (int i = 0; i < 3; i++) { levelParts[i] = Instantiate(topLeft, positions[i], Quaternion.Euler(rots[i]), gameObject.transform); levelParts[i].name = names[i]; if (i != 0) { for (int j = 0; j < 2; j++) { Destroy(levelParts[i].transform.GetChild(1 - j).gameObject); } } foreach (Transform childTile in levelParts[i].transform) { if (!childTile.gameObject.CompareTag("Wall")) { childTile.localRotation = childTile.parent.localRotation; } } } GameObject points = new GameObject(); points.name = "points"; points.transform.SetParent(gameObject.transform); if (isLevel2) { topLeft.transform.position = new Vector3(14, 0, 0); levelParts[0].transform.position = new Vector3(14, 0, 0); levelParts[1].transform.position = new Vector3(14, 0, 0); levelParts[2].transform.position = new Vector3(14, 0, 0); } foreach (string tag in new string[] { "Points", "PowerUp" }) { foreach (GameObject tile in GameObject.FindGameObjectsWithTag(tag)) { tile.transform.SetParent(points.transform); } } textDisplay.BubbleCount(points); }