Exemplo n.º 1
0
    public void update(bool callCallBack = true)
    {
        if (_Animating)
        {
            if (_TimeElapsed < _Duration)
            {
                if (_Easing != null)
                {
                    _Progression.x = _Easing.Invoke(_TimeElapsed, _From.x, (_To.x - _From.x), _Duration);
                    _Progression.y = _Easing.Invoke(_TimeElapsed, _From.y, (_To.y - _From.y), _Duration);
                    _Progression.z = _Easing.Invoke(_TimeElapsed, _From.z, (_To.z - _From.z), _Duration);

                    _ProgressPct = _TimeElapsed / _Duration;

                    _TimeElapsed += Time.deltaTime;
                }
            }
            else
            {
                _Progression = _To;

                _Animating   = false;
                _TimeElapsed = 0f;
                _ProgressPct = 1f;

                if (callCallBack && _Callback != null)
                {
                    _Callback.Invoke();
                }
            }
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Update alpha channel.
        /// </summary>
        private void UpdateAlpha()
        {
            if (mIgnoreA)
            {
                mEasingA = false;
            }

            if (!mEasingA)
            {
                return;
            }

            if (mTimeElapsed.w < mRealDurationAlpha)
            {
                this.mProgressionColor.a = mEasingAlpha.Invoke(
                    mTimeElapsed.w,
                    mFromColor.a,
                    (mTargetColor.a - mFromColor.a),
                    mRealDurationAlpha);

                this.mProgressPctColor.a = mTimeElapsed.w / mRealDurationAlpha;

                this.mTimeElapsed.w += Time.deltaTime;
            }
            else
            {
                this.mProgressionColor.a = this.mTargetColor.a;

                this.mEasingA            = false;
                this.mTimeElapsed.w      = 0.0f;
                this.mProgressPctColor.a = 1.0f;

                CheckDoneEasing();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update blue channel.
        /// </summary>
        private void UpdateBlue()
        {
            if (mIgnoreB)
            {
                mEasingB = false;
            }

            if (!mEasingB)
            {
                return;
            }

            if (mTimeElapsed.z < mRealDurationBlue)
            {
                this.mProgressionColor.b = mEasingBlue.Invoke(
                    mTimeElapsed.z,
                    mFromColor.b,
                    (mTargetColor.b - mFromColor.b),
                    mRealDurationBlue);

                this.mProgressPctColor.b = mTimeElapsed.z / mRealDurationBlue;

                this.mTimeElapsed.z += Time.deltaTime;
            }
            else
            {
                this.mProgressionColor.b = this.mTargetColor.b;

                this.mEasingB            = false;
                this.mTimeElapsed.z      = 0.0f;
                this.mProgressPctColor.b = 1.0f;

                CheckDoneEasing();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update green channel.
        /// </summary>
        private void UpdateGreen()
        {
            if (mIgnoreG)
            {
                mEasingG = false;
            }

            if (!mEasingG)
            {
                return;
            }

            if (mTimeElapsed.y < mRealDurationGreen)
            {
                this.mProgressionColor.g = mEasingGreen.Invoke(
                    mTimeElapsed.y,
                    mFromColor.g,
                    (mTargetColor.g - mFromColor.g),
                    mRealDurationGreen);

                this.mProgressPctColor.g = mTimeElapsed.y / mRealDurationGreen;

                this.mTimeElapsed.y += Time.deltaTime;
            }
            else
            {
                this.mProgressionColor.g = this.mTargetColor.g;

                this.mEasingG            = false;
                this.mTimeElapsed.y      = 0.0f;
                this.mProgressPctColor.g = 1.0f;

                CheckDoneEasing();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Update red channel.
        /// </summary>
        private void UpdateRed()
        {
            if (mIgnoreR)
            {
                mEasingR = false;
            }

            if (!mEasingR)
            {
                return;
            }

            if (mTimeElapsed.x < mRealDurationRed)
            {
                this.mProgressionColor.r = mEasingRed.Invoke(
                    mTimeElapsed.x,
                    mFromColor.r,
                    (mTargetColor.r - mFromColor.r),
                    mRealDurationRed);

                this.mProgressPctColor.r = mTimeElapsed.x / mRealDurationRed;

                this.mTimeElapsed.x += Time.deltaTime;
            }
            else
            {
                this.mProgressionColor.r = this.mTargetColor.r;

                this.mEasingR            = false;
                this.mTimeElapsed.x      = 0.0f;
                this.mProgressPctColor.r = 1.0f;

                CheckDoneEasing();
            }
        }
Exemplo n.º 6
0
        public void update(bool callCallBack = true)
        {
            if (!_Animating)
            {
                return;
            }

            if (_TimeElapsed < _Duration)
            {
                if (_Easing == null)
                {
                    return;
                }

                _Progression = _Easing.Invoke(_TimeElapsed, _From, (_To - _From), _Duration);

                _ProgressPct = _TimeElapsed / _Duration;

                _TimeElapsed += Time.deltaTime;
            }
            else
            {
                _Progression = _To;

                _Animating   = false;
                _TimeElapsed = 0.0f;
                _ProgressPct = 1.0f;

                if (callCallBack && _Callback != null)
                {
                    _Callback.Invoke();
                }
            }
        }
Exemplo n.º 7
0
        public void updateZ(bool callCallBack = true)
        {
            if (!_AnimatingZ)
            {
                return;
            }

            if (_TimeElapsed.z < _Duration.z)
            {
                if (_EasingZ != null)
                {
                    _Progression.z = _EasingZ.Invoke(_TimeElapsed.z, _From.z, (_To.z - _From.z), _Duration.z);

                    _ProgressPct.z = _TimeElapsed.z / _Duration.z;

                    _TimeElapsed.z += Time.deltaTime;
                }
            }
            else
            {
                _Progression.z = _To.z;

                _AnimatingZ    = false;
                _TimeElapsed.z = 0f;
                _ProgressPct.z = 1f;

                CheckUpdate();
            }
        }
Exemplo n.º 8
0
        public void updateY(bool callCallBack = true)
        {
            if (!_AnimatingY)
            {
                return;
            }

            if (_TimeElapsed.y < _Duration.y)
            {
                if (_EasingY != null)
                {
                    _Progression.y = _EasingY.Invoke(_TimeElapsed.y, _From.y, (_To.y - _From.y), _Duration.y);

                    _ProgressPct.y = _TimeElapsed.y / _Duration.y;

                    _TimeElapsed.y += Time.deltaTime;
                }
            }
            else
            {
                _Progression.y = _To.y;

                _AnimatingY    = false;
                _TimeElapsed.y = 0f;
                _ProgressPct.y = 1f;

                CheckUpdate();
            }
        }
Exemplo n.º 9
0
        public void updateX(bool callCallBack = true)
        {
            if (!_AnimatingX)
            {
                return;
            }

            if (_TimeElapsed.x < _Duration.x)
            {
                if (_EasingX != null)
                {
                    _Progression.x = _EasingX.Invoke(_TimeElapsed.x, _From.x, (_To.x - _From.x), _Duration.x);

                    _ProgressPct.x = _TimeElapsed.x / _Duration.x;

                    _TimeElapsed.x += Time.deltaTime;
                }
            }
            else
            {
                _Progression.x = _To.x;

                _AnimatingX    = false;
                _TimeElapsed.x = 0f;
                _ProgressPct.x = 1f;

                CheckUpdate();
            }
        }
Exemplo n.º 10
0
        private void UpdateValue()
        {
            if (!mAnimating)
            {
                return;
            }

            if (!CheckValid())
            {
                mAnimating = false;
                return;
            }

            if (mTimeElapsed < mRealDuration)
            {
                this.mProgression = mEasingFunc.Invoke(
                    mTimeElapsed,
                    mStartingValue,
                    (mTargetValue - mStartingValue),
                    mRealDuration);

                this.mProgressPct = mTimeElapsed / mRealDuration;

                this.set_float.Invoke(this.mProgression);

                this.mTimeElapsed += Time.deltaTime;
            }
            else
            {
                this.mProgression = this.mTargetValue;
                this.set_float.Invoke(this.mProgression);

                this.mAnimating   = false;
                this.mTimeElapsed = 0.0f;
                this.mProgressPct = 1.0f;

                DoDoneEasing();
            }
        }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        float myDelta = timer / duration;

        // Check for end
        if (timer > duration)
        {
            myDelta = 1f;
        }

        Vector3 tweenedVector = TweenVector(StartVector, EndVector, myDelta);

        tweenDelegate.Invoke(tweenedVector);

        if (timer > duration)
        {
            // End the tweening by disenabling the script
            enabled = false;

            EndEvent.Invoke();
        }
    }