/// <summary> /// Update the players health value and update the health display /// </summary> /// <param name="value">The new health value</param> public void SetHealth(int value) { health = value; healthBar.UpdateDisplay(health, MAX_HEALTH); if (health < 1) { health = 0; if (!GameManager.Instance.muteSFX) { audioSource.pitch = DEATH_PITCH; audioSource.PlayOneShot(deathSound, DEATH_VOLUME * GameManager.Instance.sfxVolume); } currentState = PlayerState.Dying; } }
/// <summary> /// Update the players health value and update the health display /// </summary> /// <param name="value">The new health value</param> public void SetHealth(int value) { health = value; healthBar.UpdateDisplay(health, MAX_HEALTH); if (health < 1) { lowHealth.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); health = 0; if (!GameManager.Instance.muteSFX) { //death sfx FMODUnity.RuntimeManager.PlayOneShot(playerDeath); } currentState = PlayerState.Dying; } else if (health < 3) { lowHealth.start(); } }