A dif approach?

I thought he wanted us to research an index array(i’m coming from JS to C#) then i discovered lists so this is the way i fixed the numbers never showing up twice

private List<int> allGuesses = new List<int>();
   void nextGuess()
    {
        guess = (min + max) / 2 + Random.Range(0, 10);
        if (allGuesses.Contains(guess))
        {
            nextGuess();
            Debug.Log("already guessed that");
        } else
        {
            allGuesses.Add(guess);
        } 

        guessText.text = guess.ToString();

    } 

Idk it seemed less hassle to me than dealing with the UI, it can end up going to an infinite loop but then the scope of this can be increased to say if there are no numbers available which i havent guessed already you’re clearly lying and arent even guessing a number!

Oh alsosince the teacher really loves recycling instead of making more functions instead of having the sucess button do

  SceneManager.LoadScene(blahblah)

I found i can just link to the C# file externally from numberwizard!

   SceneLoader sceneLoader = (SceneLoader)FindObjectOfType(typeof(SceneLoader));
        sceneLoader.LoadNextScene();
1 Like

This is neat. I was thinking we had to make an array of guessed values too, but my array making skills weren’t very good so I failed. I like how elegant your solution is. But I also liked Rick’s. Just never would have thought of it myself.

Privacy & Terms