private void Update() { // show fadeout when game is running or has ended if (MainBase.Instance.state == GameState.Running || MainBase.Instance.state == GameState.Ended) { if (_fadeInTimer != null) { _fadeInTimer.Update(); ApplyFadeIn(); if (_fadeInTimer.hasEnded) { SetMaterialColor(Color.white); _fadeInTimer = null; } } else if (_fadeOutTimer != null) { _fadeOutTimer.Update(); ApplyFadeOut(); if (_fadeOutTimer.hasEnded) { SetMaterialColor(Color.white.WithAlpha(0)); _fadeOutTimer = null; } } } }
// ================================================================================ // unity methods // -------------------------------------------------------------------------------- public void Awake() { _timer = new FadingTimer(0.4f, displayDuration, 0.4f); _timer.Stop(); if (_text == null || _text.Length == 0) { _text = GetComponentsInChildren<Text>(); } if (_text == null || _text.Length == 0) { // the MessengerText Object will be inside the MainCanvas var messengerObject = GameObject.Find("MessengerText") as GameObject; if (messengerObject != null) _text = messengerObject.GetComponentsInChildren<Text>(); } if (_text != null) { for (int i = 0; i < _text.Length; i++) { _text[i].enabled = false; } } }
public void FadeOut() { if (_fadeOutTimer == null) { _fadeOutTimer = new FadingTimer(0, Actor.TIME_UNTIL_DESTRUCTION, 2.0f); } }
// ================================================================================ // unity methods // -------------------------------------------------------------------------------- public void Awake() { _timer = new FadingTimer(0.4f, displayDuration, 0.4f); _timer.Stop(); if (_text == null || _text.Length == 0) { _text = GetComponentsInChildren <Text>(); } if (_text == null || _text.Length == 0) { // the MessengerText Object will be inside the MainCanvas var messengerObject = GameObject.Find("MessengerText") as GameObject; if (messengerObject != null) { _text = messengerObject.GetComponentsInChildren <Text>(); } } if (_text != null) { for (int i = 0; i < _text.Length; i++) { _text[i].enabled = false; } } }
public void FadeIn(float time = 1f) { ClearFading(); SetMaterialColor(Color.white.WithAlpha(0)); _fadeInTimer = new FadingTimer(time, time); ApplyFadeIn(); }
public void FadeOutAfterDeath() { if (_fadeOutTimer == null) { ClearFading(); _fadeOutTimer = new FadingTimer(0, Actor2D.TIME_UNTIL_DESTRUCTION, 2.0f); } }
public void Reset() { if (_isInitialized) { if (_animator != null) { SetAnimation(AvatarAnimation.idle); } _currentAnimation = AvatarAnimation.idle; _fadeOutTimer = null; SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 1.0f)); } }
void Update() { // TODO: had to comment this because of main character having no walk animation when steered by Sequence //if (_animator != null) //{ // if (BaseGameController.Instance.state == GameState.Running) // { // _animator.speed = 1.0f; // } // else // { // _animator.speed = 0f; // } //} // show fadeout when game is running or has ended if (BaseGameController.Instance.state == GameState.Running || BaseGameController.Instance.state == GameState.Ended) { if (_fadeInTimer != null) { _fadeInTimer.Update(); ApplyFadeIn(); if (_fadeInTimer.hasEnded) { SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 1f)); _fadeInTimer = null; } } else if (_fadeOutTimer != null) { _fadeOutTimer.Update(); ApplyFadeOut(); if (_fadeOutTimer.hasEnded) { SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 0f)); _fadeOutTimer = null; } } } }
void Update() { if (_animator != null) { if (BaseGameController.Instance.state == GameState.Running) { _animator.speed = 1.0f; } else { _animator.speed = 0f; } } // show fadeout when game is running or has ended if (BaseGameController.Instance.state == GameState.Running || BaseGameController.Instance.state == GameState.Ended) { if (_fadeInTimer != null) { _fadeInTimer.Update(); ApplyFadeIn(); if (_fadeInTimer.hasEnded) { SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 1f)); _fadeInTimer = null; } } else if (_fadeOutTimer != null) { _fadeOutTimer.Update(); ApplyFadeOut(); if (_fadeOutTimer.hasEnded) { SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 0f)); } } } }
public void FadeOut(float time = 1f) { ClearFading(); _fadeOutTimer = new FadingTimer(0, time, time); ApplyFadeOut(); }
public void FadeOutFast(float time) { _fadeOutTimer = new FadingTimer(0f, time, time); }
public void FadeIn() { SetMaterialColor(new Color(1.0f, 1.0f, 1.0f, 0f)); _fadeInTimer = new FadingTimer(1f, 1f); }
public void Reset() { if (_isInitialized) { if (_animator != null) SetAnimation(AvatarAnimation.idle); _currentAnimation = AvatarAnimation.idle; _fadeOutTimer = null; SetMaterialColor(Color.white); } }
// ================================================================================ // private methods // -------------------------------------------------------------------------------- private void ClearFading() { _fadeInTimer = null; _fadeOutTimer = null; }
void StartNewTimer() { _timer = new FadingTimer(intervalMin * 0.2f, Random.Range(intervalMin, intervalMax), intervalMin * 0.2f); }