/// <summary> /// fades out fullArt canvases and does callback after finishing fadeOut /// </summary> public void Hide(FadeSpeeds fadeOutMode, Action cb) { float fadeOutTime = Script_Utils.GetFadeTime(fadeOutMode); StartCoroutine( fullArtCanvasGroup .GetComponent <Script_CanvasGroupFadeInOut>() .FadeOutCo(fadeOutTime, () => { fullArtCanvasGroup.gameObject.SetActive(false); foreach (var bg in bgs) { bg.gameObject.SetActive(false); } fullArtImage.gameObject.SetActive(false); fullArtImage.sprite = null; if (cb != null) { cb(); } } ) ); }
/// <summary> /// Used to show predefined hint canvases /// </summary> public void FadeIn(Script_Hint hint, Action cb = null) { hintCanvasGroup.Initialize(); hint.gameObject.SetActive(true); hintCanvasGroup.gameObject.SetActive(true); float fadeTime = Script_Utils.GetFadeTime(hint.fadeSpeed); StartCoroutine(hintCanvasGroup.FadeInCo(fadeTime, cb)); }
public void FadeOut(FadeSpeeds fadeSpeed, Action cb) { float fadeOutTime = Script_Utils.GetFadeTime(fadeSpeed); StartCoroutine( GetComponent <Script_CanvasGroupFadeInOut>() .FadeOutCo(fadeOutTime, () => { if (cb != null) { cb(); } } ) ); }
public void FadeIn(FadeSpeeds fadeSpeed, Action cb, float maxAlpha = 1f) { float fadeInTime = Script_Utils.GetFadeTime(fadeSpeed); StartCoroutine( GetComponent <Script_CanvasGroupFadeInOut>() .FadeInCo(fadeInTime, () => { if (cb != null) { cb(); } }, maxAlpha ) ); }
public void FadeOut(Script_Hint hint, Action cb = null) { float fadeTime = Script_Utils.GetFadeTime(hint.fadeSpeed); StartCoroutine(hintCanvasGroup.FadeOutCo(fadeTime, OnFadedOut)); void OnFadedOut() { hint.gameObject.SetActive(false); hintCanvasGroup.gameObject.SetActive(false); hintCanvasGroup.Initialize(); if (cb != null) { cb(); } } }
/// <summary> /// Ensures other coroutine stops running /// Check if we're already fading out /// /// Note: This gameobject must be active to call this method (to run coroutine). /// </summary> public void FadeOut() { if (fadeInCoroutine != null) { StopCoroutine(fadeInCoroutine); fadeInCoroutine = null; } if (fadeOutCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); fadeOutCoroutine = StartCoroutine(spriteFader.FadeOutCo( null, t )); }
/// <summary> /// Note: This gameobject must be active to call this method (to run coroutine). /// </summary> public void FadeIn() { // if is fully faded out, then upon fading in, match up with player position if (fadeOutCoroutine != null) { StopCoroutine(fadeOutCoroutine); fadeOutCoroutine = null; } if (fadeInCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); fadeInCoroutine = StartCoroutine(spriteFader.FadeInCo( null, t )); }
public void FadeIn(Action cb, float?_fadeTime = null) { float fadeTime = _fadeTime ?? Script_Utils.GetFadeTime(fadeSpeed); StartCoroutine(spriteFader.FadeInCo(cb, fadeTime)); }
public static float ToFadeTime(this FadeSpeeds fadeSpeed) { return(Script_Utils.GetFadeTime(fadeSpeed)); }
// ------------------------------------------------------------------------------------- // Deprecated Old Seasons Utils public void ChangeSeason(string seasonStoneId, Action cb = null) { if (isPuzzleComplete) { return; } Seasons lastSeason = season; if (!SeasonStonesEnums.TryGetValue(seasonStoneId, out season)) { Debug.LogError($"Script_LevelBehavior_20: There is no season key {seasonStoneId}"); } /// CHANGE SEASON ANIMATION & SFX StartCoroutine(ChangeSeasonCutScene()); IEnumerator ChangeSeasonCutScene() { game.ChangeStateCutScene(); // TODO: could show some animation on drop yield return(new WaitForSeconds(waitToChangeCameraTime)); Script_VCamManager.VCamMain.SetNewVCam(vCamMid); yield return(new WaitForSeconds(waitToChangeSeasonTime)); // SFX AudioSource audioSource = GetComponent <AudioSource>(); audioSource.clip = Script_SFXManager.SFX.Rumble254ms; audioSource.volume = Script_SFXManager.SFX.Rumble254msVol; audioSource.Play(); FadeInOutSeason(); yield return(new WaitForSeconds(seasonChangeWaitTime)); Script_VCamManager.VCamMain.SwitchToMainVCam(vCamMid); yield return(new WaitForSeconds(revertCameraWaitTime)); game.ChangeStateInteract(); if (cb != null) { cb(); } } void FadeInOutSeason() { // if the season is the same, don't change the Sprite if (season == lastSeason) { return; } // fade out old season sprite if was one if (lastSeason != Seasons.None) { // get SeasonTree corresponding to it int seasonInt; SeasonInt.TryGetValue(lastSeason, out seasonInt); ManTrees[seasonInt].FadeOut(null); WomanTrees[seasonInt].FadeOut(null); } // fade in new season sprite if (season != Seasons.None) { // get SeasonTree corresponding to it int seasonInt; SeasonInt.TryGetValue(season, out seasonInt); ManTrees[seasonInt].FadeIn(null); WomanTrees[seasonInt].FadeIn(null); fadeTime = Script_Utils.GetFadeTime( WomanTrees[seasonInt].fadeSpeed ); } } }
private void HandleFadeOut() { if (fadeOutAxis == FadeOutAxis.None) { return; } if (CheckBounds()) { FadeIn(); } else { FadeOut(); } /// <summary> /// Ensure other coroutine stops running /// Check if we're already fading out /// </summary> void FadeOut() { if (fadeInCoroutine != null) { StopCoroutine(fadeInCoroutine); fadeInCoroutine = null; } if (isFadedOut || fadeOutCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); isFadedIn = false; fadeOutCoroutine = StartCoroutine(spriteFader.FadeOutCo( () => { isFadedOut = true; }, t )); } void FadeIn() { // if is fully faded out, then upon fading in, match up with player position if (isFadedOut) { InitializeState(); } if (fadeOutCoroutine != null) { StopCoroutine(fadeOutCoroutine); fadeOutCoroutine = null; } if (isFadedIn || fadeInCoroutine != null) { return; } float t = Script_Utils.GetFadeTime(fadeSpeed); isFadedOut = false; fadeInCoroutine = StartCoroutine(spriteFader.FadeInCo( () => { isFadedIn = true; }, t )); } }