public FadeOut ( float fadeOutLength, float startToFadeTime ) : void | ||
fadeOutLength | float | |
startToFadeTime | float | |
return | void |
public static AudioSource FadeOutMusic(AudioSource pAudioSource, float FadeTime = 4.0f) { pAudioSource.loop = true; pAudioFader.FadeOut(pAudioSource, FadeTime); return(pAudioSource); }
// Begin playing the current Level public void StartNewLevel() { currentStage = GameStage.LevelPlaying; if (BackgroundMenuMusic.isPlaying) { StartCoroutine(AudioFader.FadeOut(BackgroundMenuMusic, 0.5f)); } backgroundMusicManager.StartBackgroundMusic(); if (LevelStartEvent != null) LevelStartEvent(); LevelSetupUI.SetActive(false); HUD.SetActive(true); LevelEndUI.SetActive(false); if (levelEnd != null) { Destroy(levelEnd); } Player.transform.position = Vector3.zero; GameEndSound.Stop(); }
IEnumerator LoadScene(string sceneName) { StartCoroutine(AudioFader.FadeOut(GameObject.Find("Main Camera").GetComponent <AudioSource>(), transitionTime)); transitionAnim.SetTrigger(triggerName); yield return(new WaitForSeconds(transitionTime)); SceneManager.LoadScene(sceneName, LoadSceneMode.Single); }
private IEnumerator CrossFadeAudio(int nextLevel) { yield return(StartCoroutine(AudioFader.FadeOut(BackgroundAudioSource, 0.5f))); currentLevel = nextLevel; BackgroundAudioSource.clip = collection[selectedCollection].BackgroundMusic[currentLevel]; yield return(StartCoroutine(AudioFader.FadeIn(BackgroundAudioSource, 0.5f))); }
// Begin playing the current Level public void StartNewLevel() { if (firstRun) { //If there is no date retrieved, this is the first time. var result = FizzyoFramework.Instance.Achievements.CheckAndUnlockAchievement(Achievements[0].AchievementName); if (result == FizzyoRequestReturnType.SUCCESS) { achievementAnimation.UnlockAchievmentUI(Achievements[0].AchievementName, Achievements[0].AchievementTag); } firstRun = false; } else { //Check if the user has been playing long enough for some achievements for (int i = 0; i < Achievements.Length; i++) { if (Achievements[i].DayRequirement > 0 && daysPlayed > Achievements[i].DayRequirement) { var result = FizzyoFramework.Instance.Achievements.CheckAndUnlockAchievement(Achievements[i].AchievementName); if (result == FizzyoRequestReturnType.SUCCESS) { achievementAnimation.UnlockAchievmentUI(Achievements[i].AchievementName, Achievements[i].AchievementTag); } } } } currentStage = GameStage.LevelPlaying; GameStarted = true; if (BackgroundMenuMusic.isPlaying) { StartCoroutine(AudioFader.FadeOut(BackgroundMenuMusic, 0.5f)); } backgroundMusicManager.StartBackgroundMusic(); if (LevelStartEvent != null) { LevelStartEvent(); } LevelSetupUI.SetActive(false); HUD.SetActive(true); LevelEndUI.SetActive(false); if (levelEnd != null) { Destroy(levelEnd); } Player.transform.position = Vector3.zero; GameEndSound.Stop(); }
private IEnumerator FadeOutStem_(int stemNr, float fadeT) { waitLock = true; if (audioPlayers[stemNr].volume > 0.0f) { // Fade out the stem. fader.FadeOut(audioPlayers[stemNr], fadeT, 0.0f); // Waits for its fade in time to pass. yield return(new WaitForSeconds(fadeTime)); stemsPlaying--; } waitLock = false; }
public void OnTriggerExit(Collider other) { Debug.Log("exit trigger" + this.gameObject.name); if (audioTrigger != null) { //use this to pause with no fade //audioTrigger.Pause(); //use this to fade out //StopAllCoroutines(); Debug.Log("EXIT trigger " + this.gameObject.name); StartCoroutine(AudioFader.FadeOut(audioTrigger, 2f)); } }
private IEnumerator FadeOutProgram() { StartCoroutine(AudioFader.FadeOut(_rainAudio, FadeTime)); var duration = 0f; var rain = MaxRain; while (duration < FadeTime) { rain -= MaxRain / (FadeTime * FadeSteps); _rainEmission.rateOverTime = rain; yield return(new WaitForSeconds(1f / FadeSteps)); duration += 1f / FadeSteps; } _rainVision.Stop(); _callback(); }
void FixedUpdate() { // Check against all layers except Player int layerMask = ~LayerMask.GetMask("Player"); // check a short capsule below the player to see if we're grounded isGrounded = Physics.CheckCapsule(playerCollider.bounds.center, new Vector3(playerCollider.bounds.center.x, playerCollider.bounds.min.y - 0.01f, playerCollider.bounds.center.z), 0.18f, layerMask); animator.SetBool("isGrounded", isGrounded); // Debug.Log("isGrounded: " + isGrounded.ToString()); moveVector = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, Input.GetAxisRaw("Vertical")); moveVector = Quaternion.Euler(0, Camera.main.transform.rotation.eulerAngles.y, 0) * moveVector; if (isGrounded) { rb.velocity += moveVector * acceleration * Time.deltaTime; } else { // Don't accelerate at full speed in the air rb.velocity += moveVector * acceleration * Time.deltaTime / 4.0f; } Vector3 translationalVelocity = new Vector3(rb.velocity.x, 0.0f, rb.velocity.z); if (translationalVelocity.sqrMagnitude > MoveSpeed * MoveSpeed) { // evil hardcoded drag constant translationalVelocity *= 0.75f; } // Debug.Log(translationalVelocity.magnitude); rb.velocity = new Vector3(translationalVelocity.x, rb.velocity.y, translationalVelocity.z); if ( moveVector.sqrMagnitude < 0.5f && isGrounded || translationalVelocity.sqrMagnitude > MoveSpeed * MoveSpeed ) { rb.drag = stoppingDrag; } else { rb.drag = originalDrag; } // If we're falling, apply stronger gravity to mitigate the floaty feel if (rb.velocity.y < 0.0f) { // * Note: Physics.gravity is taken to be negative, so we add it rb.velocity += Physics.gravity * fallMultiplier * Time.fixedDeltaTime; } if (isGrounded && rb.velocity.magnitude > 2f) { StepSounds(); } else { StartCoroutine(AudioFader.FadeOut(FootstepSrc, 2.0f)); } stepTimer += Time.deltaTime; }
// Fades out using the AudioFader object in deltaTime seconds. If no values is specified, it will use the // lowest mixer volume value. public void FadeOut(AudioFader fader, float deltaTime, float volume = minMixerVolume) { fadeFunction = fader.FadeOut(mixer, mixerParameter, deltaTime, volume); }
public void FadeOut(float fadeTime) { StartCoroutine(_audioFader.FadeOut(fadeTime, _audioSource)); }
public void StopBackgroundMusic() { StartCoroutine(AudioFader.FadeOut(BackgroundAudioSource, 0.5f)); }
public void CloseMouth() { _frogAnimation.OpenFrog(false); fadingCoroutine = _audioFader.FadeOut(0.1F, _audioSource); StartCoroutine(fadingCoroutine); }