QuizGame.RunGame()

In QuizGame.Start(), you’ll see that the game flow was kicked off with a call to:

        // begin the game
        StartCoroutine(RunGame());

Let’s look at RunGame():

    IEnumerator RunGame()
    {
        {   // TODO first wait for the phone to be upright
        }

        // Reset to the beginning of the list
        m_listElement = -1;
        bool isDone = NextQuestion();

        while (false == isDone)
        {
            {   // TODO wait for a choice (up or down)
                // then wait for 2 seconds
                // then wait for the phone to be re-centered
                // finally advance to the next question by calling NextQuestion()
            }
            yield return null;
        }

        // We are done... move on to the wrap-up screen
        SceneManager.LoadScene("End");
    }

For more information about Coroutines, check out this supplementary video: Coroutines

Wait for Center

The first TODO says to wait for the phone to be “upright” meaning centered.

        // TODO first wait for the phone to be upright

You’ll need a loop here

  • Inside the loop:
    • Call ReadInput()
    • yield return null
  • Continue the loop until QuizInput.center returned from ReadInput() is true

Wait for Up or Down

You’ll see we’ve already got a loop set up here:

        while (false == isDone)
        {
            // TODO wait for a choice (up or down)
            // then wait for 2 seconds
            // then wait for the phone to be re-centered
            // finally advance to the next question by calling NextQuestion()
            yield return null;
        }

We’ll be adding loops inside this loop.

  • Call ReadInput()
  • If the answer is neither up nor down:
    • yield return null
    • continue the loop
  • If the answer is up:
    • call Correct()
    • wait for a minimum of 2 seconds with a yield return new WaitForSeconds(2.0f)
    • Add your own loop to yield return null until ReadInput() returns center
  • If the answer is down:
    • call Wrong()
    • wait for a minimum of 2 seconds with a yield return new WaitForSeconds(2.0f)
    • Add your own loop to yield return null until ReadInput() returns center
  • After your up or down portion,
    • continue the loop

Your code for up and down are almost identical.
Feel free to combine those into a single shared block.
I won’t take off points if you do or don’t. It’s up to you.

The game should be fully functional now.