コード例 #1
0
ファイル: Tween.cs プロジェクト: Rxanadu/ZestKit
        void resetState()
        {
            context                 = null;
            _completionHandler      = _loopCompleteHandler = null;
            _isTimeScaleIndependent = false;
            _tweenState             = TweenState.Complete;
            _shouldRecycleTween     = true;
            _isRelative             = false;
            _easeType               = ZestKit.defaultEaseType;
            _animationCurve         = null;

            if (_nextTween != null)
            {
                _nextTween.recycleSelf();
                _nextTween = null;
            }

            _delay              = 0f;
            _duration           = 0f;
            _elapsedTime        = 0f;
            _loopType           = LoopType.None;
            _delayBetweenLoops  = 0f;
            _loops              = 0;
            _isRunningInReverse = false;
        }
コード例 #2
0
        public override bool Update()
        {
            if (isPaused)
            {
                return(false);
            }

            if (currentTweenIndex >= tweenList.Count)
            {
                return(true);
            }

            ITweenable tween = tweenList[currentTweenIndex];

            if (tween.Update())
            {
                currentTweenIndex++;
                if (currentTweenIndex == tweenList.Count)
                {
                    if (completionHandler != null)
                    {
                        completionHandler(this);
                    }
                    isCurrentlyManagedBySynTween = false;
                    return(true);
                }
                else
                {
                    tweenList[currentTweenIndex].Start();
                }
            }

            return(false);
        }
コード例 #3
0
        void resetState()
        {
            context                 = null;
            _completionHandler      = _loopCompleteHandler = null;
            _isFromValueOverridden  = false;
            _isTimeScaleIndependent = false;
            _tweenState             = TweenState.Complete;
            // TODO: I don't think we should ever flip the flag from _shouldRecycleTween = false without the user's consent. Needs research and some thought
            //_shouldRecycleTween = true;
            _isRelative     = false;
            _easeType       = ZestKit.defaultEaseType;
            _animationCurve = null;

            if (_nextTween != null)
            {
                _nextTween.recycleSelf();
                _nextTween = null;
            }

            _delay              = 0f;
            _duration           = 0f;
            _timeScale          = 1f;
            _elapsedTime        = 0f;
            _loopType           = LoopType.None;
            _delayBetweenLoops  = 0f;
            _loops              = 0;
            _isRunningInReverse = false;
        }
コード例 #4
0
    private static int DOTween(ILuaState lua)
    {
        ITweenable tweenable       = lua.ToTweenable(lua.ToUserData(2), lua.ToAnyObject(1));
        object     from            = lua.ToAnyObject(3);
        object     to              = lua.ToAnyObject(4);
        float      duration        = lua.ToSingle(5);
        Ease       ease            = (Ease)lua.OptEnumValue(6, typeof(Ease), Ease.Linear);
        float      delay           = (float)lua.OptNumber(7, 0);
        var        funcRef         = lua.ToLuaFunction(8);
        bool       ignoreTimescale = lua.OptBoolean(9, false);

        if (tweenable != null)
        {
            var tw = tweenable.Tween(from, to, duration)
                     .EaseBy(ease).DelayFor(delay).SetUpdate(UpdateType.Normal, ignoreTimescale);
            if (funcRef != null)
            {
                tw.CompleteWith((o) => { funcRef.Invoke(o); funcRef.Dispose(); });
            }
            lua.PushLightUserData(tw);
        }
        else
        {
            lua.PushNil();
        }
        return(1);
    }
コード例 #5
0
ファイル: Boing.cs プロジェクト: MurrayIRC/kaneda-old-unity
        private void Update()
        {
            isUpdating = true;

            tempTweens.Clear();
            tempTweens.AddRange(activeTweens);
            for (int i = 0; i < tempTweens.Count; i++)
            {
                ITweenable tween = tempTweens[i];

                if (removedTweens.Contains(tween))
                {
                    continue;
                }

                if (tween.Update())
                {
                    // If true, the tween has completed.
                    tween.RecycleSelf();
                    activeTweens.Remove(tween);
                }
            }

            removedTweens.Clear();

            isUpdating = false;
        }
コード例 #6
0
        // -------------------------------------------------------------------------
        // Helpers
        // -------------------------------------------------------------------------

        private void Reset()
        {
            _target    = null;
            _tweenType = PositionType.NONE;
            _equation  = null;

            _isReversed    = false;
            _isInitialized = false;
            _isPooled      = false;

            _combinedTweenCount = 0;

            _delayMillis  = 0;
            _isStarted    = false;
            _isDelayEnded = false;
            _isEnded      = false;
            _isFinished   = true;

            _completeCallbacks.Clear();
            _iterationCompleteCallbacks.Clear();
            _killCallbacks.Clear();
            _poolCallbacks.Clear();
            _startCallbacks.Clear();
            _endOfDelayCallbacks.Clear();

            _repeatCnt         = 0;
            _iteration         = 0;
            _repeatDelayMillis = 0;

            _userData = null;
        }
コード例 #7
0
ファイル: GoKitLite.cs プロジェクト: Troilk/TicTacToe
            internal void reset()
            {
                // any pointers or values that are not guaranteed to be set later are defaulted here
                transform              = null;
                rectTransform          = null;
                targetVector           = _startVector = _diffVector = Vector3.zero;
                delay                  = delayBetweenLoops = 0f;
                isTimeScaleIndependent = isRunningInReverse = isPaused = false;
                loopType               = LoopType.None;
                easeFunction           = null;
                isRelativeTween        = false;
                onComplete             = onLoopComplete = null;
                onDelayComplete        = null;
                customAction           = null;
                propertyTween          = null;
                _material              = null;
                materialProperty       = null;
                delayFinished          = false;

                if (nextTween != null)
                {
                    // null out and return to the stack all additional tweens
                    GoKitLite.instance._inactiveTweenStack.Push(nextTween);
                    nextTween.reset();
                }

                nextTween = null;
            }
コード例 #8
0
        private void Reset()
        {
            Context                = null;
            updateHandler          = null;
            completionHandler      = null;
            loopCompletionHandler  = null;
            updateParams           = null;
            completionParams       = null;
            loopCompletionParams   = null;
            isFromValueOverridden  = false;
            isTimeScaleIndependent = false;
            tweenState             = TweenState.Complete;
            isRelative             = false;
            easeType               = Boing.DefaultEaseType;
            animationCurve         = null;

            if (nextTween != null)
            {
                nextTween.RecycleSelf();
                nextTween = null;
            }

            delay              = 0f;
            duration           = 0f;
            timeScale          = 1f;
            elapsedTime        = 0f;
            loopType           = LoopType.None;
            delayBetweenLoops  = 0f;
            numLoops           = 0;
            isRunningInReverse = false;
        }
コード例 #9
0
 public virtual void recycleSelf()
 {
     if (_shouldRecycleTween)
     {
         _target    = null;
         _nextTween = null;
     }
 }
コード例 #10
0
        private void AnimateScaleMultiplier()
        {
            _scaleTween?.stop();

            ScaleMultiplier = 1.4f;
            _scaleTween     = this.tween("ScaleMultiplier", 1f, 0.4f).setEaseType(EaseType.ExpoOut);
            _scaleTween.start();
        }
コード例 #11
0
 public virtual void RecycleSelf()
 {
     if (shouldRecycleTween)
     {
         target    = null;
         nextTween = null;
     }
 }
コード例 #12
0
        private void StopProcess(ITweenable processor)
        {
            if (processor.CurrentProcess == null)
            {
                return;
            }

            processor.Tweener.StopCoroutine(processor.CurrentProcess);
        }
コード例 #13
0
        private void StartProcess(ITweenable processor)
        {
            if (!processor.ActiveInHierarchy)
            {
                return;
            }

            processor.Tweener.StartCoroutine(processor.CurrentProcess);
        }
コード例 #14
0
        // -------------------------------------------------------------------------
        // Factories
        // -------------------------------------------------------------------------

        /**
         * Several options such as delays and callbacks can be added to the tween.
         * This method hides some of the internal optimizations such as object
         * reuse for convenience. However, you can control the creation of the
         * tween by using the classic constructor.
         *
         * @param target The target of the interpolation.
         * @param tweenType The desired type of interpolation.
         * @param durationMillis The duration of the interpolation, in milliseconds.
         * @param equation The easing equation used during the interpolation.
         * @return The generated Tween.
         */
        public static Tween To(ITweenable target, PositionType tweenType, int durationMillis, TweenEquation equation)
        {
            var tween = Pool.Get();

            tween.Reset();
            tween.__build(target, tweenType, durationMillis, equation);
            tween._isPooled = _isPoolEnabled;
            return(tween);
        }
コード例 #15
0
        /**
         * @param target The target of the interpolation.
         * @param tweenType The desired type of interpolation.
         * @return The generated Tween.
         */
        public static Tween Set(ITweenable target, PositionType tweenType)
        {
            var tween = Pool.Get();

            tween.Reset();
            tween.__build(target, tweenType, 0, null);
            tween._isPooled = _isPoolEnabled;
            return(tween);
        }
コード例 #16
0
ファイル: Boing.cs プロジェクト: MurrayIRC/kaneda-old-unity
        public void RemoveTween(ITweenable tween)
        {
            tween.RecycleSelf();
            activeTweens.Remove(tween);

            if (isUpdating)
            {
                removedTweens.Add(tween);
            }
        }
コード例 #17
0
    private static int FreeTween(ILuaState lua)
    {
        var        tweenType = lua.ToAnyObject(1);
        var        tweenObj  = lua.ToUserData(2);
        ITweenable tweenable = lua.ToTweenable(tweenObj, tweenType);

        if (tweenable != null)
        {
            object from = lua.ToAnyObject(3);
            object to   = lua.ToAnyObject(4);

            var   tweenParam      = lua.ToJsonObj(5);
            float duration        = tweenParam.toValue <float>("duration");
            var   ease            = tweenParam.toValue("ease", Ease.Linear);
            var   delay           = tweenParam.toValue("delay", 0f);
            var   loops           = tweenParam.toValue("loops", 0);
            var   loopType        = tweenParam.toValue("loopType", LoopType.Restart);
            var   updateType      = tweenParam.toValue("updateType", UpdateType.Normal);
            var   ignoreTimescale = tweenParam.toValue("ignoreTimescale", true);

            LuaFunction onUpdate = null;
            var         joUpdate = tweenParam["update"];
            if (joUpdate != null)
            {
                onUpdate = joUpdate.ToType(typeof(LuaFunction), null) as LuaFunction;
            }

            LuaFunction onComplete = null;
            var         joComplete = tweenParam["complete"];
            if (joComplete != null)
            {
                onComplete = joComplete.ToType(typeof(LuaFunction), null) as LuaFunction;
            }

            var tw = tweenable.Tween(from, to, duration);
            if (tw != null)
            {
                tw.EaseBy(ease).DelayFor(delay)
                .LoopFor(loops, loopType)
                .SetUpdate(updateType, ignoreTimescale);
                if (onUpdate != null)
                {
                    tw.UpdateWith((t, o) => onUpdate.Invoke(t, o));
                }
                if (onComplete != null)
                {
                    tw.CompleteWith((o) => { onComplete.Invoke(o); onComplete.Dispose(); });
                }
                lua.PushLightUserData(tw);
                return(1);
            }
        }
        LogMgr.W("Free tween fail: {0} of {1}", tweenType, tweenObj);
        return(0);
    }
コード例 #18
0
ファイル: MrTween.cs プロジェクト: MurrayIRC/mara
        /// <summary>
        /// removes a tween from the active tweens list
        /// </summary>
        /// <param name="tween">Tween.</param>
        public void RemoveTween(ITweenable tween)
        {
            tween.RecycleSelf();
            _activeTweens.Remove(tween);

            // make sure it doesn't get updated if we are in the update loop
            if (_isUpdating)
            {
                _removedTweens.Add(tween);
            }
        }
コード例 #19
0
ファイル: GoKitLite.cs プロジェクト: Troilk/TicTacToe
            /// <summary>
            /// adds a property tween that will start as soon as the current tween completes
            /// </summary>
            public Tween next(float duration, ITweenable newPropertyTween)
            {
                var tween = GoKitLite.instance.nextAvailableTween(transform, duration, TweenType.Property);

                tween.easeFunction  = easeFunction;
                tween.propertyTween = newPropertyTween;

                nextTween = tween;

                return(tween);
            }
コード例 #20
0
ファイル: GoKitLite.cs プロジェクト: Troilk/TicTacToe
        public Tween propertyTween(ITweenable propertyTween, float duration)
        {
            var tween = nextAvailableTween(this.transform, duration, TweenType.Property);

            tween.propertyTween = propertyTween;

            tween.prepareForUse();
            _activeTweens.Add(tween);

            return(tween);
        }
コード例 #21
0
 /**
  * Kills every valid tween associated to the given target and tween type.
  */
 public void Kill(ITweenable target, PositionType tweenType)
 {
     for (int i = 0; i < _tweens.Count; i++)
     {
         Tween tween = _tweens[i];
         if (tween.GetTarget() == target && tween.GetTweenType() == tweenType && !tween.GetFinished())
         {
             tween.Kill();
         }
     }
 }
コード例 #22
0
ファイル: TweenManager.cs プロジェクト: xuyanwen2012/Warband
 /// <summary>
 /// removes a tween from the active tweens list
 /// </summary>
 /// <param name="tween">Tween.</param>
 public static void removeTween(ITweenable tween)
 {
     if (_instance._isUpdating)
     {
         _instance._tempTweens.add(tween);
     }
     else
     {
         tween.recycleSelf();
         _instance._activeTweens.remove(tween);
     }
 }
コード例 #23
0
 /**
  * Returns true if the manager contains any valid tween associated to the
  * given target and tween type.
  */
 public bool Contains(ITweenable target, PositionType tweenType)
 {
     for (int i = 0; i < _tweens.Count; i++)
     {
         Tween tween = _tweens[i];
         if (tween.GetTarget() == target && tween.GetTweenType() == tweenType && !tween.GetFinished())
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #24
0
ファイル: ZestKit.cs プロジェクト: jinsp/SevenUpDrawPoker
 /// <summary>
 /// removes a tween from the active tweens list
 /// </summary>
 /// <param name="tween">Tween.</param>
 public void removeTween(ITweenable tween)
 {
     if (_isUpdating)
     {
         _tempTweens.Add(tween);
     }
     else
     {
         tween.recycleSelf();
         _activeTweens.Remove(tween);
     }
 }
コード例 #25
0
ファイル: Tween.cs プロジェクト: Rxanadu/ZestKit
        public ITween <T> setNextTween(ITweenControl nextTween)
        {
            if (nextTween is ITweenable)
            {
                _nextTween = nextTween as ITweenable;
            }
            else
            {
                Debug.LogError("attempted to set a tween that does not implement ITweenable as the nextTween!");
            }

            return(this);
        }
コード例 #26
0
    private static ITweenable ToTweenable(this ILuaState lua, object tweenObject, object tweenType)
    {
        ITweenable tweenable = null;

        if (tweenType == null)
        {
            tweenable = tweenObject as ITweenable;
        }
        else
        {
            var        com = tweenObject as Component;
            GameObject go  = com != null ? com.gameObject : tweenObject as GameObject;
            if (go)
            {
                if (tweenType is string)
                {
                    var tweenName = tweenType as string;
                    tweenable = go.GetComponent(tweenName) as ITweenable;
                    if (tweenable == null)
                    {
                        switch (tweenName)
                        {
                        case "TweenPosition": tweenable = go.AddComponent(typeof(TweenPosition)) as ITweenable; break;

                        case "TweenRotation": tweenable = go.AddComponent(typeof(TweenRotation)) as ITweenable; break;

                        case "TweenScaling": tweenable = go.AddComponent(typeof(TweenScaling)) as ITweenable; break;

                        case "TweenTransform": tweenable = go.AddComponent(typeof(TweenTransform)) as ITweenable; break;

                        case "TweenAlpha": tweenable = go.AddComponent(typeof(TweenAlpha)) as ITweenable; break;

                        case "TweenSize": tweenable = go.AddComponent(typeof(TweenSize)) as ITweenable; break;

                        default: break;
                        }
                    }
                }
                else if (tweenType is System.Type)
                {
                    var tweenerType = tweenType as System.Type;
                    tweenable = go.GetComponent(tweenerType) as ITweenable;
                    if (tweenable == null)
                    {
                        tweenable = go.AddComponent(tweenerType) as ITweenable;
                    }
                }
            }
        }
        return(tweenable);
    }
コード例 #27
0
        /**
         * Gets an array containing every tween in the manager dedicated to the
         * given target and tween type.
         * <b>Warning:</b> this method allocates an ArrayList and an array.
         */
        public Tween[] GetTweens(ITweenable target, PositionType tweenType)
        {
            List <Tween> selectedTweens = new List <Tween>();

            for (int i = 0; i < _tweens.Count; i++)
            {
                Tween tween = _tweens[i];
                if (tween.GetTarget() == target && tween.GetTweenType() == tweenType && !tween.GetFinished())
                {
                    selectedTweens.Add(tween);
                }
            }
            return(selectedTweens.ToArray());
        }
コード例 #28
0
        public TweenSequence AppendTween(ITweenable tween)
        {
            if (tween is ITweenable)
            {
                tween.Resume();
                tweenList.Add(tween as ITweenable);
            }
            else
            {
                Debug.LogError("Cannot add a tween to a sequence that does not implement ITweenable.");
            }

            return(this);
        }
コード例 #29
0
ファイル: TweenChain.cs プロジェクト: riktothepast/GGJ16
		public TweenChain appendTween( ITweenable tween )
		{
			// make sure we have a legit ITweenable
			if( tween is ITweenable )
			{
				tween.resume();
				_tweenList.Add( tween as ITweenable );
			}
			else
			{
				Debug.LogError( "attempted to add a tween that does not implement ITweenable to a TweenChain!" );
			}

			return this;
		}
コード例 #30
0
        public TweenChain appendTween(ITweenable tween)
        {
            // make sure we have a legit ITweenable
            if (tween is ITweenable)
            {
                tween.resume();
                _tweenList.Add(tween as ITweenable);
            }
            else
            {
                Debug.LogError("attempted to add a tween that does not implement ITweenable to a TweenChain!");
            }

            return(this);
        }
コード例 #31
0
        // -------------------------------------------------------------------------
        // Ctor
        // -------------------------------------------------------------------------

        /**
         * Instantiates a new Tween from scratch.
         * @param target The target of the interpolation.
         * @param tweenType The desired type of interpolation.
         * @param durationMillis The duration of the interpolation, in milliseconds.
         * @param equation The easing equation used during the interpolation.
         */
        public Tween(ITweenable target, PositionType tweenType, int durationMillis, TweenEquation equation)
        {
            _startValues            = new float[MaxCombinedTweens];
            _targetValues           = new float[MaxCombinedTweens];
            _targetMinusStartValues = new float[MaxCombinedTweens];

            _startCallbacks             = new List <ITweenCallback>(3);
            _endOfDelayCallbacks        = new List <ITweenCallback>(3);
            _iterationCompleteCallbacks = new List <ITweenCallback>(3);
            _completeCallbacks          = new List <ITweenCallback>(3);
            _killCallbacks = new List <ITweenCallback>(3);
            _poolCallbacks = new List <ITweenCallback>(3);

            Reset();
            __build(target, tweenType, durationMillis, equation);
        }
コード例 #32
0
ファイル: GoKitLite.cs プロジェクト: prime31/GoKitLite
            internal void reset()
            {
                // any pointers or values that are not guaranteed to be set later are defaulted here
                transform = null;
                rectTransform = null;
                targetVector = _startVector = _diffVector = Vector3.zero;
                delay = delayBetweenLoops = 0f;
                isTimeScaleIndependent = isRunningInReverse = isPaused = false;
                loopType = LoopType.None;
                easeType = GoKitLite.defaultEaseType;
                animCurve = null;
                isRelativeTween = false;
                onComplete = onLoopComplete = null;
                customAction = null;
                propertyTween = null;
                _material = null;
                materialProperty = null;

                if( nextTween != null )
                {
                    // null out and return to the stack all additional tweens
                    GoKitLite.instance._inactiveTweenStack.Push( nextTween );
                    nextTween.reset();
                }

                nextTween = null;
            }
コード例 #33
0
ファイル: TweenManager.cs プロジェクト: prime31/Nez
		/// <summary>
		/// adds a tween to the active tweens list
		/// </summary>
		/// <param name="tween">Tween.</param>
		public static void addTween( ITweenable tween )
		{
			_instance._activeTweens.add( tween );
		}
コード例 #34
0
ファイル: TweenManager.cs プロジェクト: prime31/Nez
		/// <summary>
		/// removes a tween from the active tweens list
		/// </summary>
		/// <param name="tween">Tween.</param>
		public static void removeTween( ITweenable tween )
		{
			if( _instance._isUpdating )
			{
				_instance._tempTweens.add( tween );
			}
			else
			{
				tween.recycleSelf();
				_instance._activeTweens.remove( tween );
			}
		}
コード例 #35
0
ファイル: TweenAction.cs プロジェクト: ncguy2/HeadFirstCSharp
 public void reset() {
     m_target = null;
     m_reverse = false;
     m_interpolation = null;
     restart();
 }
コード例 #36
0
ファイル: TweenAction.cs プロジェクト: ncguy2/HeadFirstCSharp
 public TweenAction setTarget(ITweenable target) {
     this.m_target = target;
     return this;
 }
コード例 #37
0
ファイル: GoKitLite.cs プロジェクト: prime31/GoKitLite
        public Tween propertyTween( ITweenable propertyTween, float duration )
        {
            var tween = nextAvailableTween( this.transform, duration, TweenType.Property );
            tween.propertyTween = propertyTween;

            tween.prepareForUse();
            _activeTweens.Add( tween );

            return tween;
        }
コード例 #38
0
ファイル: GoKitLite.cs プロジェクト: prime31/GoKitLite
            /// <summary>
            /// adds a property tween that will start as soon as the current tween completes
            /// </summary>
            public Tween next( float duration, ITweenable newPropertyTween )
            {
                var tween = GoKitLite.instance.nextAvailableTween( transform, duration, TweenType.Property );
                tween.easeType = easeType;
                tween.propertyTween = newPropertyTween;

                nextTween = tween;

                return tween;
            }
コード例 #39
0
		/// <summary>
		/// adds a tween to the active tweens list
		/// </summary>
		/// <param name="tween">Tween.</param>
		public void addTween( ITweenable tween )
		{
			_activeTweens.Add( tween );
		}
コード例 #40
0
		/// <summary>
		/// removes a tween from the active tweens list. List.Remove can be quite slow so it is preferable to sue the other
		/// removeTween variant.
		/// </summary>
		/// <param name="tween">Tween.</param>
		public void removeTween( ITweenable tween )
		{
			_activeTweens.Remove( tween );
			tween.recycleSelf();
		}
コード例 #41
0
		/// <summary>
		/// removes the tween at index from the active tweens list.
		/// </summary>
		/// <param name="tween">Tween.</param>
		/// <param name="index">Index.</param>
		public void removeTween( ITweenable tween, int index )
		{
			_activeTweens.RemoveAt( index );
			tween.recycleSelf();
		}