public void TakeDamage(sbyte damage) //Check the health conditions and update the health indicator in the GUI. { m_AudioMethods.PlayDamageSound(); // Play damage sound m_Health -= damage; if (m_Health <= 0) //Health cannot be negative { m_Health = 0; //Health cannot be lower than zero Die(); } //Debug.Log("Damage Received: " + damage); //Debug.Log("Health = " + m_Health); }
public void TakeDamage(sbyte damage) //Check the health conditions and update the health indicator in the GUI. { if (!m_ShieldActive) //Player has no shield { if (damage > 5) //Sound will be played only if damage is greater than 5 { m_AudioMethods.PlayDamageSound(); // Play damage sound } m_Health -= damage; //Reduce health if (m_Health <= 0) //Character is dead { m_Health = 0; //Health cannot be lower than zero Die(1); //Call die method because health reaching 0 } } else //Player has shield { StartCoroutine(DeactivatePowerUp(2, 0f)); //Deactivate shield } //Debug.Log("Damage Received: " + damage); //Debug.Log("Health = " + m_Health); }