/// <summary> /// Get healed. /// </summary> /// <param name="recoveryPoints">float - how many points the player recovers.</param> /// <param name="playSound">bool - whether to play default recovery sounds. True by default.</param> /// <param name="alternativeSound">AudioClip - alternative healing sound. Not required.</param> public void RecoverHP(float recoveryPoints, bool playSound = true, AudioClip alternativeSound = null) { if (playerData.hitPoints < playerData.maxHitPoints) { // update player damage. playerData.UpdateHitPoints(recoveryPoints); // play healing sound. if (playSound) { if (alternativeSound != null) { Debug.Log(_audio); _audio.PlayClip(alternativeSound); } else { _audio.PlaySound(3); } } // display UI elements. if (GamePlayUI.instance != null) { GamePlayUI.instance.PlayerHealed(); } } }
/// <summary> /// Reproduce song. /// </summary> /// <param name="clip">AudioClip - audio clip to reproduce</param> /// <param name="inmediateStart">bool - wheter to start the song inmediately or fade songs.</param> private IEnumerator ReproduceSong(AudioClip clip, bool inmediateStart) { if (_audio != null) { if (inmediateStart) { _audio.PlayClip(clip); } else { StartCoroutine(_audio.FadeOutSongRoutine(0.3f, false)); yield return(new WaitForSecondsRealtime(2.5f)); _audio.PlayClip(clip, false); StartCoroutine(_audio.FadeInSongRoutine(0.7f, 0f, .5f)); } } }
public void PlayMusic(int clip) { mus.PlayClip(clip); }
public void PlayEffect(int clip) { fx.PlayClip(clip); }
/// <summary> /// Play song for this level. /// </summary> /// <param name="songName">AudioClip - song name to play</param> public void PlayLevelSong(AudioClip clip) { audio.PlayClip(clip); }