private void Generate() { int tries = 0; tryagain: _wiresColors = Enumerable.Range(0, 7).Select(x => (tEnum)Rnd.Range(0, 8)).ToArray(); if (!_secondStage) { Debug.LogFormat("[Thinking Wires #{0}] In stage 1, wires' colors from top to bottom are the following: [{1}]", _moduleId, string.Join(", ", _wiresColors.Select(t => t.ToString()).ToArray())); firstWireToCut = (int)_conditions.EvaluateFromIndex(_wiresColors, _visitedNode, 0, string.Format("[Thinking Wires #{0}] {{0}}: {{1}}", _moduleId)); SetDisplay(setOff: true); Debug.LogFormat("[Thinking Wires #{0}] The first wire to cut is wire {1}.", _moduleId, firstWireToCut); } else { _displayNumber = Rnd.Range(1, _visitedNode.Count + 1); if (!_wiresColors.Contains((tEnum)_visitedNode[_displayNumber - 1].BoxColor)) { tries++; if (tries < 3) { goto tryagain; } _displayNumber = 69; _secondWireToCutEnum = null; } else { _secondWireToCutEnum = _visitedNode[_displayNumber - 1].BoxColor; } screenNumber = _displayNumber.ToString("00"); Debug.LogFormat("[Thinking Wires #{0}] In stage 2, wires' colors from top to bottom are the following: [{1}]", _moduleId, string.Join(", ", _wiresColors.Select(t => t.ToString()).ToArray())); Debug.LogFormat("[Thinking Wires #{0}] The display number is {1}.", _moduleId, _displayNumber); secondWireToCut = _secondWireToCutEnum == null ? "Any" : _secondWireToCutEnum.ToString(); if (secondWireToCut == "Any") { Debug.LogFormat("[Thinking Wires #{0}] The second wire to cut can have any color.", _moduleId); } else { Debug.LogFormat("[Thinking Wires #{0}] The second wire to cut must have {1} color.", _moduleId, secondWireToCut.ToLowerInvariant()); } SetDisplay(); } foreach (TextMesh tx in ColorblindTexts) { tx.text = _wiresColors[Array.IndexOf(ColorblindTexts, tx)] == tEnum.Black ? "K" : _wiresColors[Array.IndexOf(ColorblindTexts, tx)].ToString().Substring(0, 1); } for (int i = 0; i < _allWires.Length; i++) { _allWiresMesh[i][0].material = Colors[(int)_wiresColors[i]]; _allWires[i][0].SetActive(true); _allWiresMesh[i][1].material = Colors[(int)_wiresColors[i]]; _allWires[i][1].SetActive(false); } }