Beispiel #1
0
 public ClingyRotationTweener(GameObject gameObject, TweenOptions tweenOptions,
                              RotateMethod rotateMethod, GetDestinationRotationDelegate GetDestinationRotation,
                              TweenCompleteDelegate TweenComplete = null, TweenCancelledDelegate TweenCancelled = null)
     : base(gameObject, tweenOptions, TweenComplete, TweenCancelled)
 {
     this.rotateMethod           = rotateMethod;
     this.GetDestinationRotation = GetDestinationRotation;
 }
Beispiel #2
0
        public static Tweener TweenRotation(GameObject gameObject, TweenOptions tweenOptions,
                                            RotateMethod rotateMethod, GetDestinationRotationDelegate GetDestinationRotation,
                                            TweenCompleteDelegate TweenComplete = null, TweenCancelledDelegate TweenCancelled = null)
        {
            Tweener tweener = new ClingyRotationTweener(gameObject, tweenOptions, rotateMethod,
                                                        GetDestinationRotation, TweenComplete, TweenCancelled);

            tweener.Start();
            return(tweener);
        }
Beispiel #3
0
        public void Apply(GetDestinationPositionDelegate GetDestinationPosition = null,
                          GetDestinationRotationDelegate GetDestinationRotation = null,
                          SnapshotCompleteDelegate SnapshotComplete             = null, bool tweenFirst = false)
        {
            if (tweening)
            {
                throw new System.InvalidOperationException("Already applying.");
            }
            if (!target)
            {
                throw new System.InvalidOperationException("No target for snapshot.");
            }

            this.tweenFirst = tweenFirst;

            SnapshotCompleteDelegate FinishIfAllTweensComplete = () => {
                if (tweening)
                {
                    return;
                }
                positionTweener = rotationTweener = null;
                if (tweenFirst)
                {
                    ApplyNonTweenables();
                }
                if (SnapshotComplete != null)
                {
                    SnapshotComplete();
                }
            };

            if (!tweenFirst)
            {
                ApplyNonTweenables();
            }

            bool starting = true;

            // fixme - need to make it an option to translate position before rotation or vice versa I guess...
            if (options.restoreRotation)
            {
                if (GetDestinationRotation == null)
                {
                    GetDestinationRotation = () => data.rotation;
                }
                rotationTweener = Tweener.TweenRotation(target, options.tweenRotationOptions, options.rotateMethod,
                                                        GetDestinationRotation,
                                                        TweenComplete: () => {
                    if (!starting)
                    {
                        FinishIfAllTweensComplete();
                    }
                }, TweenCancelled: () => {
                    rotationTweener = null;
                }
                                                        );
            }

            if (options.restorePosition)
            {
                if (GetDestinationPosition == null)
                {
                    GetDestinationPosition = () => data.position;
                }
                positionTweener = Tweener.TweenPosition(target, options.tweenPositionOptions, options.moveMethod,
                                                        GetDestinationPosition,
                                                        TweenComplete: () => {
                    if (!starting)
                    {
                        FinishIfAllTweensComplete();
                    }
                }, TweenCancelled: () => {
                    positionTweener = null;
                }
                                                        );
            }

            starting = false;
            FinishIfAllTweensComplete();
        }