public int GetNumOfLevels() { if (library == null) { library = new LevelLibrary(); } return(library.levels.Count); }
void Start() { units = new List <GameObject> (); library = new LevelLibrary(); foreach (Transform child in transform) { if (child.CompareTag(Tags.DARK)) { units.Add(child.gameObject); } } }
public void GenerateLevelcard(int id, Transform parent) { if (library == null) { library = new LevelLibrary(); } level = library.GetLevel(id); int index = 0; if (level != null) { for (int i = 0; i < level.units.Length; i++) { if (level.units[i] >= 0 && level.units[i] < level.units.Length) { Vector3 position = parent.position; position.x = unit_start_x + unit_width * index; if (units == null) { units = new List <GameObject> (); library = new LevelLibrary(); foreach (Transform child in transform) { if (child.CompareTag(Tags.DARK)) { units.Add(child.gameObject); } } } GameObject level_object = Instantiate(units[level.units[i]], position, parent.rotation, parent); // objectives float rate = Random.Range(0, 1f); if (rate >= 0.4f) { foreach (Transform child in level_object.transform) { if (child.CompareTag(Tags.OBJECTIVE_SMALL)) { Destroy(child.gameObject); } } } if (rate >= 0.8f) { foreach (Transform child in level_object.transform) { if (child.CompareTag(Tags.OBJECTIVE)) { Destroy(child.gameObject); } } } } index++; } } }