public int TakeDamage(int damages) { m_hp -= damages; m_ui.SetLifeBarFill(m_hp / 100.0f); if (m_hp <= 0) { PlayDeathSound(); Destroy(gameObject); } return(m_hp); }
public void SetHP(int hp) { if (hp < 0) { hp = 0; } if (hp > m_maxHp) { hp = m_maxHp; } m_hp = hp; m_ui.SetLifeBarFill(m_hp / (float)m_maxHp); }