示例#1
0
    /* impact with word */
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Word"))
        {
            if (other.gameObject.GetComponent <WordController>().good)
            {
                PlaySound(true);
                //metrics.AddGoodWords(1);

                //adds the positives to the list
                stored.AddPositiveToList(level, other.gameObject.GetComponentInChildren <Text>());
                //expand halo & hit box
                halo.transform.localScale = new Vector3(halo.transform.localScale.x + 0.5f, halo.transform.localScale.y + 0.5f, 1);
                collider.radius          += 0.1f;

                //using the number of positives to determine win state
                if ((level == 1 && stored.levelOnePositiveList.Count >= stored.levelOneThreshold) ||
                    (level == 2 && stored.levelTwoPositiveList.Count >= stored.levelTwoThreshold))
                {
                    playing    = false;
                    audio.clip = endGoodClip;
                    audio.Play();
                    victory = true;
                }
            }
            else
            {
                PlaySound(false);
                ps.Play();
                //increase the negative word count
                negatives++;

                //using the negative counter to determine lose state
                if (negatives >= loseState)
                {
                    playing    = false;
                    audio.clip = endBadClip;
                    audio.Play();
                }
            }

            Destroy(other.gameObject);

            if (!playing)
            {
                stored.SetHighScore(level);
                StartCoroutine(SwitchScene());
            }
            //this is how it was before

            /*else
             * {
             *  Destroy(other.gameObject);
             * }*/
        }
    }