示例#1
0
    public void UpdateHealth(int damage)
    {
        if (currHealth - damage > 0)
        {
            currHealth -= damage;
        }
        else
        {
            // player died
            currHealth = 0;

            // Change scene
            PlayerDie();
        }

        if (currHealth >= 0)
        {
            hearts[currHealth].SetActive(false);
        }

        m_foodManager.ExplodeForceOnFood();

        audioSource.PlayOneShot(hurtSound);
        StartCoroutine(Shake(shakeDuration, shakeMagnitude));
    }