Beispiel #1
0
 /// <summary>
 /// Pauses lerp if lerping. Use Resume() to continue
 /// </summary>
 public void Pause()
 {
     if (_lerpState == AutoLerpState.Lerping)
     {
         _lerpState = AutoLerpState.Paused;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Resumes paused lerp.
 /// </summary>
 public void Resume()
 {
     if (_lerpState == AutoLerpState.Paused)
     {
         _lerpState      = AutoLerpState.Lerping;
         _lastUpdateTime = Time.time;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates instance of TimedLerp class
        /// </summary>
        /// <param name="startValue">Start value for lerp</param>
        /// <param name="endValue">End value for lerp</param>
        /// <param name="time">Time in seconds to lerp from startValue to endValue</param>
        public TimedLerp(T startValue, T endValue, float time)
        {
            _startValue = startValue;
            _endValue   = endValue;
            _lerpTime   = time;

            _lerpTimer      = 0f;
            _lerpValue      = startValue;
            _lerpState      = AutoLerpState.Ready;
            _lastUpdateTime = 0f;
        }
Beispiel #4
0
        /// <summary>
        /// Updates internal lerp time and value
        /// </summary>
        /// <returns>Lerped value based on time</returns>
        public T GetValue()
        {
            if (_lerpState != AutoLerpState.Lerping)
            {
                return(_lerpValue);
            }

            UpdateDeltaTime();

            _lerpTimer += _deltaTime;
            if (_lerpTimer >= _lerpTime)
            {
                _lerpState = AutoLerpState.Done;
                _lerpValue = _endValue;
                return(_lerpValue);
            }

            _lerpValue = Lerp();
            return(_lerpValue);
        }
Beispiel #5
0
 /// <summary>
 /// Starts lerping. Resets values to start.
 /// </summary>
 public void Start()
 {
     _lerpTimer = 0f;
     _lerpValue = _startValue;
     _lerpState = AutoLerpState.Lerping;
 }