예제 #1
0
 void CheckIfCorrect(ButtonScript butt)
 {
     //Pressed buttons start at 1 and toPress start at 0 so you have to minus here when checking
     if (pressed[timesPressed - 1] - 1 == toPress[timesPressed - 1])
     {
         correct++;
         if (correct == 6)
         {
             ShowWon(true);
             if (!source.isPlaying)
             {
                 AudioSource[] sources = FindObjectsOfType <AudioSource>();
                 foreach (var item in sources)
                 {
                     item.Stop();
                 }
                 source.PlayOneShot(right);
             }
             info.AddTimesCorrect();
             StopAllCoroutines();
             GameManager.hasFinishedTutorial = true;
             ShowXs(false);
             Invoke("StartAgain", 2f);
         }
     }
     else
     {
         butt.ColorChanger();
         waiting = false;
         info.ResetWinStreak();
         ShowXs(true);
         if (!source.isPlaying)
         {
             AudioSource[] sources = FindObjectsOfType <AudioSource>();
             foreach (var item in sources)
             {
                 item.Stop();
             }
             source.PlayOneShot(wrong);
         }
         if (canRestart)
         {
             Invoke("StartAgain", 1.5f);
         }
     }
 }