public void PlaceCounters() { /* * List<GameObject>lockersCopy = lockers; * List<GameObject>ventsCopy = vents; */ int pos; // We reset to all the questions again //CopyList(questionsCopy, questions); List <GameObject> ventsActive = new List <GameObject>(); for (int i = 0; i < 6; i++) { if (questions.Count > 0) { if (lockers.Count > 2) { pos = Random.Range(0, lockers.Count - 1); GameObject g = lockers[pos]; g.SetActive(true); lockers.RemoveAt(pos); CounterController cc = g.GetComponent <CounterController>(); cc.CreateCanvas(); pos = Random.Range(0, questions.Count - 1); cc.SetQuestion(questions[pos]); questions.RemoveAt(pos); } } if (questions.Count > 0) { pos = Random.Range(0, questions.Count - 1); Question q = questions[pos]; questions.RemoveAt(pos); for (int j = 0; j < 2; j++) { if (vents.Count > 0) { pos = Random.Range(0, vents.Count - 1); GameObject g = vents[pos]; g.SetActive(true); vents.RemoveAt(pos); CounterController cc = g.GetComponent <CounterController>(); cc.CreateCanvas(); cc.SetQuestion(q); ventsActive.Add(g); } } } } for (int i = 0; i < (ventsActive.Count / 2); i++) { GameObject g1 = ventsActive[2 * i]; GameObject g2 = ventsActive[2 * i + 1]; g1.GetComponent <Vent>().SetOppositeVent(g2.transform.position - new Vector3(1, 0, 0)); g2.GetComponent <Vent>().SetOppositeVent(g1.transform.position - new Vector3(1, 0, 0)); } }