void UpdateUI() { if (attemptNum < attempts.Count) { if (isTestRunning) { ProcedureAttempt currentAttempt = attempts[attemptNum]; attemptInfo.color = Color.green; attemptInfo.text = "Attempt # " + (attemptNum) + " Time: " + (Time.realtimeSinceStartup - currentAttempt.timeStarted); prompt.text = "Press Enter to End Test"; prompt.color = Color.white; } else { attemptInfo.color = Color.white; prompt.text = "Press Enter to Start Test"; prompt.color = Color.blue; if (attempts.Count > 0) { ProcedureAttempt lastAttempt = attempts[attemptNum]; attemptInfo.text = "Last attempt: " + lastAttempt.summaryText; } } } }
void StartAttempt() { isTestRunning = true; RestartTest(); var newAttempt = new ProcedureAttempt(); newAttempt.timeStarted = Time.realtimeSinceStartup; attempts.Add(newAttempt); attemptNum = attempts.Count - 1; //return CheckForPunctureState. }
//sets attempt details and returns true if success bool EndAttempt() { isTestRunning = false; ProcedureAttempt currentAttempt = attempts[attemptNum]; if (currentAttempt != null) { currentAttempt.timeEnded = Time.realtimeSinceStartup; var currentLayer = PenetrableMaterial.GetLayer(HapticNativePlugin.getLastLayerPenetratedID()); currentAttempt.notes = "ended in: " + currentLayer.m_name; if (duraPunctured) { currentAttempt.notes += ", Dura punctured"; } currentAttempt.success = (currentLayer == targetLayer); string result; if (currentAttempt.success) { result = "success"; } else { result = "failure, "; } currentAttempt.summaryText = "Attempt # " + attemptNum + ": " + result + ", Duration: " + (currentAttempt.timeEnded - currentAttempt.timeStarted) + ", " + currentAttempt.notes;; return(currentAttempt.success); } else { return(false); } }