IEnumerator PlaySequence(float pauseTimeBetweenSequencePlays) { inputRestricted = true; sequencePlaying = true; SetSphereInputRestricted(true); simon.ClearInputs(); int sequenceIndex = 0; if (startGameSound) { AudioSource parentAudioSource = transform.GetComponent <AudioSource>(); if (parentAudioSource) { parentAudioSource.clip = startGameSound; parentAudioSource.Play(); } } yield return(new WaitForSeconds(startUpBuffer)); while (sequenceIndex < inputSequence.Length) { int currentInputId = inputSequence[sequenceIndex]; simonSpheres[currentInputId].ApplySphereIntensity("selected"); AudioSource audioSource = transform.GetChild(currentInputId).GetComponent <AudioSource>(); if (audioSource) { audioSource.Play(); } yield return(new WaitForSeconds(modifiedAudioLength)); simonSpheres[currentInputId].ApplySphereIntensity("inactive"); sequenceIndex++; yield return(new WaitForSeconds(pauseTimeBetweenSequencePlays)); } SetSphereInputRestricted(false); inputRestricted = false; sequencePlaying = false; }