/// <summary> /// This is called when the page should be updated. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public virtual void Update(GameTime gameTime) { if (FadeState == FadeStates.Wait) { fadeStep++; if (fadeStep > fadeLength) { layer.CurrentPage = page; Goto(); fadeStep = 0; FadeState = FadeStates.FadeIn; } } else if (FadeState == FadeStates.FadeIn) { fadeStep++; if (fadeStep > fadeLength) { fadeStep = 0; FadeState = FadeStates.Visible; } } else if (FadeState == FadeStates.FadeOut) { fadeStep++; if (fadeStep > fadeLength) { fadeStep = 0; Leave(); FadeState = FadeStates.None; } } }
public void InitiateFadeLevel(string nextLevel) { currentFadeState = FadeStates.FadeOut; currentFadeType = FadeTypes.FadeLevel; sNextLevel = nextLevel; }
public void CloseBars(float durationSeconds, AnimationCurve curveToUse = null) { if (isAnimating) StopAllCoroutines(); state = FadeStates.Bars; AnimationCurve curCurve = (curveToUse != null) ? curveToUse : defaultBarsCloseCurve; StartCoroutine(AnimationRoutine(durationSeconds, curCurve)); }
private void ChangeFadeState(FadeStates fadeState, Color color, int duration, Action trigger) { this.fadeState = fadeState; logoSprite.Color = color; text.Color = color; timer = new Timer(duration, trigger, false); }
//-------------------------------------------------------------- // *** FRAME *** public void FixedUpdate() { // Precaution if (_UIPanel != null) { switch (_FadeState) { case FadeStates.idle: { // Hide panel _UIPanel.SetActive(false); _Fading = false; break; } case FadeStates.fadeIn: { // Show panel _UIPanel.SetActive(true); // Fade screen into COLOUR if (_Image.color.a < 1f) { _Image.color = new Color(_Image.color.r, _Image.color.g, _Image.color.b, _Image.color.a + _FadeRate); _Fading = true; } // Fade complete else { _FadeState = FadeStates.idle; } break; } case FadeStates.fadeOut: { // Show panel _UIPanel.SetActive(true); // Fade screen from COLOUR if (_Image.color.a > 0f) { _Image.color = new Color(_Image.color.r, _Image.color.g, _Image.color.b, _Image.color.a - _FadeRate); _Fading = true; } // Fade complete else { _FadeState = FadeStates.idle; } break; } default: { break; } } } }
public void SetBarVal(float newVal) { if (isAnimating) { StopAllCoroutines(); } state = FadeStates.Bars; animationVal = Mathf.Clamp01(newVal); }
public void CloseBars(float durationSeconds, AnimationCurve curveToUse = null) { if (isAnimating) { StopAllCoroutines(); } state = FadeStates.Bars; AnimationCurve curCurve = (curveToUse != null) ? curveToUse : defaultBarsCloseCurve; StartCoroutine(AnimationRoutine(durationSeconds, curCurve)); }
internal void FadeOut() { if (fadeState == FadeStates.FadeOut) { return; } FadeOut(FadeOutTime); fadeState = FadeStates.FadeOut; IsDisplayed = false; }
internal void FadeIn() { if (fadeState == FadeStates.FadeIn) { return; } FadeIn(FadeInTime); fadeState = FadeStates.FadeIn; IsDisplayed = true; }
/// <summary> /// Plays the cue with a fade in effect. If it is pause, it will resume the cue. /// </summary> public void Play() { _FadeTimer = 0f; _FadeState = FadeStates.FadeIn; if (IsPaused) { Cue.Resume(); } else { Cue.Play(); } }
public void OpenCircle(float durationSeconds, Vector2 viewportPos, AnimationCurve curveToUse = null) { if (isAnimating) { StopAllCoroutines(); } state = FadeStates.Circle; positionX = viewportPos.x; positionY = viewportPos.y; AnimationCurve curCurve = (curveToUse != null) ? curveToUse : defaultCircleOpenCurve; StartCoroutine(AnimationRoutine(durationSeconds, curCurve)); }
/// <summary> /// Ensure we always have an audio preview playing while on song selection. Silence sucks, after all. /// </summary> private void UpdateMusic(bool force = false) { if (audioError) { return; } if (GameBase.SixtyFramesPerSecondFrame || force) { switch (audioState) { case FadeStates.FadeOut: AudioEngine.SetVolumeMusicFade(AudioEngine.volumeMusicFade - 8); if (AudioEngine.volumeMusicFade <= 10) { try { if (BeatmapManager.Current != null) { AudioEngine.LoadAudioForPreview(BeatmapManager.Current, false, true); audioState = FadeStates.Idle; } } catch (Exception) { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.SongSelection_AudioError)); audioError = true; } } break; } } try { if (AudioEngine.AudioState == AudioStates.Stopped && AudioEngine.AllowRandomSong && BeatmapManager.Beatmaps.Count > 0 && GameBase.FadeState == FadeStates.Idle) { if (BeatmapManager.Current == null) { BeatmapManager.Current = BeatmapManager.Beatmaps[0]; } AudioEngine.LoadAudioForPreview(BeatmapManager.Current, true, true); } } catch { audioError = true; } }
/// <summary> /// Pauses the player. /// </summary> /// <param name="Fade">Whether to fade or not.</param> /// <returns>Returns true if player pauses playing</returns> public bool Pause(bool Fade) { try { if (!InFade && !InCrossfade) { if (PlayerState == PlayerStates.Playing) { if (Fade) { switch (PlayingPlayer) { case Players.Player1: StoppingPlayer = Players.Player1; PlayingPlayer = Players.NULL; break; case Players.Player2: StoppingPlayer = Players.Player2; PlayingPlayer = Players.NULL; break; } FadeState = FadeStates.Out; StartFade(); } else { switch (PlayingPlayer) { case Players.Player1: Player1.pause(); break; case Players.Player2: Player2.pause(); break; } } PlayerState = PlayerStates.Paused; return(true); } } } catch (Exception ex) { OnError.Invoke(new ErrorEventArgs("Pause : " + ex.Message)); } return(false); }
/// <summary> /// Starts the player playing the paused file. /// </summary> /// <param name="Fade">Whether to fade or not.</param> /// <returns>Returns true if player starts playing</returns> public bool Resume(bool Fade) { try { if (PlayerState == PlayerStates.Paused) { if (!InFade && !InCrossfade) { if (Fade) { FadeState = FadeStates.In; switch (StoppingPlayer) { case Players.Player1: PlayingPlayer = Players.Player1; break; case Players.Player2: PlayingPlayer = Players.Player2; break; } StartFade(); } else { switch (PlayingPlayer) { case Players.Player1: PlayingPlayer = Players.Player1; Player1.play(); break; case Players.Player2: PlayingPlayer = Players.Player2; Player2.play(); break; } } PlayerState = PlayerStates.Playing; } } } catch { } return(false); }
/// <summary> /// Fades the player's volume up/down to the specified level. /// </summary> /// <param name="ANewVolume">The volume to fade to.</param> /// <returns>Returns true if fade starts.</returns> public bool Fade(int ANewVolume) { try { if (!InFade && !InCrossfade && PlayerState == PlayerStates.Playing) { NewVolume = ANewVolume > 100 ? 100 : ANewVolume < 0 ? 0 : ANewVolume; InFade = true; FadeState = NewVolume < Volume ? FadeStates.Down : FadeStates.Up; StartFade(); } } catch (Exception ex) { OnError.Invoke(new ErrorEventArgs("Pause : " + ex.Message)); } return(false); }
private void BeginAudioTransition(Beatmap beatmap, bool continuePlaying) { if (continuePlaying) { if (audioThread != null && audioThreadLoadingMap == BeatmapManager.Current && audioState != FadeStates.Idle) { return; } AudioEngine.LoadAudioForPreview(BeatmapManager.Current, continuePlaying, true); } else { audioState = FadeStates.FadeOut; //if (audioThread != null) // audioThread.Abort(); //audioThreadLoadingMap = beatmap; //audioThread = GameBase.RunBackgroundThread(delegate //{ // try // { // while (AudioEngine.volumeMusicFade > 10) // { // audioState = FadeStates.FadeOut; // Thread.Sleep(10); // } // audioState = FadeStates.Idle; // AudioEngine.LoadAudioForPreview(BeatmapManager.Current, continuePlaying, true); // } // catch (Exception) { // NotificationManager.ShowMessage("Error loading audio for this beatmap..."); // audioError = true; // } // audioThread = null; //}); } }
/// <summary> /// Handles the FadeIn/FadeOut states. /// </summary> private void FadeValue(float elaspedTime) { _FadeTimer += elaspedTime; float musicVolume = MathHelper.Clamp(_FadeTimer / _FadeDuration, 0f, 1f); switch (_FadeState) { case FadeStates.FadeIn: SetVariable(MUSIC_VOLUME_VARIABLE, musicVolume); if (_FadeTimer >= _FadeDuration) { _FadeState = FadeStates.None; } break; case FadeStates.FadeOutPause: SetVariable(MUSIC_VOLUME_VARIABLE, 1f - musicVolume); if (_FadeTimer >= _FadeDuration) { _FadeState = FadeStates.None; Cue.Pause(); _IsPausing = false; } break; case FadeStates.FadeOutStop: SetVariable(MUSIC_VOLUME_VARIABLE, 1f - musicVolume); if (_FadeTimer >= _FadeDuration) { Cue.Stop(AudioStopOptions.AsAuthored); _FadeState = FadeStates.None; _IsStopped = true; } break; default: break; } }
public void UpdateFade() { if (currentFadeState == FadeStates.FadeOut) { fFadeAlpha += 0.025f; if (fFadeAlpha >= 1) { currentFadeState = FadeStates.FadeIn; CLoadingScreen.Instance.UnloadLevelData(); CLoadingScreen.Instance.PrepareLevelData(sNextLevel); CLoadingScreen.Instance.Load(); } } else if (currentFadeState == FadeStates.FadeIn) { if (fFadeAlpha > 0) { fFadeAlpha -= 0.025f; } } }
//-------------------------------------------------------------- // *** FADE *** public void StartFade(FadeStates state, Color colour, float rate) { // Set fade colour _Image.color = colour; // Set fading rate _FadeRate = rate; // Begin fade _FadeState = state; switch (state) { case FadeStates.idle: { break; } case FadeStates.fadeIn: { _UIPanel.SetActive(true); _Fading = true; _Image.color = new Color(_Image.color.r, _Image.color.g, _Image.color.b, 0f); break; } case FadeStates.fadeOut: { _UIPanel.SetActive(true); _Fading = true; _Image.color = new Color(_Image.color.r, _Image.color.g, _Image.color.b, 1f); break; } default: { break; } } }
/// <summary> /// Pauses the cue with fade out effect. /// </summary> public void Pause() { _IsPausing = true; _FadeTimer = 0f; _FadeState = FadeStates.FadeOutPause; }
/// <summary> /// Stops the cue with a fade out and stop effect. /// </summary> public void Stop() { _FadeTimer = 0f; _FadeState = FadeStates.FadeOutStop; }
/// <summary> /// Handles the FadeIn/FadeOut states. /// </summary> private void FadeValue(float elaspedTime) { _FadeTimer += elaspedTime; float musicVolume = MathHelper.Clamp(_FadeTimer / _FadeDuration, 0f, 1f); switch (_FadeState) { case FadeStates.FadeIn: SetVariable(MUSIC_VOLUME_VARIABLE, musicVolume); if (_FadeTimer >= _FadeDuration) _FadeState = FadeStates.None; break; case FadeStates.FadeOutPause: SetVariable(MUSIC_VOLUME_VARIABLE, 1f - musicVolume); if (_FadeTimer >= _FadeDuration) { _FadeState = FadeStates.None; Cue.Pause(); _IsPausing = false; } break; case FadeStates.FadeOutStop: SetVariable(MUSIC_VOLUME_VARIABLE, 1f - musicVolume); if (_FadeTimer >= _FadeDuration) { Cue.Stop(AudioStopOptions.AsAuthored); _FadeState = FadeStates.None; _IsStopped = true; } break; default: break; } }
/// <summary> /// Starts the player playing the specified file. /// </summary> /// <param name="TheSong">The filename of the song to play.</param> /// <param name="Fade">Whether to fade or not.</param> /// <returns>Returns true if player starts playing</returns> public bool Play(string TheSong, bool Fade) { try { if (PlayerState != PlayerStates.Paused) { if (PlayingPlayer == Players.NULL) { if (!InCrossfade && !InFade) { if (Fade) { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; FadeState = FadeStates.In; StartFade(); } else { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; Player1.volume = Volume; Player1.play(); PlayerState = PlayerStates.Playing; return(true); } } } else if (Crossfade) { if (!InCrossfade && !InFade) { if (PlayingPlayer == Players.Player1) { Player2Song = TheSong; StoppingPlayer = Players.Player1; StartCrossfade(); return(true); } else if (PlayingPlayer == Players.Player2) { Player1Song = TheSong; StoppingPlayer = Players.Player2; StartCrossfade(); return(true); } else { if (Fade) { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; FadeState = FadeStates.In; StartFade(); } else { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; Player1.volume = Volume; Player1.play(); PlayerState = PlayerStates.Playing; return(true); } } } } else if (!InFade) { if (Fade) { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; FadeState = FadeStates.In; StartFade(); } else { PlayingPlayer = Players.Player1; Player1Song = TheSong; Player1.URL = TheSong; Player1.volume = Volume; Player1.play(); PlayerState = PlayerStates.Playing; return(true); } } } else if (PlayerState == PlayerStates.Paused) { Resume(Fade); } } catch (Exception ex) { OnError.Invoke(new ErrorEventArgs("Play : " + ex.Message)); } return(false); }
public void SetBarVal(float newVal) { if (isAnimating) StopAllCoroutines(); state = FadeStates.Bars; animationVal = Mathf.Clamp01(newVal); }
public void CloseCircle(float durationSeconds, Vector2 viewportPos, AnimationCurve curveToUse = null) { if (isAnimating) StopAllCoroutines(); state = FadeStates.Circle; positionX = viewportPos.x; positionY = viewportPos.y; AnimationCurve curCurve = (curveToUse != null) ? curveToUse : defaultCircleCloseCurve; StartCoroutine(AnimationRoutine(durationSeconds, curCurve)); }
/// <summary> /// Stops the cue with a fade out and stop effect. /// </summary> public void Stop() { _FadeTimer = 0f; _FadeState = FadeStates.FadeOutStop; }
/// <summary> /// Pauses the cue with fade out effect. /// </summary> public void Pause() { _IsPausing = true; _FadeTimer = 0f; _FadeState = FadeStates.FadeOutPause; }
/// <summary> /// This is called when the page should be updated. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public virtual void Update(GameTime gameTime) { if (FadeState == FadeStates.Wait) { fadeStep++; if (fadeStep > fadeLength) { layer.CurrentPage = page; Goto(); fadeStep = 0; FadeState = FadeStates.FadeIn; } } else if (FadeState == FadeStates.FadeIn) { fadeStep++; if (fadeStep > fadeLength) { fadeStep = 0; FadeState = FadeStates.Visible; } } else if (FadeState == FadeStates.FadeOut) { fadeStep++; if (fadeStep > fadeLength) { fadeStep = 0; Leave(); FadeState = FadeStates.None; } } }
/// <summary> /// Plays the cue with a fade in effect. If it is pause, it will resume the cue. /// </summary> public void Play() { _FadeTimer = 0f; _FadeState = FadeStates.FadeIn; if (IsPaused) Cue.Resume(); else Cue.Play(); }