private void CheckStat(BaseStat stat) { if (_statText != null) { _statText.text = stat.ToString(); } if (_actor.Entity.Tags.Contain(EntityTags.IsDead)) { _statTween.Restart(_statSlider.value, 0, 0.35f); return; } if (_statTween.Active) { return; } if (_statTween.Length <= 0) { _statSlider.value = _actor.GetVital(_targetStat).CurrentPercent; return; } var percent = _actor.GetVital(_targetStat).CurrentPercent; var statDifference = Mathf.Abs(_statSlider.value - percent); if (statDifference > 0.05f) { _statTween.Restart (_statSlider.value, percent, Mathf.Lerp(0.35f, _maxTweenLength, statDifference)); } }
private IEnumerator Despawn(float length) { _hideTween.Restart(_group.alpha, 0, length); while (_hideTween.Active) { _group.alpha = _hideTween.Get(); yield return(null); } ItemPool.Despawn(gameObject); }
private IEnumerator TransitionRenderTexture(float totalTime, float extraPause) { yield return(extraPause); _normalFade.Restart(0, 1, totalTime); while (_normalFade.Active) { _rtMaterial.SetFloat("_Cutoff", _normalFade.Get()); yield return(null); } _image.enabled = false; _canvasGroup.alpha = 0; }
private IEnumerator DamageTween() { _animatingColor = true; var modelComponent = this.GetEntity().Get <ModelComponent>(); var blocks = modelComponent.GetMatBlocks; if (blocks == null) { yield break; } var renderers = modelComponent.GetRenderers; if (renderers == null) { yield break; } Color[] colors = new Color[blocks.Length]; Color[] emissive = new Color[blocks.Length]; for (int i = 0; i < blocks.Length; i++) { colors[i] = renderers[i].sharedMaterial.GetColor(_shaderColor); emissive[i] = renderers[i].sharedMaterial.GetColor(_shaderEmissive); blocks[i].SetColor(_shaderColor, Color.red); blocks[i].SetColor(_shaderEmissive, Color.red); } modelComponent.ApplyMaterialBlocks(blocks); _scaleDmgTween.Restart(1, _dmgMaxScale); var scale = _spriteRender.transform.localScale; while (_scaleDmgTween.Active) { _spriteRender.transform.localScale = new Vector3(scale.x * _scaleDmgTween.Get(), scale.y, scale.z); yield return(null); } _scaleDmgTween.Restart(_dmgMaxScale, 1); while (_scaleDmgTween.Active) { _spriteRender.transform.localScale = new Vector3(scale.x * _scaleDmgTween.Get(), scale.y, scale.z); for (int i = 0; i < blocks.Length; i++) { blocks[i].SetColor(_shaderColor, Color.Lerp(Color.red, colors[i], _scaleDmgTween.Get())); blocks[i].SetColor(_shaderEmissive, Color.Lerp(Color.red, emissive[i], _scaleDmgTween.Get())); } modelComponent.ApplyMaterialBlocks(blocks); yield return(null); } _animatingColor = false; }
public IEnumerator OpenRadial(Vector2 startPosition, MenuActionLayer menuAction) { if (_state != State.Disabled) { StartCloseRadial(); while (_state != State.Disabled) { yield return(null); } } _currentLayer = menuAction; PanelTransform.position = startPosition; var point = PanelTransform.anchoredPosition; point.x = Mathf.Clamp(point.x, -_positionLimit.x, _positionLimit.x); point.y = Mathf.Clamp(point.y, -_positionLimit.y, _positionLimit.y); PanelTransform.anchoredPosition = point; if (GameOptions.PauseForInput) { Game.Pause("Radial"); } Game.CursorUnlock("Radial"); _clickTimer.StartTimer(); _state = State.Opening; DetermineTargetAngle(_currentControl); _currentLayer.Init(this, _cursorTargetAngle); _fadeIn.Restart(0, 1); _canvasGroup.SetActive(true); }
private void CheckSliders(CharacterNode unit) { _state = State.Waiting; if (!_healthTween.Active) { var healthPercent = unit.GetVital(_targetVital).CurrentPercent; var statDifference = Math.Abs(_healthSlider.value - healthPercent); if (statDifference > 0.01f) { _healthTween.Restart (_healthSlider.value, healthPercent, Mathf.Lerp(0.15f, _maxTweenLength, statDifference)); } } else { _state = State.Active; _healthSlider.value = _healthTween.Get(); } //if (!_shieldTween.Active) { // //var shieldPercent = unit.VitalStats[Vitals.Shield].CurrentPercent; // var statDifference = Math.Abs(_shieldSlider.value - shieldPercent); // if ( statDifference > 0.01f) { // _shieldTween.Restart // (_shieldSlider.value, shieldPercent, Mathf.Lerp(0.15f, _maxTweenLength, statDifference)); // } //} //else { // _shieldSlider.value = _shieldTween.Get(); // _state = State.Active; //} }
public override void StartTween() { _index++; if (_index >= _targets.Length) { _index = 0; } _tweener.Restart(_canvasGroup.alpha, _targets[_index], _durations[_index], _easing[_index], UnScaled); }
private IEnumerator FadeIn() { _revealTween.Restart(0, 1); while (_revealTween.Active) { _group.alpha = _revealTween.Get(); yield return(null); } }
public IEnumerator CloseRadial() { _state = State.Closing; _fadeOut.Restart(1, 0); if (_currentLayer != null) { _currentLayer.StartClose(); } while (true) { if (_fadeOut.Active) { _canvasGroup.alpha = _fadeOut.Get(); } if (_currentLayer != null) { if (_currentLayer.TransitionComplete() && !_fadeOut.Active) { break; } } else { if (!_fadeOut.Active) { break; } } yield return(null); } if (_currentLayer != null) { _currentLayer.Pool(); _currentLayer = null; } for (int i = 0; i < _previousLayers.Count; i++) { _previousLayers[i].Pool(); } _previousLayers.Clear(); _canvasGroup.SetActive(false); if (GameOptions.PauseForInput) { Game.RemovePause("Radial"); } Game.RemoveCursorUnlock("Radial"); _state = State.Disabled; }
protected void ProcessSetStatus(bool status) { _lastStatusScene = false; if (_fadeTween == null) { _fadeTween = new TweenFloat(0, 1, _transitionLength, EasingTypes.SinusoidalInOut, true); _fadeTween.Init(); } _canvasgroup.interactable = status; _canvasgroup.blocksRaycasts = status; _fadeTween.Restart(_canvasgroup.alpha, status ? 1 : 0); _fadeTween.Play((f => _canvasgroup.alpha = f), null); Status = status; OnStatusChanged(status); }
public IEnumerator SetTargetText(string text, float duration, Vector3 end, Color color) { _text.text = text; _text.color = _defaultColor; _moveTween.Restart(transform.position, end, duration); _colorTween.Restart(0, 1, duration); while (_moveTween.Active) { _text.color = Color.Lerp(_defaultColor, _endColor, _colorTween.Get()); transform.position = _moveTween.Get(); transform.LookAt(transform.position + Player.Cam.transform.rotation * Vector3.forward, Player.Cam.transform.rotation * Vector3.up); //_text.fontSize = Vector3.Distance(transform.position, Player.Cam.transform.position) * 0.35f; yield return(null); } ItemPool.Despawn(gameObject); }
private IEnumerator PainAnimation() { _image.color = _painColor; _image.material = null; _image.texture = null; _image.enabled = true; _canvasGroup.alpha = _maxAlpha; yield return(_painHoldTime); _painEnd.Restart(_maxAlpha, 0); while (_painEnd.Active) { _canvasGroup.alpha = _painEnd.Get(); yield return(null); } _image.enabled = false; }
private IEnumerator UpdateBar(CharacterNode unit, float offset) { _healthSlider.value = unit.GetVital(_targetVital).CurrentPercent; //_shieldSlider.value = unit.VitalStats[Vitals.Shield].CurrentPercent; _endTime = TimeManager.Time + _timeOut; _state = State.Waiting; transform.position = unit.Entity.GetPosition(); _canvasGroup.alpha = 1; var v3Offset = new Vector3(0, offset, 0); while (true) { transform.position = unit.Entity.GetPosition() + v3Offset; Player.Cam.FaceCamera(transform, false); if (_state != State.Fading) { CheckSliders(unit); } if (_state == State.Waiting && TimeManager.Time > _endTime) { _fadeTween.Restart(1, 0); _state = State.Fading; } if (_state == State.Fading) { if (_fadeTween.Active) { _canvasGroup.alpha = _fadeTween.Get(); } else { break; } } yield return(null); } _activeBars.Remove(unit); ItemPool.Despawn(gameObject); }