Пример #1
0
        void Move(Vector2 origin, Vector2 destination, Tween.LoopType loopType = Tween.LoopType.None)
        {
            float distance = Vector3.Distance(origin, destination);
            float time     = distance / speed;

            currentTween = Tween.Position(transform, origin, destination, time, 0.0f, Tween.EaseInOutStrong, loopType);

            direction = (destination - (Vector2)transform.position).normalized;
        }
Пример #2
0
 //----------- Private Methods -----------
 private void Initialize(float duration, float delay, AnimationCurve curve, Action completeCallback, Tween.LoopType loopType, bool destroyWhenDone)
 {
     Reset();
     this.duration         = duration;
     this.delay            = delay;
     this.curve            = curve;
     this.completeCallback = completeCallback;
     this.destroyWhenDone  = destroyWhenDone;
     this.loopType         = loopType;
     if (loopType != Tween.LoopType.None)
     {
         destroyWhenDone = false;
     }
     id = Path.GetRandomFileName().Replace(".", "");
 }
Пример #3
0
        /// <summary>
        /// Sets the essential properties that all tweens need and should be called from their constructor. If targetInstanceID is -1 then this tween won't interrupt tweens of the same type on the same target.
        /// </summary>
        protected void SetEssentials(Tween.TweenType tweenType, int targetInstanceID, float duration, float delay, bool obeyTimeScale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            this.tweenType        = tweenType;
            this.targetInstanceID = targetInstanceID;

            if (delay > 0)
            {
                Status = Tween.TweenStatus.Delayed;
            }

            Duration         = duration;
            Delay            = delay;
            Curve            = curve;
            StartCallback    = startCallback;
            CompleteCallback = completeCallback;
            LoopType         = loop;
            ObeyTimescale    = obeyTimeScale;

            ResetStartTime();
        }
Пример #4
0
        //Constructor:
        public LocalPosition(Transform target, Vector3 endValue, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.Position, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _target  = target;
            EndValue = endValue;
        }
Пример #5
0
        //Constructor:
        public ValueRect(Rect startValue, Rect endValue, Action <Rect> valueUpdatedCallback, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.Value, -1, duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _valueUpdatedCallback = valueUpdatedCallback;
            _start   = startValue;
            EndValue = endValue;
        }
        public Pitch(AudioSource target, float endValue, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.Pitch, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _target  = target;
            EndValue = endValue;
        }
Пример #7
0
        //Constructor:
        public ShakePosition(Transform target, Vector3 initialPosition, Vector3 intensity, float duration, float delay, AnimationCurve curve, Action startCallback, Action completeCallback, Tween.LoopType loop, bool obeyTimescale)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.Position, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _target          = target;
            _initialPosition = initialPosition;
            _intensity       = intensity;
        }
        public SpriteRendererColor(SpriteRenderer target, Color endValue, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.SpriteRendererColor, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _target  = target;
            EndValue = endValue;
        }
Пример #9
0
        //Constructor:
        public ShaderVector(Material target, string propertyName, Vector4 endValue, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //set essential properties:
            SetEssentials(Tween.TweenType.ShaderVector, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _target       = target;
            _propertyName = propertyName;
            EndValue      = endValue;
        }
Пример #10
0
        //Constructor:
        public SplinePercentage(Spline spline, Transform target, float startPercentage, float endPercentage, bool faceDirection, float duration, float delay, bool obeyTimescale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback)
        {
            //clamps:
            if (!spline.loop)
            {
                startPercentage = Mathf.Clamp01(startPercentage);
                endPercentage   = Mathf.Clamp01(endPercentage);
            }

            //set essential properties:
            SetEssentials(Tween.TweenType.Spline, target.GetInstanceID(), duration, delay, obeyTimescale, curve, loop, startCallback, completeCallback);

            //catalog custom properties:
            _spline          = spline;
            _target          = target;
            EndValue         = endPercentage;
            _startPercentage = startPercentage;
            _faceDirection   = faceDirection;
        }
Пример #11
0
        public static string Add(Quaternion start, Quaternion end, float duration, float delay, AnimationCurve curve, Tween.LoopType loopType, Action <Quaternion> progressCallback, Action completeCallback = null, bool destroyWhenDone = true)
        {
            TweenObject newTweenObject = new TweenObject(start, end, duration, delay, curve, loopType, progressCallback, completeCallback, destroyWhenDone);

            Instance.tweens.Add(newTweenObject);
            return(newTweenObject.id);
        }
Пример #12
0
 public TweenObject(Quaternion start, Quaternion end, float duration, float delay, AnimationCurve curve, Tween.LoopType loopType, Action <Quaternion> progressCallback, Action completeCallback = null, bool destroyWhenDone = true)
 {
     type                       = Type.Quaternion;
     startQuaternion            = start;
     endQuaternion              = end;
     progressCallbackQuaternion = progressCallback;
     Initialize(duration, delay, curve, completeCallback, loopType, destroyWhenDone);
 }
Пример #13
0
 public TweenObject(Color start, Color end, float duration, float delay, AnimationCurve curve, Tween.LoopType loopType, Action <Color> progressCallback, Action completeCallback = null, bool destroyWhenDone = true)
 {
     type                  = Type.Color;
     startColor            = start;
     endColor              = end;
     progressCallbackColor = progressCallback;
     Initialize(duration, delay, curve, completeCallback, loopType, destroyWhenDone);
 }
Пример #14
0
 public TweenObject(Vector3 start, Vector3 end, float duration, float delay, AnimationCurve curve, Tween.LoopType loopType, Action <Vector3> progressCallback, Action completeCallback = null, bool destroyWhenDone = true)
 {
     type                    = Type.Vector3;
     startVector3            = start;
     endVector3              = end;
     progressCallbackVector3 = progressCallback;
     Initialize(duration, delay, curve, completeCallback, loopType, destroyWhenDone);
 }
Пример #15
0
 //----------- Constructors -----------
 public TweenObject(float start, float end, float duration, float delay, AnimationCurve curve, Tween.LoopType loopType, Action <float> progressCallback, Action completeCallback = null, bool destroyWhenDone = true)
 {
     type = Type.Float;
     if (GUILayout.Button("Stop Pulse"))
     {
     }
     startFloat            = start;
     endFloat              = end;
     progressCallbackFloat = progressCallback;
     Initialize(duration, delay, curve, completeCallback, loopType, destroyWhenDone);
 }