Ejemplo n.º 1
0
 // 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;
     }
 }
Ejemplo n.º 2
0
    //private int coordControl = 0; // coordinates recording control
    // Use this for initialization
    void Start()
    {
        signalOffset = Mathf.Atan( ( 0.5F * signal.transform.localScale.y ) / signalRadius );
        cylQuat = Quaternion.Euler( new Vector3( 270.0F, 0.0F, 0.0F ) );

        leftCenter = false;
        accelerated = false;
        accelerationTime = "-1";

        coordinateRecording = false;
        fixedDeltaTime = 0.0f;

        gameoverTextScript = GameObject.Find("gameoverText").GetComponent<GameoverTextScript>();
        centerScriptL = GameObject.Find("centerTestL").GetComponent<CenterTest>();
        centerScriptR = GameObject.Find("centerTestR").GetComponent<CenterTest>();
        finalScoreTextScript = GameObject.Find("finalScoreText").GetComponent<FinalScoreTextScript>();
        redFlashControl = GameObject.Find("RedFlash").GetComponent<RedFlashControl>();
        centerSecondsScript = GameObject.Find("centerSeconds").GetComponent<CenterSecondsScript>();
        centerImageScriptL = GameObject.Find("centerImageL").GetComponent<CenterImageScript>();
        centerImageScriptR = GameObject.Find("centerImageR").GetComponent<CenterImageScript>();
        coords = new ArrayList();
        coordTimes = new ArrayList();

        StartJSONExport();
    }