Esempio n. 1
0
    public void LoseHealth(int healthDelta)
    {
        m_currentHealth -= healthDelta;
        GameObject particle = Instantiate(bloodParticle, transform.position, transform.rotation) as GameObject;

        Destroy(particle, 1f);

        if (!m_PlayAudio.isPlaying())
        {
            m_PlayAudio.PlayClip(HurtSound);
        }

        if (m_currentHealth <= 0)
        {
            Destroy(this.gameObject);
            if (remainsPrefab != null)
            {
                if (!remains)
                {
                    remains = Instantiate(remainsPrefab, this.transform.position, Quaternion.identity);
                }
                Destroy(remains, remainsDuration);
            }
        }
    }