Esempio n. 1
0
    IEnumerator showHint()
    {
        while (true)
        {
            if (pitchID == 0)
            {
                keyController.MatchReset();
                ShowPatternClip.Play();
                //Debug.Log("Set forever");
                GameObject.Find("InteractiveObjManager").GetComponent <InteractiveObjManager>().SetTextTimed(
                    "Match the spheres with your voice.\n Press Q to stop", -1);
            }
            if (pitchID > 0 || pitchID == -intermissionLength)
            {
                //get match result, replaced by matchResult temporarily
                if (forceMatch)
                {
                    matchResult = forceMatchResult;
                }
                else
                {
                    matchResult     = matcher.TestMatch();
                    matcher.enabled = false;
                    Debug.Log("Stop Listening");
                }

                if (matchResult == KeyMatcher.KeyMatchStatus.SUCCESS)
                {
                    matchSuccessClip.Play();
                    keyController.MatchSucceed();
                }
                else if (matchResult == KeyMatcher.KeyMatchStatus.FAILURE)
                {
                    matchFailClip.Play();
                    keyController.MatchFail();
                    pitchID = -1;
                }
                yield return(new WaitForSeconds(keyController.DestroySeconds));
            }

            if (pitchID == -intermissionLength)
            {
                keyController.testAllMatch();
                ShowPatternClip.Play();
            }

            float targetScale;
            if (pitchID >= 0)
            {
                targetScale = patternScale[(int)pattern[pitchID]];
                //this.transform.localScale = new Vector3(curScale, curScale, curScale);
            }
            else
            {
                targetScale = 0;
                //this.transform.localScale = new Vector3(0, 0, 0);
            }
            //SetTargetScale(targetScale);
            scaleChangeStep = (targetScale - this.transform.localScale.x) / (float)changeFrames;
            //Debug.Log(scaleChangeStep);
            pitchID++;
            if (pitchID == pattern.Length)
            {
                pitchID = -intermissionLength;
            }
            yield return(new WaitForSeconds(pitchLength));
        }
    }