public void AddLevel() { GameObject.Destroy(activeLevels[0]); activeLevels.RemoveAt(0); GameObject newLevel = levels[Random.Range(0, levels.Count-1)]; LevelEndpoint endPoint = activeLevels[activeLevels.Count-1].GetComponentInChildren<LevelEndpoint>(); Instantiate(newLevel, endPoint.transform.position, endPoint.transform.rotation); activeLevels.Add(newLevel); }
IEnumerator InitLevels() { for (int i = 0; i < 4; i++) { if (i == 0) { GameObject newLevel = levels[0]; activeLevels.Add(newLevel); Instantiate(newLevel); } else { GameObject newLevel = levels[Random.Range(1, levels.Count-1)]; LevelEndpoint endPoint = activeLevels[activeLevels.Count-1].GetComponentInChildren<LevelEndpoint>(); activeLevels.Add(newLevel); Instantiate(newLevel); newLevel.transform.position = endPoint.transform.position; } } yield return null; }