// Update is called once per frame public void Run() { switch( state ) { case "initialize": GameObject cent = Instantiate( centerTestObj, Main.center, cylQuat ) as GameObject; centerScript = cent.GetComponent<CenterTest>(); state = "centering"; break; case "centering": if( centerScript.Test() ) { if( CallTimer( delayDur ) ) { goto case "set variables"; } else { break; } } else { testTimer = null; break; } case "set variables": varis = new Variables( signalRadius ); thisCue = Instantiate( cue, Main.center, cylQuat ) as GameObject; thisCue.renderer.material = cueMaterials[varis.cueIndex]; state = "cue"; goto case "cue"; case "cue": if( centerScript.Test() ) { if( CallTimer( cueDur ) ) { Destroy( thisCue ); state = "wait"; goto case "wait"; } else { break; } } else { testTimer = null; Destroy( thisCue ); state = "centering"; break; } case "wait": if( centerScript.Test() ) { if( CallTimer( constantWaitDur ) ) { goto case "signal"; } else { break; } } else { testTimer = null; state = "centering"; break; } case "signal": thisSig = Instantiate(signal, varis.signalVec, Quaternion.identity) as GameObject; if( !varis.valid ) { thisSig.renderer.material = invalidSignalMat; } signalTime = Time.time; string displayMessage = "Signal displayed at " + Mathf.RoundToInt( Time.time * 1000 ).ToString() + System.Environment.NewLine; System.IO.File.AppendAllText( Main.path, displayMessage ); state = "testing"; goto case "testing"; case "testing": testing = true; if( CallTimer( reactDur ) ) { WriteData( true, -0.001F, -0.001F ); Destroy( thisSig ); Reset(); break; } else if( !centerScript.Test() ) { if( varis.valid ) { rt = Time.time - signalTime; state = "RTFound"; goto default; } else { WriteData( false, -0.001F, Time.time - signalTime ); Destroy( thisSig ); Reset(); break; } } break; default: break; } }