Exemplo n.º 1
0
 private void Start()
 {
     testManagerObject = GameObject.Find("The Testing Ground");
     testHandler       = GameObject.Find("The Testing Ground").GetComponent <testHandler>();
     crash             = GameObject.Find("Crash_indicator").GetComponent <Animator>();
     crashBG           = GameObject.Find("BulletHitIndicator").GetComponent <Animator>();
     audioSource       = gameObject.GetComponent <AudioSource>();
     inGameHelper      = GameObject.Find("InGame SubManager").GetComponent <InGameHelper>();
 }
    // Use this for initialization
    void OnEnable()
    {
        try{
            inGameHelper = GameObject.Find("InGame SubManager").GetComponent <InGameHelper>();
        }catch {}

        sfx_source = this.GetComponent <AudioSource>();
        isCorrect  = testManager.GetComponent <testHandler>().isCorrect;

        var aiCount = GameObject.FindGameObjectsWithTag("AI");

        //play appropriate sound effect
        if (!isCorrect)
        {
            testManager.GetComponent <testHandler>().mistakeCount += 1;            // add 1 to every mistake the player makes

            icon.sprite = sprite_mistake;

            sfx_source.PlayOneShot(sfx_warning);

            if (aiCount.Length >= 3)
            {
                // play intense music
                if (isCalm)
                {
                    inGameHelper.GetComponent <AudioSource>().Stop();
                    inGameHelper.intenseMusicPlay();

                    isCalm = false;
                }
            }
        }
        else
        {
            icon.sprite = sprite_correct;
            sfx_source.PlayOneShot(sfx_correct);

            if (aiCount.Length <= 0)
            {
                if (!isCalm)
                {
                    inGameHelper.GetComponent <AudioSource>().Stop();
                    inGameHelper.playCalmTheme();

                    isCalm = true;
                }
            }
        }

        StartCoroutine(closeTime(timeSettings));
    }