Example #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "Wubs")
        {
            foreach (var star in stars.Where(x => x != null))
            {
                StartCoroutine(SpriteHelper.FadeOut(star.GetComponentInChildren <SpriteRenderer>(), 1.0f));
            }

            if (!collected)
            {
                Instantiate(starDust, transform.position, Quaternion.Euler(0, 0, 0), transform.parent);
                StarController.CollectStar(starSource);
                collected = true;
            }


            Destroy(this.gameObject, 3.75f);
        }
    }