private static AnimationTimer CreateFadeTimer(FadeStep fadeStep) { var fadeTimer = fadeStep switch { FadeStep.FadeIn => new AnimationTimer(1.75f), FadeStep.Hold => new AnimationTimer(1.75f), FadeStep.FadeOut => new AnimationTimer(0.5f), _ => default,
void Delay(float fDelaTime) { m_delayTime += fDelaTime; if (m_delayTime >= 2.0f) { m_fadeStep = FadeStep.OUT; m_delayTime = 0f; } }
void FadeOut() { m_color -= 0.01f; this.gameObject.GetComponent <Image>().color = new Color(m_color, m_color, m_color, 1); if (m_color <= 0f) { m_fadeStep = FadeStep.DONE; } }
void FadeIn() { m_color += 0.01f; this.gameObject.GetComponent <Image>().color = new Color(m_color, m_color, m_color, 1); if (m_color >= 1f) { m_fadeStep = FadeStep.IDLE; } }
public override void OnActivate() { Debug.WriteLine($"{nameof(SplashScreenPageHandler)} OnActivate"); _currentDisplayImageIndex = 0; _currentFadeStep = FadeStep.FadeIn; _fadeTimer = CreateFadeTimer(_currentFadeStep); for (int i = 0; i < _splashScreenContents.Length; i++) { _splashScreenContents[i].Opacity = 0; } _loadingText.Text = null; }
void FinishFadeStep() { m_curImageIndex++; if (m_images.Length > m_curImageIndex) { this.gameObject.GetComponent <Image>().sprite = m_images[m_curImageIndex]; } m_fadeStep = FadeStep.IN; if (m_images.Length <= m_curImageIndex + 1) { m_finished = true; this.gameObject.GetComponent <Image>().color = new Color(1, 1, 1, 1); } }
public override void Update() { if (IsAnimationFinished) { return; } if (_currentDisplayImageIndex < _splashScreenContents.Length) { float dt = (float)Game.UpdateTime.Elapsed.TotalSeconds; _fadeTimer.Update(dt); var opacity = _currentFadeStep switch { FadeStep.FadeIn => _fadeTimer.CompletionValueInDecimal * _fadeTimer.CompletionValueInDecimal, FadeStep.Hold => 1, FadeStep.FadeOut => (1 - _fadeTimer.CompletionValueInDecimal), _ => 0, }; _splashScreenContents[_currentDisplayImageIndex].Opacity = opacity; if (_fadeTimer.IsComplete) { if (_currentFadeStep < FadeStep.Finished) { _currentFadeStep++; if (_currentFadeStep == FadeStep.Finished) { _currentDisplayImageIndex++; if (_currentDisplayImageIndex >= _splashScreenContents.Length) { _loadingText.Text = "Loading..."; } else { _currentFadeStep = FadeStep.FadeIn; _fadeTimer = CreateFadeTimer(_currentFadeStep); } } else { _fadeTimer = CreateFadeTimer(_currentFadeStep); } } } } }