Exemplo n.º 1
0
        protected virtual void AutoUpdate()
        {
            if (!AutoUpdating)
            {
                return;
            }

            _newPercent          = MathsHelper.Remap(BarProgress, 0f, 1f, startValue, endValue);
            _targetFill          = _newPercent;
            _lastUpdateTimestamp = (TimeScale == TimeScales.Time) ? Time.time : Time.unscaledTime;
        }
Exemplo n.º 2
0
 // Updates the bar's values
 public virtual void UpdateBar(float currentValue, float minValue, float maxValue)
 {
     _newPercent = MathsHelper.Remap(currentValue, minValue, maxValue, startValue, endValue);
     if ((_newPercent != BarProgress) && !Bumping)
     {
         Bump();
     }
     BarProgress          = _newPercent;
     _targetFill          = _newPercent;
     _lastUpdateTimestamp = (TimeScale == TimeScales.Time) ? Time.time : Time.unscaledTime;
     _lastPercent         = _newPercent;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Call this method to update the fill amount based on a currentValue between minValue and maxValue
 /// </summary>
 /// <param name="currentValue">Current value.</param>
 /// <param name="minValue">Minimum value.</param>
 /// <param name="maxValue">Max value.</param>
 public virtual void UpdateBar(float currentValue, float minValue, float maxValue)
 {
     _newPercent = MathsHelper.Remap(currentValue, minValue, maxValue, StartValue, EndValue);
     if (_radialImage == null)
     {
         return;
     }
     _radialImage.fillAmount = _newPercent;
     if (_radialImage.fillAmount > 1 - Tolerance)
     {
         _radialImage.fillAmount = 1;
     }
     if (_radialImage.fillAmount < Tolerance)
     {
         _radialImage.fillAmount = 0;
     }
 }
Exemplo n.º 4
0
        // Core methods ---------------------------------------------------------------------------------------------------------------

        // Moves a value between a startValue and an endValue based on a currentTime, along the specified tween curve
        public static float TweenConstructor(float currentTime, float initialTime, float endTime, float startValue, float endValue, TweenCurve curve)
        {
            currentTime = MathsHelper.Remap(currentTime, initialTime, endTime, 0f, 1f);
            switch (curve)
            {
            case TweenCurve.LinearTween: currentTime = TweenDefinitions.Linear_Tween(currentTime); break;

            case TweenCurve.AntiLinearTween: currentTime = TweenDefinitions.LinearAnti_Tween(currentTime); break;

            case TweenCurve.EaseInQuadratic: currentTime = TweenDefinitions.EaseIn_Quadratic(currentTime); break;

            case TweenCurve.EaseOutQuadratic: currentTime = TweenDefinitions.EaseOut_Quadratic(currentTime); break;

            case TweenCurve.EaseInOutQuadratic: currentTime = TweenDefinitions.EaseInOut_Quadratic(currentTime); break;

            case TweenCurve.EaseInCubic: currentTime = TweenDefinitions.EaseIn_Cubic(currentTime); break;

            case TweenCurve.EaseOutCubic: currentTime = TweenDefinitions.EaseOut_Cubic(currentTime); break;

            case TweenCurve.EaseInOutCubic: currentTime = TweenDefinitions.EaseInOut_Cubic(currentTime); break;

            case TweenCurve.EaseInQuartic: currentTime = TweenDefinitions.EaseIn_Quartic(currentTime); break;

            case TweenCurve.EaseOutQuartic: currentTime = TweenDefinitions.EaseOut_Quartic(currentTime); break;

            case TweenCurve.EaseInOutQuartic: currentTime = TweenDefinitions.EaseInOut_Quartic(currentTime); break;

            case TweenCurve.EaseInQuintic: currentTime = TweenDefinitions.EaseIn_Quintic(currentTime); break;

            case TweenCurve.EaseOutQuintic: currentTime = TweenDefinitions.EaseOut_Quintic(currentTime); break;

            case TweenCurve.EaseInOutQuintic: currentTime = TweenDefinitions.EaseInOut_Quintic(currentTime); break;

            case TweenCurve.EaseInSinusoidal: currentTime = TweenDefinitions.EaseIn_Sinusoidal(currentTime); break;

            case TweenCurve.EaseOutSinusoidal: currentTime = TweenDefinitions.EaseOut_Sinusoidal(currentTime); break;

            case TweenCurve.EaseInOutSinusoidal: currentTime = TweenDefinitions.EaseInOut_Sinusoidal(currentTime); break;

            case TweenCurve.EaseInBounce: currentTime = TweenDefinitions.EaseIn_Bounce(currentTime); break;

            case TweenCurve.EaseOutBounce: currentTime = TweenDefinitions.EaseOut_Bounce(currentTime); break;

            case TweenCurve.EaseInOutBounce: currentTime = TweenDefinitions.EaseInOut_Bounce(currentTime); break;

            case TweenCurve.EaseInOverhead: currentTime = TweenDefinitions.EaseIn_Overhead(currentTime); break;

            case TweenCurve.EaseOutOverhead: currentTime = TweenDefinitions.EaseOut_Overhead(currentTime); break;

            case TweenCurve.EaseInOutOverhead: currentTime = TweenDefinitions.EaseInOut_Overhead(currentTime); break;

            case TweenCurve.EaseInExponential: currentTime = TweenDefinitions.EaseIn_Exponential(currentTime); break;

            case TweenCurve.EaseOutExponential: currentTime = TweenDefinitions.EaseOut_Exponential(currentTime); break;

            case TweenCurve.EaseInOutExponential: currentTime = TweenDefinitions.EaseInOut_Exponential(currentTime); break;

            case TweenCurve.EaseInElastic: currentTime = TweenDefinitions.EaseIn_Elastic(currentTime); break;

            case TweenCurve.EaseOutElastic: currentTime = TweenDefinitions.EaseOut_Elastic(currentTime); break;

            case TweenCurve.EaseInOutElastic: currentTime = TweenDefinitions.EaseInOut_Elastic(currentTime); break;

            case TweenCurve.EaseInCircular: currentTime = TweenDefinitions.EaseIn_Circular(currentTime); break;

            case TweenCurve.EaseOutCircular: currentTime = TweenDefinitions.EaseOut_Circular(currentTime); break;

            case TweenCurve.EaseInOutCircular: currentTime = TweenDefinitions.EaseInOut_Circular(currentTime); break;
            }
            return(startValue + currentTime * (endValue - startValue));
        }
Exemplo n.º 5
0
        // Animation curve methods --------------------------------------------------------------------------------------------------------------

        public static float TweenConstructor(float currentTime, float initialTime, float endTime, float startValue, float endValue, AnimationCurve curve)
        {
            currentTime = MathsHelper.Remap(currentTime, initialTime, endTime, 0f, 1f);
            currentTime = curve.Evaluate(currentTime);
            return(startValue + currentTime * (endValue - startValue));
        }
Exemplo n.º 6
0
        // Updates the front bar's scale
        protected virtual void UpdateFrontBar()
        {
            float currentDeltaTime = (TimeScale == TimeScales.Time) ? Time.deltaTime : Time.unscaledTime;

            if (ForegroundBar != null)
            {
                switch (FillMode)
                {
                case FillModes.LocalScale:
                    _targetLocalScale = Vector3.one;
                    switch (barDirection)
                    {
                    case BarDirections.LeftToRight:
                        _targetLocalScale.x = _targetFill;
                        break;

                    case BarDirections.RightToLeft:
                        _targetLocalScale.x = 1f - _targetFill;
                        break;

                    case BarDirections.DownToUp:
                        _targetLocalScale.y = _targetFill;
                        break;

                    case BarDirections.UpToDown:
                        _targetLocalScale.y = 1f - _targetFill;
                        break;
                    }

                    if (LerpForegroundBar)
                    {
                        _newScale = Vector3.Lerp(ForegroundBar.localScale, _targetLocalScale, currentDeltaTime * LerpForegroundBarSpeed);
                    }
                    else
                    {
                        _newScale = _targetLocalScale;
                    }

                    ForegroundBar.localScale = _newScale;
                    break;

                case FillModes.Width:
                    if (_foregroundImage == null)
                    {
                        return;
                    }
                    float newSizeX = MathsHelper.Remap(_targetFill, 0f, 1f, 0, _initialFrontBarSize.x);
                    newSizeX = Mathf.Lerp(_foregroundImage.rectTransform.sizeDelta.x, newSizeX, currentDeltaTime * LerpForegroundBarSpeed);
                    _foregroundImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, newSizeX);
                    break;

                case FillModes.Height:
                    if (_foregroundImage == null)
                    {
                        return;
                    }
                    float newSizeY = MathsHelper.Remap(_targetFill, 0f, 1f, 0, _initialFrontBarSize.y);
                    newSizeY = Mathf.Lerp(_foregroundImage.rectTransform.sizeDelta.x, newSizeY, currentDeltaTime * LerpForegroundBarSpeed);
                    _foregroundImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, newSizeY);
                    break;

                case FillModes.FillAmount:
                    if (_foregroundImage == null)
                    {
                        return;
                    }
                    if (LerpForegroundBar)
                    {
                        _foregroundImage.fillAmount = Mathf.Lerp(_foregroundImage.fillAmount, _targetFill, currentDeltaTime * LerpForegroundBarSpeed);
                    }
                    else
                    {
                        _foregroundImage.fillAmount = _targetFill;
                    }
                    break;
                }
            }
        }