public void RecomputeValues() { _numberOfBugs = 0; int inputCorrectValue = 4; int inputActualValue = 4; for (int counter = 0; counter < NumberOfLinesOfCode; counter++) { LineOfCodeBehavior b = LineOfCodeBehaviors[counter]; // Debug.Log("Counter " + counter); // Debug.Log("Correct " + inputCorrectValue); // Debug.Log("Actual " + inputActualValue); b.SetInputValueNoBugs(inputCorrectValue); b.SetInputValueWithBugs(inputActualValue); b.ComputeOutput(); // Debug.Log("compute"); // Set values for next line of code. inputCorrectValue = b.GetCorrectOutput(); inputActualValue = b.GetActualOutput(); // Debug.Log("Correct " + inputCorrectValue); // Debug.Log("Actual " + inputActualValue); // Update bug count. if (b.GetHasBug()) { // Debug.Log("Bug!!!!"); _numberOfBugs++; } // Debug.Log("-----------------"); } // Debug.Log("Bugs: " + _numberOfBugs); }
private void Awake() { for (int counter = 0; counter < NumberOfLinesOfCode; counter++) { // Make a line of code object. GameObject lineOfCode = Instantiate(lineOfCodePrefab, new Vector3(0, 0, 0), Quaternion.identity); // Child of panel. lineOfCode.transform.SetParent(linesOfCodeParent.transform, false); // Set its position. RectTransform t = lineOfCode.GetComponent <RectTransform>(); float top = LineOfCodeTopOffset + counter * (t.rect.height + LineOfCodeGap); t.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, LineOfCodeLeftOffset, t.rect.width); t.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, top, t.rect.height); // Tell it about its context. LineOfCodeBehavior b = lineOfCode.GetComponent <LineOfCodeBehavior>(); b.SetGameController(this); b.SetLineNumber(counter); // Remember the creations. LinesOfCode[counter] = lineOfCode; LineOfCodeBehaviors[counter] = b; } }
void Start() { _lineOfCode = transform.parent.gameObject; _lineOfCodeBehavior = _lineOfCode.GetComponent <LineOfCodeBehavior>(); }