Пример #1
0
    public void RegisterTweenValueType()
    {
        var runner = new TweenRunner();

        // Register a test type
        TweenDataRegistry.RegisterTweenDataType <TestType>(GetValueTestType);

        // Make sure a tween of that type can be started and updated
        var startValue  = (TestType)1f;
        var tweenParams = new TweenParams
        {
            TweenSecs = 10f,
            Ease      = EaseType.Linear,
            Loop      = LoopType.PingPong
        };
        var tweenRef = runner.StartTween <TestType>(
            startValue,
            10f,
            tweenParams,
            null
            );

        // Make sure the starting value is correct
        var value = runner.GetTweenValue <TestType>(tweenRef);

        Assert.IsTrue(value == startValue, $"TestType pre update, got value {value} should be {startValue}");

        runner.Update(1f / 60f);

        // Make sure the value has changed after updating
        value = runner.GetTweenValue <TestType>(tweenRef);
        Assert.IsTrue(value != startValue, $"TestType post update, got value {value} should be different from start value {startValue}");

        runner.StopTween(tweenRef);
    }
Пример #2
0
    private static int SetUpdate(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(TweenParams), typeof(bool)))
            {
                TweenParams tweenParams = (TweenParams)ToLua.ToObject(L, 1);
                bool        update      = LuaDLL.lua_toboolean(L, 2);
                TweenParams o           = tweenParams.SetUpdate(update);
                ToLua.PushObject(L, o);
                result = 1;
            }
            else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(TweenParams), typeof(UpdateType), typeof(bool)))
            {
                TweenParams tweenParams2        = (TweenParams)ToLua.ToObject(L, 1);
                UpdateType  updateType          = (UpdateType)((int)ToLua.ToObject(L, 2));
                bool        isIndependentUpdate = LuaDLL.lua_toboolean(L, 3);
                TweenParams o2 = tweenParams2.SetUpdate(updateType, isIndependentUpdate);
                ToLua.PushObject(L, o2);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.TweenParams.SetUpdate");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #3
0
        //creates a new tween with given arguments that moves along the path
        private void CreateTween()
        {
            //prepare DOTween's parameters, you can look them up here
            //http://dotween.demigiant.com/documentation.php

            TweenParams parms = new TweenParams();

            //differ between speed or time based tweening
            if (timeValue == TimeValue.speed)
            {
                parms.SetSpeedBased();
            }
            if (loopType == LoopType.yoyo)
            {
                parms.SetLoops(-1, DG.Tweening.LoopType.Yoyo);
            }

            //apply ease type or animation curve
            if (easeType == DG.Tweening.Ease.INTERNAL_Custom)
            {
                parms.SetEase(animEaseType);
            }
            else
            {
                parms.SetEase(easeType);
            }

            if (moveToPath)
            {
                parms.OnWaypointChange(OnWaypointReached);
            }
            else
            {
                if (loopType == LoopType.yoyo)
                {
                    parms.OnStepComplete(ReachedEnd);
                }

                transform.position = wpPos[0];

                parms.OnWaypointChange(OnWaypointChange);
                parms.OnComplete(ReachedEnd);
            }

            tween = transform.DOPath(wpPos, originSpeed, pathType, pathMode, 1)
                    .SetAs(parms)
                    .SetOptions(false, lockPosition, lockRotation)
                    .SetLookAt(lookAhead);
            if (!moveToPath && startPoint > 0)
            {
                GoToWaypoint(startPoint);
                startPoint = 0;
            }

            //continue new tween with adjusted speed if it was changed before
            if (originSpeed != speed)
            {
                ChangeSpeed(speed);
            }
        }
Пример #4
0
        private void Awake()
        {
            _icon         = GetComponent <MaskableGraphic>();
            _icon.color   = Colors.clearWhite;
            _icon.enabled = false;
            _transform    = _icon.transform;

            TweenParams commonTweenParams = new TweenParams()
                                            .SetEase(_ease)
                                            .SetRecyclable(true)
                                            .SetAutoKill(false);

            _fadeIn = _icon
                      .DOColor(Color.white, _fadeDuration)
                      .SetAs(commonTweenParams)
                      .OnStart(OnStartLoading)
                      .Pause();
            _fadeOut = _icon
                       .DOColor(Colors.clearWhite, _fadeDuration)
                       .SetAs(commonTweenParams)
                       .OnComplete(OnCompleteLoading)
                       .Pause();

            // _text.color = Colors.clearWhite;
            // _text.enabled = false;
        }
Пример #5
0
        public void Initialize(GameObject newEnemy, EnemySpawn spawnObject, GameObject container)
        {
            if (waypoints != null)
            {
                var worldWaypoints = new Vector3[waypoints.Length];

                for (var i = 0; i < waypoints.Length; i++)
                {
                    var localWaypoint = waypoints[i];

                    worldWaypoints[i] = new Vector3(spawnObject.flipOnX ? -localWaypoint.x : localWaypoint.x,
                                                    //worldWaypoints[i] = newEnemy.transform.TransformPoint(spawnObject.flipOnX ? -localWaypoint.x : localWaypoint.x,
                                                    localWaypoint.y, localWaypoint.z);
                }

                var tweenCompletion = container.AddComponent <DisappearWhenTweenComplete>();

                var tweenParams = new TweenParams();
                tweenParams.SetSpeedBased(true).SetEase(Ease.Linear).SetLoops(0).SetAutoKill(true);
                if (tweenCompletion != null)
                {
                    tweenParams.OnComplete(tweenCompletion.OnTweenComplete);
                }

                var tween = newEnemy.transform.DOLocalPath(worldWaypoints, speed, PathType.CatmullRom, PathMode.Full3D, tweenPathResolution)
                            //newEnemy.transform.DOLocalPath(theWaypoints, speed, PathType.CatmullRom, PathMode.TopDown2D)
                            .SetAs(tweenParams).SetOptions(false).SetLookAt(lookAhead, -Vector3.forward)
                ;
            }
        }
Пример #6
0
    private static int OnWaypointChange(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams         tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            LuaTypes            luaTypes    = LuaDLL.lua_type(L, 2);
            TweenCallback <int> action;
            if (luaTypes != LuaTypes.LUA_TFUNCTION)
            {
                action = (TweenCallback <int>)ToLua.CheckObject(L, 2, typeof(TweenCallback <int>));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                action = (DelegateFactory.CreateDelegate(typeof(TweenCallback <int>), func) as TweenCallback <int>);
            }
            TweenParams o = tweenParams.OnWaypointChange(action);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    private static int SetAs(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(Tween), typeof(Tween)))
            {
                Tweener t       = (Tweener)ToLua.ToObject(L, 1);
                Tween   asTween = (Tween)ToLua.ToObject(L, 2);
                Tween   o       = t.SetAs(asTween);
                ToLua.PushObject(L, o);
                result = 1;
            }
            else if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(Tween), typeof(TweenParams)))
            {
                Tweener     t2          = (Tweener)ToLua.ToObject(L, 1);
                TweenParams tweenParams = (TweenParams)ToLua.ToObject(L, 2);
                Tween       o2          = t2.SetAs(tweenParams);
                ToLua.PushObject(L, o2);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.Tweener.SetAs");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #8
0
    private void OnEnable()
    {
        TweenParams tParms = new TweenParams().SetLoops(-1).SetEase(Ease.Linear);

        circle.DOLocalRotate(new Vector3(30, 0, 360), speed, RotateMode.FastBeyond360).SetAs(tParms);

        renderer = circle.GetComponent <SpriteRenderer>();
    }
Пример #9
0
 public void onTweenTo(Transform Moveto)
 {
     DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
     tParmsMove   = new TweenParams().SetDelay(this.waitTime).SetLoops(this.LoopTimes, this.loopType).SetEase(this.easeType).OnStart(onStartCallback).OnComplete(onCompleteCallback).SetId(this.name).SetAutoKill(true);
     tParmsScale  = new TweenParams().SetDelay(this.waitTime).SetLoops(this.LoopTimes, this.loopType).SetEase(this.easeType).SetId(this.name).SetAutoKill(true);
     tParmsRotate = new TweenParams().SetDelay(this.waitTime).SetLoops(this.LoopTimes, this.loopType).SetEase(this.easeType).SetId(this.name).SetAutoKill(true);
     onPlayTween(Moveto);
 }
Пример #10
0
    public void Awake()
    {
        // Cache default anim values
        this.rectTransform = GetComponent <RectTransform>();
        this.pivotY        = this.rectTransform.pivot.y;

        // Set anim settings
        this.slideAnimParams = new TweenParams().SetEase(Ease.InOutExpo);
    }
Пример #11
0
    public void MakeTweener()
    {
        TweenParams para = new TweenParams();

        //   1)设置动画循环
        //     第一个参数是循环次数  -1代表无限循环
        //     第二个参数是循环方式
        //      Restart  重新开始
        //      Yoyo   从起始点运动到目标点,再从目标点运动回来,这样循环
        //      Incremental   一直向着运动方向运动
        para.SetLoops(-1, LoopType.Yoyo);

        //   2)设置参数
        transform.DOMove(Vector3.one, 2).SetAs(para);

        //   3)设置自动杀死动画
        transform.DOMove(Vector3.one, 1).SetAutoKill(true);

        //   4)from补间
        //     例如;
        transform.DOMove(Vector3.one, 2).From(true);
        //   From参数 isRelative(相对的):
        //    为true,传入的就是偏移量,即当前坐标 + 传入值 = 目标值
        //    为falese,传入的就是目标值,即传入值 = 目标值

        //   5)设置动画延时
        transform.DOMove(Vector3.one, 2).SetDelay(1);

        //   6)设置动画运动以速度为基准
        //      例如:
        transform.DOMove(Vector3.one, 1).SetSpeedBased();
        //   使用SetSpeedBased时,移动方式就变成以速度为基准
        //   原本表示持续时间的第二个参数,就变成表示速度的参数,每秒移动的单位数

        //   7)设置动画ID
        transform.DOMove(Vector3.one, 2).SetId("Id");

        //   8)设置是否可回收
        //     为true的话,动画播放完会被回收,缓存下来,不然播完就直接销毁
        transform.DOMove(Vector3.one, 2).SetRecyclable(true);

        //   9)设置动画为增量运动
        //       例如:
        transform.DOMove(Vector3.one, 2).SetRelative(true);
        // SetRelative参数 isRelative(相对的):
        // 为true,传入的就是偏移量,即当前坐标 + 传入值 = 目标值 为falese,传入的就是目标值,即传入值 = 目标值

        //   10)设置动画的帧函数
        //    例如:
        transform.DOMove(Vector3.one, 2).SetUpdate(UpdateType.Normal, true);
        //  第一个参数 UpdateType :选择使用的帧函数
        //  UpdateType.Normal:更新每一帧中更新要求。
        //  UpdateType.Late:在LateUpdate调用期间更新每一帧。
        //  UpdateType.Fixed:使用FixedUpdate调用进行更新。
        //  UpdateType.Manual:通过手动DOTween.ManualUpdate调用进行更新。
        //  第二个参数:为TRUE,则补间将忽略Unity的Time.timeScale
    }
Пример #12
0
 /// <summary>
 /// Close popup with actal sequence and callback.
 /// </summary>
 /// <param name="_sequence"></param>
 /// <param name="_tParms"></param>
 /// <param name="_callback"></param>
 void Close(Sequence _sequence, TweenParams _tParms, TweenCallback _callback)
 {
     Time.timeScale = 1;
     _sequence.Append(GetComponent <RectTransform>().DOAnchorPos(HidePosition, 0.15f).SetAs(_tParms));
     if (_callback != null)
     {
         _callback();
     }
 }
Пример #13
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(0.6f));

        TweenParams tp = new TweenParams().SetEase(Ease.Linear);

        tp.SetSpeedBased(speedBased);
        txtRichA.DOText("This is a <color=#ff0000>colored <color=#00ff00>text</color></color> and normal text. And this is a minor sign: <", duration, true, scrambleMode).SetAs(tp);
        txtA.DOText("This is a colored text and normal text", duration, true, scrambleMode).SetAs(tp);
    }
Пример #14
0
    private void StartMotion()
    {
        int loopCount = (_loop ? -1 : 0);

        TweenParams tweenParams = new TweenParams()
                                  .SetLoops(loopCount, LoopType.Yoyo)
                                  .SetEase(_easeType);

        _platformRigidBody.DOMove(_targetPosition.position, _duration).SetAs(tweenParams);
    }
Пример #15
0
 public void ApplyTo(TweenParams tweenParams)
 {
     if (UseCustomCurve)
     {
         tweenParams.SetEase(curve);
     }
     else
     {
         tweenParams.SetEase(ease);
     }
 }
Пример #16
0
    private static int SetEase(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(TweenParams), typeof(EaseFunction)))
            {
                TweenParams  tweenParams = (TweenParams)ToLua.ToObject(L, 1);
                LuaTypes     luaTypes    = LuaDLL.lua_type(L, 2);
                EaseFunction ease;
                if (luaTypes != LuaTypes.LUA_TFUNCTION)
                {
                    ease = (EaseFunction)ToLua.ToObject(L, 2);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    ease = (DelegateFactory.CreateDelegate(typeof(EaseFunction), func) as EaseFunction);
                }
                TweenParams o = tweenParams.SetEase(ease);
                ToLua.PushObject(L, o);
                result = 1;
            }
            else if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(TweenParams), typeof(AnimationCurve)))
            {
                TweenParams    tweenParams2 = (TweenParams)ToLua.ToObject(L, 1);
                AnimationCurve ease2        = (AnimationCurve)ToLua.ToObject(L, 2);
                TweenParams    o2           = tweenParams2.SetEase(ease2);
                ToLua.PushObject(L, o2);
                result = 1;
            }
            else if (num == 4 && TypeChecker.CheckTypes(L, 1, typeof(TweenParams), typeof(Ease), typeof(float?), typeof(float?)))
            {
                TweenParams tweenParams3         = (TweenParams)ToLua.ToObject(L, 1);
                Ease        ease3                = (Ease)((int)ToLua.ToObject(L, 2));
                float?      overshootOrAmplitude = (float?)ToLua.ToObject(L, 3);
                float?      period               = (float?)ToLua.ToObject(L, 4);
                TweenParams o3 = tweenParams3.SetEase(ease3, overshootOrAmplitude, period);
                ToLua.PushObject(L, o3);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.TweenParams.SetEase");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
        public void Show(Data _data, TweenCallback _callback = null)
        {
            AudioManager.I.PlaySfx(Sfx.UIPopup);

            MainLable.text = _data.MainTextToDisplay;
            // Preset for animation
            CompletedCheck.rectTransform.DOScale(6, 0);
            CompletedCheck.DOFade(0, 0);
            // Animation sequence
            sequence = DOTween.Sequence().SetUpdate(true);
            tParms   = new TweenParams()
                       .SetEase(Ease.InOutBack);
            timeScaleAtMenuOpen = Time.timeScale;
            Time.timeScale      = 0; // not working
            sequence.Append(GetComponent <RectTransform>().DOAnchorPos(ShowPosition, 0.3f).SetAs(tParms));
            TitleLable.text = _data.Title;
            // Complete check animation.
            if (_data.Type == PopupType.Mission_Completed)
            {
                AudioManager.I.PlaySfx(Sfx.StampOK);
                sequence.Insert(0.3f, CompletedCheck.DOFade(1, 0.1f));
                sequence.Append(CompletedCheck.rectTransform.DOScale(1, 0.3f).SetAs(tParms));
                //                    .OnComplete(delegate()
                //                    {
                //                        AudioManager.I.PlaySfx(Sfx.Win);
                //                    });
            }
            // Draw
            if (_data.DrawSprite)
            {
                Draw.gameObject.SetActive(true);
                Draw.sprite = _data.DrawSprite;
            }
            else
            {
                Draw.gameObject.SetActive(false);
            }
            // Autoclose
            if (_data.AutoCloseTime >= 0)
            {
                sequence.InsertCallback(_data.AutoCloseTime, delegate {
                    Close(sequence, tParms, _callback);
                });
            }
            else
            {
                pendingCallback = null; // reset
                if (_callback != null)
                {
                    pendingCallback = _callback;
                }
            }
        }
        protected override void absStart()
        {
            _currCanMoveNavMeshPath = new NavMeshPath();

            _tpLookAt   = new TweenParams().SetEase(Ease.Linear);
            _tpMovement = new TweenParams().SetEase(Ease.Linear).OnUpdate(this.tweenOnMovementUpdate).OnComplete(this.tweenOnMovementComplete);

            _ani = GetComponent <Animator>();
            _ani.applyRootMotion = false;
            _ani.SetBool(aniKeyOnGround, true);

            BMC.getObserverBehaviour().registerMsg(this);
        }
Пример #19
0
    public void Awake()
    {
        this.rectTransform = GetComponent <RectTransform>();

        // Cache default anim values
        this.titlePanelHeight = this.rectTransform.anchoredPosition.y;
        this.pivotY           = this.rectTransform.pivot.y;
        this.drawZoneY        = this.drawZone.transform.position.y;

        // Set anim settings
        this.slideAnimParams = new TweenParams().SetEase(Ease.InOutExpo);

        // Set sound button parent reference
        this.soundButton.ParentView = this;
    }
Пример #20
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(0.5f));

        TweenParams tp = new TweenParams()
                         .SetRelative()
                         // .SetSpeedBased()
                         .SetEase(Ease.OutQuint)
                         .SetLoops(-1, LoopType.Yoyo);

        foreach (Transform t in ts)
        {
            t.DOMoveY(2, 1).SetAs(tp);
        }
    }
Пример #21
0
    private static int Clear(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            TweenParams o           = tweenParams.Clear();
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #22
0
    // Use this for initialization
    void Start()
    {
        gmScript = GetComponent <GameMaster>();
        myPlayer = GameObject.Find("Player").GetComponent <PlayerShip>();

        //Tween stuff
        tweenParm = new TweenParams().SetLoops(1, LoopType.Yoyo).SetEase(Ease.Linear).SetAutoKill(false);

        //Formation
        if (vFormation == null)
        {
            vFormation = GetComponent <VFormation>();
        }
        if (pathFormation == null)
        {
            pathFormation = GetComponent <CustomPathFormation>();
        }
    }
Пример #23
0
    void startAnimation()
    {
        masterPieces = GameObject.FindGameObjectsWithTag("masterPiece");
        floor        = GameObject.Find("Floor");
        Sequence    startSequence = DOTween.Sequence();
        TweenParams tParams       = new TweenParams().SetEase(Ease.InOutQuad);

        for (int i = 0; i < masterPieces.Length; i++)
        {
            Vector3 initPos = masterPieces[i].transform.position;
            masterPieces[i].transform.position -= Vector3.up * 10f;
            masterPieces[i].transform.rotation  = Quaternion.Euler(0, -180, 0);
            startSequence.Insert(2 + i * 0.1f, masterPieces[i].transform.DOMoveY(initPos.y, 1).SetAs(tParams));
            startSequence.Insert(2 + i * 0.1f, masterPieces[i].transform.DORotate(new Vector3(0, 0, 0), 1).SetAs(tParams));
        }

        startSequence.Play();
    }
Пример #24
0
    private IEnumerator PlaySpiritAnimation()
    {
        Vector3 playerSpawnPos = PlayerCheckpoint.LastRegisteredCheckpointPosition;

        TweenParams tweenParams = new TweenParams()
                                  .SetEase(_particleEaseType);

        _spiritParticles.gameObject.SetActive(true);
        _spiritParticles.Play();

        _entirePlayerGameObject.transform.DOMove(playerSpawnPos, _particleAnimationDuration).SetAs(tweenParams).OnComplete(() => StartCoroutine(CleanupParticles()));


        if (moveBeforeScalingOnDeath)
        {
            yield return(new WaitForSeconds(0.6f));
        }

        while (_playerModel.transform.localScale.x > 0)
        {
            _playerModel.transform.localScale -= Vector3.one * (Time.deltaTime * 6);
            yield return(new WaitForEndOfFrame());
        }

        _playerModel.gameObject.SetActive(false);

        yield return(null);

// can fade player out if we use a transparent supported material

        //Material mat = _playerModel.material;

        /*
         * while (mat.color.a > 0)
         * {
         *  Color newColor = mat.color;
         *  newColor.a -= Time.deltaTime;
         *  mat.color = newColor;
         *  _playerModel.material = mat;
         *  yield return new WaitForEndOfFrame();
         * }
         */
    }
Пример #25
0
    private static int SetTarget(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            object      target      = ToLua.ToVarObject(L, 2);
            TweenParams o           = tweenParams.SetTarget(target);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #26
0
    private static int SetDelay(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            float       delay       = (float)LuaDLL.luaL_checknumber(L, 2);
            TweenParams o           = tweenParams.SetDelay(delay);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #27
0
    private static int SetAutoKill(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            bool        autoKill    = LuaDLL.luaL_checkboolean(L, 2);
            TweenParams o           = tweenParams.SetAutoKill(autoKill);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #28
0
        public static void Tint(
            EntityManager entityManager,
            Entity entity,
            float4 start,
            float4 end,
            float duration,
            EaseDesc easeDesc = default,
            bool isPingPong   = false,
            int loopCount     = 1,
            float startDelay  = 0.0f)
        {
            if (!CheckParams(easeDesc.Exponent, loopCount))
            {
                return;
            }

            TweenParams tweenParams = new TweenParams(duration, easeDesc.Type, easeDesc.Exponent, isPingPong, loopCount, startDelay);

            entityManager.AddComponentData(entity, new TweenTintCommand(tweenParams, start, end));
        }
Пример #29
0
        public static void Move(
            EntityCommandBuffer commandBuffer,
            Entity entity,
            float3 start,
            float3 end,
            float duration,
            EaseDesc easeDesc = default,
            bool isPingPong   = false,
            int loopCount     = 1,
            float startDelay  = 0.0f)
        {
            if (!CheckParams(easeDesc.Exponent, loopCount))
            {
                return;
            }

            TweenParams tweenParams = new TweenParams(duration, easeDesc.Type, easeDesc.Exponent, isPingPong, loopCount, startDelay);

            commandBuffer.AddComponent(entity, new TweenTranslationCommand(tweenParams, start, end));
        }
Пример #30
0
    private static int SetLoops(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 3);
            TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            int         loops       = (int)LuaDLL.luaL_checknumber(L, 2);
            LoopType?   loopType    = (LoopType?)ToLua.CheckVarObject(L, 3, typeof(LoopType?));
            TweenParams o           = tweenParams.SetLoops(loops, loopType);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Пример #31
0
        /** Utilizes a tween to animate the target object over a certain time. Internally, this
         *  method uses a tween instance (taken from an object pool) that is added to the
         *  juggler right away. This method provides a convenient alternative for creating
         *  and adding a tween manually.
         *
         *  <p>Fill 'properties' with key-value pairs that describe both the
         *  tween and the animation target. Here is an example:</p>
         *
         *  <pre>
         *  juggler.tween(object, 2.0, {
         *      transition: Transitions.EASE_IN_OUT,
         *      delay: 20, // -> tween.delay = 20
         *      x: 50      // -> tween.animate("x", 50)
         *  });
         *  </pre>
         */
        public void tween(object target, float time, TweenParams properties)
        {
            Tween tween = Tween.fromPool(target, time);

            foreach (var prop in properties)
            {
                if ( hasProperty(tween, prop.Key) )
                    SetValue(tween, prop.Key, prop.Value);
                else if ( hasProperty(target, prop.Key) )
                   	tween.animate(prop.Key, (float)prop.Value);
                else
                    throw new ArgumentError("Invalid property: " + prop.Key);
            }

            tween.addEventListener(starling.events.Event.REMOVE_FROM_JUGGLER, onPooledTweenComplete);
            add(tween);
        }