Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.isTrigger)
        {
            if (other.gameObject.CompareTag("mallet"))
            {
                GameObject sparks = other.gameObject.transform.GetChild(3).gameObject;
                sparks.GetComponent <ParticleSystem>().Play();
                if (songController.playMode == PlayMode.Stepped && shouldPlay)
                {
                    Play(Color.green);
                    shouldPlay = false;

                    if (activeProgress != null)
                    {
                        StopCoroutine(activeProgress);
                    }
                    mat.SetFloat("_Progress", 0);
                    if (songController.CheckNotes(pitch))
                    {
                        IgniteFireMallet();
                    }
                    else
                    {
                        ExtinguishFireMallet();
                    }
                    instrument.OnKeyHit(this);
                }
                else if (songController.playMode == PlayMode.Stepped && !shouldPlay)
                {
                    if (songController.CheckNotes(pitch))
                    {
                        IgniteFireMallet();
                    }
                    else
                    {
                        ExtinguishFireMallet();
                    }
                    Play(Color.red);
                }
                else
                {
                    if (songController.CheckNotes(pitch))
                    {
                        IgniteFireMallet();
                    }
                    else
                    {
                        ExtinguishFireMallet();
                    }
                    Play(Color.green);
                }
            }
        }
    }