Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Reward"))
        {
            fishBoneAudio.Play();
            fishBone++;
            uiManagement.UpdateReward(fishBone);
            other.transform.parent.gameObject.SetActive(false);
        }

        if (invincible)
        {
            return;
        }
        if (other.CompareTag("Obstacle"))
        {
            canMove = false;
            currentLife--;
            uiManagement.UpdateHealth(currentLife);
            anim.SetTrigger("Hit");
            speed = 0;
            if (currentLife <= 0)
            {
                deadAudio.Play();
                speed = 0;
                anim.SetBool("Dead", true);
                uiManagement.gameOverPanel.SetActive(true);
                Invoke("CallMenu", 2f);
            }
            else
            {
                hurtAudio.Play();
                Invoke("CanMove", 0.75f);
                StartCoroutine(InvincibleTimer(invincibleTime));
            }
        }
    }