Пример #1
0
 static int SetZero(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.TweenValue obj = (FairyGUI.TweenValue)ToLua.CheckObject <FairyGUI.TweenValue>(L, 1);
         obj.SetZero();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #2
0
        void Update()
        {
            _ended = 0;

            if (_valueSize == 0)             //DelayedCall
            {
                if (_elapsedTime >= _delay + _duration)
                {
                    _ended = 1;
                }

                return;
            }

            if (!_started)
            {
                if (_elapsedTime < _delay)
                {
                    return;
                }

                _started = true;
                CallStartCallback();
                if (_killed)
                {
                    return;
                }
            }

            bool  reversed = false;
            float tt       = _elapsedTime - _delay;

            if (_breakpoint >= 0 && tt >= _breakpoint)
            {
                tt     = _breakpoint;
                _ended = 2;
            }

            if (_repeat != 0)
            {
                int round = Mathf.FloorToInt(tt / _duration);
                tt -= _duration * round;
                if (_yoyo)
                {
                    reversed = round % 2 == 1;
                }

                if (_repeat > 0 && _repeat - round < 0)
                {
                    if (_yoyo)
                    {
                        reversed = _repeat % 2 == 1;
                    }
                    tt     = _duration;
                    _ended = 1;
                }
            }
            else if (tt >= _duration)
            {
                tt     = _duration;
                _ended = 1;
            }

            _normalizedTime = EaseManager.Evaluate(_easeType, reversed ? (_duration - tt) : tt, _duration,
                                                   _easeOvershootOrAmplitude, _easePeriod);

            _value.SetZero();
            _deltaValue.SetZero();

            if (_valueSize == 5)
            {
                double d = _startValue.d + (_endValue.d - _startValue.d) * _normalizedTime;
                if (_snapping)
                {
                    d = Math.Round(d);
                }
                _deltaValue.d = d - _value.d;
                _value.d      = d;
            }
            else if (_valueSize == 6)
            {
                if (_ended == 0)
                {
                    Vector3 r = UnityEngine.Random.insideUnitSphere;
                    r.x = r.x > 0 ? 1 : -1;
                    r.y = r.y > 0 ? 1 : -1;
                    r.z = r.z > 0 ? 1 : -1;
                    r  *= _startValue.w * (1 - _normalizedTime);

                    _deltaValue.vec3 = r;
                    _value.vec3      = _startValue.vec3 + r;
                }
                else
                {
                    _value.vec3 = _startValue.vec3;
                }
            }
            else
            {
                for (int i = 0; i < _valueSize; i++)
                {
                    float n1 = _startValue[i];
                    float n2 = _endValue[i];
                    float f  = n1 + (n2 - n1) * _normalizedTime;
                    if (_snapping)
                    {
                        f = Mathf.Round(f);
                    }
                    _deltaValue[i] = f - _value[i];
                    _value[i]      = f;
                }
            }

            if (_target != null && _propType != TweenPropType.None)
            {
                TweenPropTypeUtils.SetProps(_target, _propType, _value);
            }

            CallUpdateCallback();
        }