Exemplo n.º 1
0
 private void onForceDestroy()
 {
     if (_tween != null)
     {
         _tween.Stop(TweenStopBehavior.Complete);
         _tween = null;
     }
 }
Exemplo n.º 2
0
        public static Vector2Tween TweenAnchoredPosition(this RectTransform obj, float duration, Vector2 from, Vector2 to)
        {
            Vector2Tween node = Vector2Tween.Allocate(duration, from, to);

            node.SetUpdate(
                (result) =>
            {
                obj.anchoredPosition = result;
            });
            return(node);
        }
Exemplo n.º 3
0
        internal static Vector2Tween GetVector2Tween(Vector2 from, Vector2 to, float t)
        {
            Vector2Tween tween;

            if (TryGetTween(vector2Tweens, out tween))
            {
                tween.Init(from, to, t);
            }
            else
            {
                tween         = new Vector2Tween(from, to, t, GenerateId());
                tween.Recycle = FinishTween;
            }

            _activeTweens.Add(tween);
            return(tween);
        }
Exemplo n.º 4
0
        private void onEndDelay()
        {
            Vector3 pos = view.gameObject.transform.position;

            GameObject player = GameObject.FindWithTag(PlayerView.ID);

            if (player != null)
            {
                Vector3 playerPos = player.transform.position;

                _tween = TweenFactory.Tween("MoveCoin", new Vector2(pos.x, pos.y), new Vector2(playerPos.x, playerPos.y + 0.5f), 1f, TweenScaleFunctions.CubicEaseIn, (tweenProgress) => {
                    view.gameObject.transform.position = new Vector3(tweenProgress.CurrentValue.x, tweenProgress.CurrentValue.y);
                }, (tweenComplete) => {
                    onCompleteTween();
                });
            }
            else
            {
                onCompleteTween();
            }
        }
Exemplo n.º 5
0
    public static PTween createTween <T>() where T : struct
    {
        PTween tween = null;
        Type   t     = typeof(T);

        if (t == typeof(int))
        {
            tween = new IntTween();
        }
        else if (t == typeof(float))
        {
            tween = new FloatTween();
        }
        else if (t == typeof(Vector2))
        {
            tween = new Vector2Tween();
        }
        else if (t == typeof(Vector3))
        {
            tween = new Vector3Tween();
        }
        else if (t == typeof(Vector4))
        {
            tween = new Vector4Tween();
        }
        else if (t == typeof(Color))
        {
            tween = new ColorTween();
        }
        else if (t == typeof(Quaternion))
        {
            tween = new QuaternionTween();
        }
        else
        {
            Debug.LogError("PTween createTween: invalid type: " + t); return(null);
        }
        add(tween);
        return(tween);
    }
        public ShipInterpolationManager(ShipMovementController movementController)
        {
            _movementController = movementController;
            _positionTween      = new Vector2Tween(Vector2.Zero, Vector2.Zero, 1);
            _rotationTween      = new NumberTween(0, 0, 1);
            _tweensComplete     = 0;
            _lock       = new object();
            _onComplete = () =>
            {
                lock (_lock)
                {
                    if (++_tweensComplete % 2 == 0)
                    {
                        Interpolating   = false;
                        _tweensComplete = 0;
                    }
                }
            };

            _positionTween.OnComplete += (_) =>
            {
                _onComplete();
            };

            _rotationTween.OnComplete += (_) =>
            {
                _onComplete();
            };

            _positionTween.OnChange += (newPosition) =>
            {
                _movementController.Position = newPosition;
            };

            _rotationTween.OnChange += (newRotation) =>
            {
                _movementController.Rotation = newRotation;
            };
        }
Exemplo n.º 7
0
        public ShipInterpolationManager(ShipMovementController movementController)
        {
            _movementController = movementController;
            _positionTween = new Vector2Tween(Vector2.Zero, Vector2.Zero, 1);
            _rotationTween = new NumberTween(0, 0, 1);
            _tweensComplete = 0;
            _lock = new object();
            _onComplete = () =>
            {
                lock (_lock)
                {
                    if (++_tweensComplete % 2 == 0)
                    {
                        Interpolating = false;
                        _tweensComplete = 0;
                    }
                }
            };

            _positionTween.OnComplete += (_) =>
            {
                _onComplete();
            };

            _rotationTween.OnComplete += (_) =>
            {
                _onComplete();
            };

            _positionTween.OnChange += (newPosition) =>
            {
                _movementController.Position = newPosition;
            };

            _rotationTween.OnChange += (newRotation) =>
            {
                _movementController.Rotation = newRotation;
            };
        }
Exemplo n.º 8
0
        public BaseTween VectorTween(Vector2 from, Vector2 to, float t)
        {
            Vector2Tween tween = TweenPool.GetVector2Tween(from, to, t);

            return(ProcessTween(tween));
        }