Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (recording)
     {
         foreach (string button in buttons)
         {
             if (input.GetButtonDown(button))
             {
                 var responseTime = Time.time - recordingStartTime;
                 response.Add(new Response(button, responseTime));
                 break;
             }
         }
     }
 }
Beispiel #2
0
    //-------------------
    //DIFFERENT METHODS
    //-------------------

    IEnumerator PressButton()
    {
        float timer = 3f;

        //Get winner
        while (winner == null)
        {
            if (InputBroker.GetButtonDown("Interact1"))
            {
                winner = GameControl.instance.players [0];
            }
            else if (InputBroker.GetButtonDown("Interact2"))
            {
                winner = GameControl.instance.players [1];
            }
            else if (InputBroker.GetButtonDown("Interact3"))
            {
                winner = GameControl.instance.players [2];
            }
            else if (InputBroker.GetButtonDown("Interact4"))
            {
                winner = GameControl.instance.players [3];
            }

            //Subtract from the timer
            timer -= Time.unscaledDeltaTime;

            //If the time has run down, nobody has won
            if (timer <= 0)
            {
                break;
            }

            yield return(null);
        }
    }