Example #1
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (GameManager.Instance.Pause)
        {
            return;
        }

        if (!harvesting && (collision.gameObject.transform.position - this.transform.position).sqrMagnitude <= 1.0f && collision.gameObject.CompareTag("Flower"))
        {
            harvestingCollider         = collision;
            harvestingCollider.enabled = false;
            harvesting = true;
            ScrollManager.Instance.StopScroll();
            rgdBdy.gravityScale = 0.0f;
            _animator.SetBool("Eating", true);
            GameObject particles = Instantiate(pollenParticles, this.transform.position, Quaternion.identity);
            Destroy(particles, particles.GetComponent <ParticleSystem>().main.duration);
            flower.Play();
        }

        if (!harvesting && !_dmgEffect.Invincible() && collision.gameObject.CompareTag("Bird"))
        {
            _currentNectar = Mathf.Max(0f, _currentNectar - 6.0f);
            _dmgEffect.MakeInvincible();
            _justHit = true;
            bird.Play();
        }

        if (collision.gameObject.CompareTag("Tree"))
        {
            moveToHive   = true;
            hiveLocation = collision.gameObject.GetComponentInChildren <Hive>().GetLocation();
            ScrollManager.Instance.StopScroll();
            rgdBdy.gravityScale = 0.0f;
            rgdBdy.velocity     = Vector2.zero;
        }
    }