rotate() public static method

public static rotate ( GameObject gameObject, Vector3 to, float time ) : LTDescr,
gameObject GameObject
to Vector3
time float
return LTDescr,
 private void OnEnable()
 {
     transform.rotation = Quaternion.Euler(startRotation);
     LeanTween.rotate(gameObject, endRotation, animationDuration).setEase(LeanTweenType.easeInOutQuart);
 }
Beispiel #2
0
    void SetupTweens()
    {
        // Ease
        DG.Tweening.Ease           dotweenEase = easing == Easing.Linear ? DG.Tweening.Ease.Linear : DG.Tweening.Ease.InOutQuad;
        Holoville.HOTween.EaseType hotweenEase = easing == Easing.Linear ? Holoville.HOTween.EaseType.Linear : Holoville.HOTween.EaseType.EaseInOutQuad;
        LeanTweenType leanEase = easing == Easing.Linear ? LeanTweenType.linear : LeanTweenType.easeInOutQuad;
        GoEaseType    goEase   = easing == Easing.Linear ? GoEaseType.Linear : GoEaseType.QuadInOut;

        iTween.EaseType iTweenEase = easing == Easing.Linear ? iTween.EaseType.linear : iTween.EaseType.easeInOutQuad;
        // Loop
        int loops = testSetup == TestSetup.Emit ? 1 : -1;

        DG.Tweening.LoopType       dotweenLoopType = testSetup == TestSetup.YoyoLoop ? DG.Tweening.LoopType.Yoyo : DG.Tweening.LoopType.Restart;
        Holoville.HOTween.LoopType hotweenLoopType = testSetup == TestSetup.YoyoLoop ? Holoville.HOTween.LoopType.Yoyo : Holoville.HOTween.LoopType.Restart;
        LeanTweenType leanLoopType = testSetup == TestSetup.YoyoLoop ? LeanTweenType.pingPong : LeanTweenType.clamp;
        GoLoopType    goLoopType   = testSetup == TestSetup.YoyoLoop ? GoLoopType.PingPong : GoLoopType.RestartFromBeginning;

        iTween.LoopType iTweenLoopType = loops != -1 ? iTween.LoopType.none : testSetup == TestSetup.YoyoLoop ? iTween.LoopType.pingPong : iTween.LoopType.loop;
        // Create tweens
        switch (testType)
        {
        case TestType.Floats:
            for (int i = 0; i < numTweens; ++i)
            {
                TestObjectData data = testObjsData[i];
                switch (engine)
                {
                case Engine.HOTween:
                    HOTween.To(data, duration, new Holoville.HOTween.TweenParms()
                               .Prop("floatValue", rndFloats[i])
                               .Ease(hotweenEase)
                               .Loops(loops, hotweenLoopType)
                               );
                    break;

                case Engine.LeanTween:
                    LeanTween.value(this.gameObject, x => data.floatValue = x, data.floatValue, rndFloats[i], duration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                    break;

                case Engine.GoKit:
                    Go.to(data, duration, new GoTweenConfig()
                          .floatProp("floatValueProperty", rndFloats[i])
                          .setEaseType(goEase)
                          .setIterations(loops, goLoopType)
                          );
                    break;

                case Engine.iTween:
                    Hashtable hs = new Hashtable();
                    hs.Add("from", data.floatValue);
                    hs.Add("to", rndFloats[i]);
                    hs.Add("time", duration);
                    hs.Add("onupdate", "UpdateiTweenFloat");
                    hs.Add("looptype", iTweenLoopType);
                    hs.Add("easetype", iTweenEase);
                    iTween.ValueTo(this.gameObject, hs);
                    break;

                default:
                    // tCopy is needed to create correct closure object,
                    // otherwise closure will pass the same t to all the loop
                    TestObjectData dataCopy = data;
                    DOTween.To(() => dataCopy.floatValue, x => dataCopy.floatValue = x, rndFloats[i], duration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                    break;
                }
            }
            break;

        default:
            for (int i = 0; i < numTweens; ++i)
            {
                float      twDuration = testSetup == TestSetup.Emit ? UnityEngine.Random.Range(0.25f, 1f) : duration;
                Transform  t          = testObjsTrans[i];
                GameObject go         = testObjsGos[i];         // Used by LeanTween and iTween
                switch (engine)
                {
                case Engine.HOTween:
                    Holoville.HOTween.TweenParms tp = new Holoville.HOTween.TweenParms()
                                                      .Ease(hotweenEase)
                                                      .Loops(loops, hotweenLoopType);
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        tp.Prop("position", toPos);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenPositionFor(t, toPos, twDuration, hotweenEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        tp.Prop("rotation", toRot);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenRotationFor(t, toRot, twDuration, hotweenEase));
                        }
                    }
                    if (scaleTween)
                    {
                        tp.Prop("localScale", rndScale);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenScaleFor(t, rndScale, twDuration, hotweenEase));
                        }
                    }
                    HOTween.To(t, twDuration, tp);
                    break;

                case Engine.LeanTween:
                    LTDescr leanTween;
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        leanTween = LeanTween.move(go, rndPositions[i], twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenPositionFor(t, go, toPos, twDuration, leanEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        leanTween = LeanTween.rotate(go, rndRotations[i], twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenRotationFor(t, go, toRot, twDuration, leanEase));
                        }
                    }
                    if (scaleTween)
                    {
                        leanTween = LeanTween.scale(go, rndScale, twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenScaleFor(t, go, rndScale, twDuration, leanEase));
                        }
                    }
                    break;

                case Engine.GoKit:
                    GoTweenConfig goConfig = new GoTweenConfig()
                                             .setEaseType(goEase)
                                             .setIterations(loops, goLoopType);
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        goConfig.addTweenProperty(new PositionTweenProperty(toPos));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitPositionFor(t, toPos, twDuration, goEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        goConfig.addTweenProperty(new RotationTweenProperty(toRot));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitRotationFor(t, toRot, twDuration, goEase));
                        }
                    }
                    if (scaleTween)
                    {
                        goConfig.addTweenProperty(new ScaleTweenProperty(rndScale));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitScaleFor(t, rndScale, twDuration, goEase));
                        }
                    }
                    Go.to(t, twDuration, goConfig);
                    break;

                case Engine.iTween:
                    Hashtable hs;
                    if (positionTween)
                    {
                        hs = new Hashtable();
                        hs.Add("position", rndPositions[i]);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.MoveTo(go, hs);
                    }
                    if (rotationTween)
                    {
                        hs = new Hashtable();
                        hs.Add("rotation", rndRotations[i]);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.RotateTo(go, hs);
                    }
                    if (scaleTween)
                    {
                        hs = new Hashtable();
                        hs.Add("scale", rndScale);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.ScaleTo(go, hs);
                    }
                    break;

                default:
                    // tCopy is needed to create correct closure object,
                    // otherwise closure will pass the same t to all the loop
                    Transform         tCopy = t;
                    DG.Tweening.Tween dotween;
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        dotween = tCopy.DOMove(toPos, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenPositionFor(t, toPos, twDuration, dotweenEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        dotween = tCopy.DORotate(toRot, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenRotationFor(t, toRot, twDuration, dotweenEase));
                        }
                    }
                    if (scaleTween)
                    {
                        dotween = tCopy.DOScale(rndScale, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenScaleFor(t, rndScale, twDuration, dotweenEase));
                        }
                    }
                    break;
                }
            }
            break;
        }
    }
        void Start()
        {
//			Time.timeScale = 0.25f;

            LeanTest.timeout  = 46f;
            LeanTest.expected = 51;

            LeanTween.init(15 + 1200);
            // add a listener
            LeanTween.addListener(cube1, 0, eventGameObjectCalled);

            LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

            LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
                LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
            });

            // dispatch event that is received
            LeanTween.dispatchEvent(0);
            LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

            // do not remove listener
            LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
            // remove listener
            LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

            // add a listener
            LeanTween.addListener(1, eventGeneralCalled);

            // dispatch event that is received
            LeanTween.dispatchEvent(1);
            LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

            // remove listener
            LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

            lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
            LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

            LeanTween.reset();

            Vector3[] splineArr = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) };
            LTSpline  cr        = new LTSpline(splineArr);

            cr.place(cube4.transform, 0.5f);
            LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
            LeanTween.color(cube4, Color.green, 0.01f);

//			Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2]));

            // OnStart Speed Test for ignoreTimeScale vs normal timeScale

            GameObject cubeDest    = cubeNamed("cubeDest");
            Vector3    cubeDestEnd = new Vector3(100f, 20f, 0f);

            LeanTween.move(cubeDest, cubeDestEnd, 0.7f);

            GameObject cubeToTrans = cubeNamed("cubeToTrans");

            LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
                LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
            });

            GameObject cubeDestroy = cubeNamed("cubeDestroy");

            LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
            LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
                LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
            });

            GameObject cubeSpline = cubeNamed("cubeSpline");

            LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
            });

            // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
            GameObject jumpCube = cubeNamed("jumpTime");

            jumpCube.transform.position    = new Vector3(100f, 0f, 0f);
            jumpCube.transform.localScale *= 100f;
            int jumpTimeId = LeanTween.moveX(jumpCube, 200f, 1f).id;

            LeanTween.delayedCall(gameObject, 0.2f, () => {
                LTDescr d     = LeanTween.descr(jumpTimeId);
                float beforeX = jumpCube.transform.position.x;
                d.setTime(0.5f);
                LeanTween.delayedCall(0.0f, () => { }).setOnStart(() => {
                    float diffAmt = 1f;                    // This variable is dependent on a good frame-rate because it evalutes at the next Update
                    beforeX      += Time.deltaTime * 100f * 2f;
                    LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < diffAmt, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX) + " beforeX:" + beforeX + " now:" + jumpCube.transform.position.x + " dt:" + Time.deltaTime);
                });
            });

            // Tween with time of zero is needs to be set to it's final value
            GameObject zeroCube = cubeNamed("zeroCube");

            LeanTween.moveX(zeroCube, 10f, 0f).setOnComplete(() => {
                LeanTest.expect(zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:" + zeroCube.transform.position.x);
            });

            // Scale, and OnStart
            GameObject cubeScale = cubeNamed("cubeScale");

            LeanTween.scale(cubeScale, new Vector3(5f, 5f, 5f), 0.01f).setOnStart(() => {
                LeanTest.expect(true, "ON START WAS CALLED");
            }).setOnComplete(() => {
                LeanTest.expect(cubeScale.transform.localScale.z == 5f, "SCALE", "expected scale z:" + 5f + " returned:" + cubeScale.transform.localScale.z);
            });

            // Rotate
            GameObject cubeRotate = cubeNamed("cubeRotate");

            LeanTween.rotate(cubeRotate, new Vector3(0f, 180f, 0f), 0.02f).setOnComplete(() => {
                LeanTest.expect(cubeRotate.transform.eulerAngles.y == 180f, "ROTATE", "expected rotate y:" + 180f + " returned:" + cubeRotate.transform.eulerAngles.y);
            });

            // RotateAround
            GameObject cubeRotateA = cubeNamed("cubeRotateA");

            LeanTween.rotateAround(cubeRotateA, Vector3.forward, 90f, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeRotateA.transform.eulerAngles.z == 90f, "ROTATE AROUND", "expected rotate z:" + 90f + " returned:" + cubeRotateA.transform.eulerAngles.z);
            });

            // RotateAround 360
            GameObject cubeRotateB = cubeNamed("cubeRotateB");

            cubeRotateB.transform.position = new Vector3(200f, 10f, 8f);
            LeanTween.rotateAround(cubeRotateB, Vector3.forward, 360f, 0.3f).setPoint(new Vector3(5f, 3f, 2f)).setOnComplete(() => {
                LeanTest.expect(cubeRotateB.transform.position == new Vector3(200f, 10f, 8f), "ROTATE AROUND 360", "expected rotate pos:" + (new Vector3(200f, 10f, 8f)) + " returned:" + cubeRotateB.transform.position);
            });

            // Alpha, onUpdate with passing value, onComplete value
            LeanTween.alpha(cubeAlpha1, 0.5f, 0.1f).setOnUpdate((float val) => {
                LeanTest.expect(val != 0f, "ON UPDATE VAL");
            }).setOnCompleteParam("Hi!").setOnComplete((object completeObj) => {
                LeanTest.expect(((string)completeObj) == "Hi!", "ONCOMPLETE OBJECT");
                LeanTest.expect(cubeAlpha1.GetComponent <Renderer>().material.color.a == 0.5f, "ALPHA");
            });
            // Color
            float onStartTime = -1f;

            LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.GetComponent <Renderer>().material.color == Color.cyan, "COLOR");
                LeanTest.expect(onStartTime >= 0f && onStartTime < Time.time, "ON START", "onStartTime:" + onStartTime + " time:" + Time.time);
            }).setOnStart(() => {
                onStartTime = Time.time;
            });
            // moveLocalY (make sure uses y values)
            Vector3 beforePos = cubeAlpha1.transform.position;

            LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha1.transform.position.x == beforePos.x && cubeAlpha1.transform.position.z == beforePos.z, "MOVE Y");
            });

            Vector3 beforePos2 = cubeAlpha2.transform.localPosition;

            LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.transform.localPosition.x == beforePos2.x && cubeAlpha2.transform.localPosition.y == beforePos2.y, "MOVE LOCAL Z", "ax:" + cubeAlpha2.transform.localPosition.x + " bx:" + beforePos.x + " ay:" + cubeAlpha2.transform.localPosition.y + " by:" + beforePos2.y);
            });

            AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve(new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve(new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options());

            LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f, 0f, 0f), 0.1f).setDelay(0.2f).setOnComplete(() => {
                LeanTest.expect(Time.time > 0, "DELAYED SOUND");
            });

            StartCoroutine(timeBasedTesting());
        }
Beispiel #4
0
 public void Open()
 {
     LeanTween.rotate(door, openRot, 1f).setEaseInSine();
 }
Beispiel #5
0
        void Start()
        {
            //          Time.timeScale = 0.25f;

            LeanTest.timeout  = 46f;
            LeanTest.expected = 62;

            LeanTween.init(1300);

            // add a listener
            LeanTween.addListener(cube1, 0, eventGameObjectCalled);

            LeanTest.expect(LeanTween.isTweening() == false, "NOTHING TWEEENING AT BEGINNING");

            LeanTest.expect(LeanTween.isTweening(cube1) == false, "OBJECT NOT TWEEENING AT BEGINNING");

            LeanTween.scaleX(cube4, 2f, 0f).setOnComplete(() => {
                LeanTest.expect(cube4.transform.localScale.x == 2f, "TWEENED WITH ZERO TIME");
            });

            // dispatch event that is received
            LeanTween.dispatchEvent(0);
            LeanTest.expect(eventGameObjectWasCalled, "EVENT GAMEOBJECT RECEIVED");

            // do not remove listener
            LeanTest.expect(LeanTween.removeListener(cube2, 0, eventGameObjectCalled) == false, "EVENT GAMEOBJECT NOT REMOVED");
            // remove listener
            LeanTest.expect(LeanTween.removeListener(cube1, 0, eventGameObjectCalled), "EVENT GAMEOBJECT REMOVED");

            // add a listener
            LeanTween.addListener(1, eventGeneralCalled);

            // dispatch event that is received
            LeanTween.dispatchEvent(1);
            LeanTest.expect(eventGeneralWasCalled, "EVENT ALL RECEIVED");

            // remove listener
            LeanTest.expect(LeanTween.removeListener(1, eventGeneralCalled), "EVENT ALL REMOVED");

            lt1Id = LeanTween.move(cube1, new Vector3(3f, 2f, 0.5f), 1.1f).id;
            LeanTween.move(cube2, new Vector3(-3f, -2f, -0.5f), 1.1f);

            LeanTween.reset();

            // Queue up a bunch of tweens, cancel some of them but expect the remainder to finish
            GameObject[] cubes    = new GameObject[99];
            int[]        tweenIds = new int[cubes.Length];
            for (int i = 0; i < cubes.Length; i++)
            {
                GameObject c = cubeNamed("cancel" + i);
                tweenIds[i] = LeanTween.moveX(c, 100f, 1f).id;
                cubes[i]    = c;
            }
            int onCompleteCount = 0;

            LeanTween.delayedCall(cubes[0], 0.2f, () => {
                for (int i = 0; i < cubes.Length; i++)
                {
                    if (i % 3 == 0)
                    {
                        LeanTween.cancel(cubes[i]);
                    }
                    else if (i % 3 == 1)
                    {
                        LeanTween.cancel(tweenIds[i]);
                    }
                    else if (i % 3 == 2)
                    {
                        LTDescr descr = LeanTween.descr(tweenIds[i]);
                        //                      Debug.Log("descr:"+descr);
                        descr.setOnComplete(() => {
                            onCompleteCount++;
                            //                          Debug.Log("onCompleteCount:"+onCompleteCount);
                            if (onCompleteCount >= 33)
                            {
                                LeanTest.expect(true, "CANCELS DO NOT EFFECT FINISHING");
                            }
                        });
                    }
                }
            });

            Vector3[] splineArr = new Vector3[] { new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(4f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector3(30f, 0f, 0f) };
            LTSpline  cr        = new LTSpline(splineArr);

            cr.place(cube4.transform, 0.5f);
            LeanTest.expect((Vector3.Distance(cube4.transform.position, new Vector3(10f, 0f, 0f)) <= 0.7f), "SPLINE POSITIONING AT HALFWAY", "position is:" + cube4.transform.position + " but should be:(10f,0f,0f)");
            LeanTween.color(cube4, Color.green, 0.01f);

            //          Debug.Log("Point 2:"+cr.ratioAtPoint(splineArr[2]));

            // OnStart Speed Test for ignoreTimeScale vs normal timeScale

            GameObject cubeDest    = cubeNamed("cubeDest");
            Vector3    cubeDestEnd = new Vector3(100f, 20f, 0f);

            LeanTween.move(cubeDest, cubeDestEnd, 0.7f);

            GameObject cubeToTrans = cubeNamed("cubeToTrans");

            LeanTween.move(cubeToTrans, cubeDest.transform, 1.2f).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => {
                LeanTest.expect(cubeToTrans.transform.position == cubeDestEnd, "MOVE TO TRANSFORM WORKS");
            });

            GameObject cubeDestroy = cubeNamed("cubeDestroy");

            LeanTween.moveX(cubeDestroy, 200f, 0.05f).setDelay(0.02f).setDestroyOnComplete(true);
            LeanTween.moveX(cubeDestroy, 200f, 0.1f).setDestroyOnComplete(true).setOnComplete(() => {
                LeanTest.expect(true, "TWO DESTROY ON COMPLETE'S SUCCEED");
            });

            GameObject cubeSpline = cubeNamed("cubeSpline");

            LeanTween.moveSpline(cubeSpline, new Vector3[] { new Vector3(0.5f, 0f, 0.5f), new Vector3(0.75f, 0f, 0.75f), new Vector3(1f, 0f, 1f), new Vector3(1f, 0f, 1f) }, 0.1f).setOnComplete(() => {
                LeanTest.expect(Vector3.Distance(new Vector3(1f, 0f, 1f), cubeSpline.transform.position) < 0.01f, "SPLINE WITH TWO POINTS SUCCEEDS");
            });

            // This test works when it is positioned last in the test queue (probably worth fixing when you have time)
            GameObject jumpCube = cubeNamed("jumpTime");

            jumpCube.transform.position    = new Vector3(100f, 0f, 0f);
            jumpCube.transform.localScale *= 100f;
            int jumpTimeId = LeanTween.moveX(jumpCube, 200f, 1f).id;

            LeanTween.delayedCall(gameObject, 0.2f, () => {
                LTDescr d     = LeanTween.descr(jumpTimeId);
                float beforeX = jumpCube.transform.position.x;
                d.setTime(0.5f);
                LeanTween.delayedCall(0.0f, () => { }).setOnStart(() => {
                    float diffAmt = 1f;// This variable is dependent on a good frame-rate because it evalutes at the next Update
                    beforeX      += Time.deltaTime * 100f * 2f;
                    LeanTest.expect(Mathf.Abs(jumpCube.transform.position.x - beforeX) < diffAmt, "CHANGING TIME DOESN'T JUMP AHEAD", "Difference:" + Mathf.Abs(jumpCube.transform.position.x - beforeX) + " beforeX:" + beforeX + " now:" + jumpCube.transform.position.x + " dt:" + Time.deltaTime);
                });
            });

            // Tween with time of zero is needs to be set to it's final value
            GameObject zeroCube = cubeNamed("zeroCube");

            LeanTween.moveX(zeroCube, 10f, 0f).setOnComplete(() => {
                LeanTest.expect(zeroCube.transform.position.x == 10f, "ZERO TIME FINSHES CORRECTLY", "final x:" + zeroCube.transform.position.x);
            });

            // Scale, and OnStart
            GameObject cubeScale = cubeNamed("cubeScale");

            LeanTween.scale(cubeScale, new Vector3(5f, 5f, 5f), 0.01f).setOnStart(() => {
                LeanTest.expect(true, "ON START WAS CALLED");
            }).setOnComplete(() => {
                LeanTest.expect(cubeScale.transform.localScale.z == 5f, "SCALE", "expected scale z:" + 5f + " returned:" + cubeScale.transform.localScale.z);
            });

            // Rotate
            GameObject cubeRotate = cubeNamed("cubeRotate");

            LeanTween.rotate(cubeRotate, new Vector3(0f, 180f, 0f), 0.02f).setOnComplete(() => {
                LeanTest.expect(cubeRotate.transform.eulerAngles.y == 180f, "ROTATE", "expected rotate y:" + 180f + " returned:" + cubeRotate.transform.eulerAngles.y);
            });

            // RotateAround
            GameObject cubeRotateA = cubeNamed("cubeRotateA");

            LeanTween.rotateAround(cubeRotateA, Vector3.forward, 90f, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeRotateA.transform.eulerAngles.z == 90f, "ROTATE AROUND", "expected rotate z:" + 90f + " returned:" + cubeRotateA.transform.eulerAngles.z);
            });

            // RotateAround 360
            GameObject cubeRotateB = cubeNamed("cubeRotateB");

            cubeRotateB.transform.position = new Vector3(200f, 10f, 8f);
            LeanTween.rotateAround(cubeRotateB, Vector3.forward, 360f, 0.3f).setPoint(new Vector3(5f, 3f, 2f)).setOnComplete(() => {
                LeanTest.expect(cubeRotateB.transform.position.ToString() == (new Vector3(200f, 10f, 8f)).ToString(), "ROTATE AROUND 360", "expected rotate pos:" + (new Vector3(200f, 10f, 8f)) + " returned:" + cubeRotateB.transform.position);
            });

            // Alpha, onUpdate with passing value, onComplete value
            LeanTween.alpha(cubeAlpha1, 0.5f, 0.1f).setOnUpdate((float val) => {
                LeanTest.expect(val != 0f, "ON UPDATE VAL");
            }).setOnCompleteParam("Hi!").setOnComplete((object completeObj) => {
                LeanTest.expect(((string)completeObj) == "Hi!", "ONCOMPLETE OBJECT");
                LeanTest.expect(cubeAlpha1.GetComponent <Renderer>().material.color.a == 0.5f, "ALPHA");
            });
            // Color
            float onStartTime = -1f;

            LeanTween.color(cubeAlpha2, Color.cyan, 0.3f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.GetComponent <Renderer>().material.color == Color.cyan, "COLOR");
                LeanTest.expect(onStartTime >= 0f && onStartTime < Time.time, "ON START", "onStartTime:" + onStartTime + " time:" + Time.time);
            }).setOnStart(() => {
                onStartTime = Time.time;
            });
            // moveLocalY (make sure uses y values)
            Vector3 beforePos = cubeAlpha1.transform.position;

            LeanTween.moveY(cubeAlpha1, 3f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha1.transform.position.x == beforePos.x && cubeAlpha1.transform.position.z == beforePos.z, "MOVE Y");
            });

            Vector3 beforePos2 = cubeAlpha2.transform.localPosition;

            LeanTween.moveLocalZ(cubeAlpha2, 12f, 0.2f).setOnComplete(() => {
                LeanTest.expect(cubeAlpha2.transform.localPosition.x == beforePos2.x && cubeAlpha2.transform.localPosition.y == beforePos2.y, "MOVE LOCAL Z", "ax:" + cubeAlpha2.transform.localPosition.x + " bx:" + beforePos.x + " ay:" + cubeAlpha2.transform.localPosition.y + " by:" + beforePos2.y);
            });

            AudioClip audioClip = LeanAudio.createAudio(new AnimationCurve(new Keyframe(0f, 1f, 0f, -1f), new Keyframe(1f, 0f, -1f, 0f)), new AnimationCurve(new Keyframe(0f, 0.001f, 0f, 0f), new Keyframe(1f, 0.001f, 0f, 0f)), LeanAudio.options());

            LeanTween.delayedSound(gameObject, audioClip, new Vector3(0f, 0f, 0f), 0.1f).setDelay(0.2f).setOnComplete(() => {
                LeanTest.expect(Time.time > 0, "DELAYED SOUND");
            });

            // Easing Methods
            int totalEasingCheck        = 0;
            int totalEasingCheckSuccess = 0;

            for (int j = 0; j < 2; j++)
            {
                bool isCheckingFrom       = j == 1;
                int  totalTweenTypeLength = (int)LeanTweenType.easeShake;
                for (int i = (int)LeanTweenType.notUsed; i < totalTweenTypeLength; i++)
                {
                    LeanTweenType easeType = (LeanTweenType)i;
                    GameObject    cube     = cubeNamed("cube" + easeType);
                    LTDescr       descr    = LeanTween.moveLocalX(cube, 5, 0.1f).setOnComplete((object obj) => {
                        GameObject cubeIn = obj as GameObject;
                        totalEasingCheck++;
                        if (cubeIn.transform.position.x == 5f)
                        {
                            totalEasingCheckSuccess++;
                        }
                        if (totalEasingCheck == (2 * totalTweenTypeLength))
                        {
                            LeanTest.expect(totalEasingCheck == totalEasingCheckSuccess, "EASING TYPES");
                        }
                    }).setOnCompleteParam(cube);

                    if (isCheckingFrom)
                    {
                        descr.setFrom(-5f);
                    }
                }
            }

            // value2
            bool value2UpdateCalled = false;

            LeanTween.value(gameObject, new Vector2(0, 0), new Vector2(256, 96), 0.1f).setOnUpdate((Vector2 value) => {
                value2UpdateCalled = true;
            });
            LeanTween.delayedCall(0.2f, () => {
                LeanTest.expect(value2UpdateCalled, "VALUE2 UPDATE");
            });

            // check descr
            //          LTDescr descr2 = LeanTween.descr( descrId );
            //          LeanTest.expect(descr2 == null,"DESCRIPTION STARTS AS NULL");

            StartCoroutine(timeBasedTesting());
        }
Beispiel #6
0
    // 转页,isNextPage==true则翻至下一页,否则翻至上一页
    public void TurnPage(bool isNextPage, int difference)
    {
        // int length = imageObjects.ToArray().Length;
        int         total_page_num = (int)Math.Ceiling(length / (float)countPerPage);
        IEnumerator e;

        // Vector3 currentRatation = go.itemHolder.transform.localRotation.eulerAngles;
        if (isNextPage)
        { //翻至下一页
            if (currPageNumber + 1 < total_page_num)
            {
                currPageNumber++;
                currPageNumber += difference;
                // preload Backpack Items
                e = GetBackpackEnumerator(currPageNumber * countPerPage, countPerPage);
                int i;
                if (currPageNumber % 2 == 1)
                {
                    i = countPerPage;
                }
                else
                {
                    i = 0;
                }
                while (e.MoveNext())
                {
                    GameObject currObj = (GameObject)e.Current;
                    if (currObj != null)
                    {
                        RectTransform item_transform = currObj.GetComponent <RectTransform>();
                        GameObject    locationObj    = go.itemPositionHolder.transform.GetChild(i).gameObject;
                        item_transform.anchoredPosition = locationObj.GetComponent <RectTransform>().anchoredPosition;
                        item_transform.localRotation    = locationObj.GetComponent <RectTransform>().localRotation;
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (currPageNumber % 2 == 1)
                {
                    LeanTween.rotate(go.itemHolder, new Vector3(0, 0, -180), 0.5f);
                }
                else
                {
                    LeanTween.rotate(go.itemHolder, new Vector3(0, 0, 0), 0.5f);
                }

                // Hide Backpack Items in the previous page
                if (currPageNumber > 0)
                {
                    e = GetBackpackEnumerator((currPageNumber - 1 - difference) * countPerPage, countPerPage);
                    while (e.MoveNext())
                    {
                        GameObject currObj = (GameObject)e.Current;
                        if (currObj != null)
                        {
                            RectTransform item_transform = currObj.GetComponent <RectTransform>();
                            GameObject    locationObj    = go.extraItemHolder;
                            item_transform.anchoredPosition = locationObj.GetComponent <RectTransform>().anchoredPosition;
                            item_transform.localRotation    = locationObj.GetComponent <RectTransform>().localRotation;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
        else
        { //翻至上一页
            if (currPageNumber > 0)
            {
                currPageNumber--;
                currPageNumber -= difference;
                // preload Backpack Items
                e = imageObjects.GetEnumerator(currPageNumber * countPerPage, countPerPage);
                int i;
                if (currPageNumber % 2 == 1)
                {
                    i = countPerPage;
                }
                else
                {
                    i = 0;
                }
                while (e.MoveNext())
                {
                    GameObject currObj = (GameObject)e.Current;
                    if (currObj != null)
                    {
                        RectTransform item_transform = currObj.GetComponent <RectTransform>();
                        GameObject    locationObj    = go.itemPositionHolder.transform.GetChild(i).gameObject;
                        item_transform.anchoredPosition = locationObj.GetComponent <RectTransform>().anchoredPosition;
                        item_transform.localRotation    = locationObj.GetComponent <RectTransform>().localRotation;
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (currPageNumber % 2 == 1)
                {
                    LeanTween.rotate(go.itemHolder, new Vector3(0, 0, 181), 0.5f);
                }
                else
                {
                    LeanTween.rotate(go.itemHolder, new Vector3(0, 0, 361), 0.5f);
                }

                // Hide Backpack Items in the next page
                if (currPageNumber + 1 < total_page_num)
                {
                    e = GetBackpackEnumerator((currPageNumber + difference) * countPerPage + countPerPage, countPerPage);
                    while (e.MoveNext())
                    {
                        GameObject currObj = (GameObject)e.Current;
                        if (currObj != null)
                        {
                            RectTransform item_transform = currObj.GetComponent <RectTransform>();
                            GameObject    locationObj    = go.extraItemHolder;
                            item_transform.anchoredPosition = locationObj.GetComponent <RectTransform>().anchoredPosition;
                            item_transform.localRotation    = locationObj.GetComponent <RectTransform>().localRotation;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
    }
Beispiel #7
0
 public static LTDescr LeanRotate(this Transform transform, Vector3 to, float time)
 {
     return(LeanTween.rotate(transform.gameObject, to, time));
 }
Beispiel #8
0
    IEnumerator Start()
    {
        VuforiaRuntime.Instance.InitVuforia();

        logoCanvas = logoRect.GetComponent <CanvasGroup>();

        canvasGroup = GetComponent <CanvasGroup>();

        elementsBg = elementsBgParent.GetComponentsInChildren <RectTransform>();


        foreach (var item in logoTop)
        {
            item.localScale = Vector3.zero;
        }

        foreach (var item in logoCenter)
        {
            item.localScale = Vector3.zero;
        }

        foreach (var item in logoBottom)
        {
            item.localScale = Vector3.zero;
        }

        logoRect.anchoredPosition = Vector2.zero;

        //Anima os objetos de fundo
        foreach (var item in elementsBg)
        {
            if (item.Equals(elementsBgParent))
            {
                continue;
            }

            LeanTween.rotate(item.gameObject, item.eulerAngles + new Vector3(0, 0, 15), 1.2f).setEase(LeanTweenType.easeInOutSine).setLoopPingPong();
        }

        //Aguarda a confirmação do aviso RA
        while (!AvisoRa.Confirmed)
        {
            yield return(new WaitForEndOfFrame());
        }

        while (!CamPermission())
        {
            yield return(new WaitForSeconds(1));
        }

        loopAudioSource.Play();

        StartCoroutine(AnimLogo());

        while (!animLogoRoutineFinished)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ActivatePlayScreen();
                StopAllCoroutines();
            }
            yield return(null);
        }

        yield return(new WaitForSeconds(2));

        LeanTween.move(logoRect, new Vector2(0, 343.85f), 0.3f);

        yield return(new WaitForSeconds(1));

        PlayScreen.SetActive(true);

        yield return(new WaitForSeconds(1));

        canvasGroup.alpha = 0;

        yield return(null);
    }
Beispiel #9
0
 public void Tween()
 {
     LeanTween.rotate(gameObject, target, 1).setEaseInQuad();
 }
Beispiel #10
0
        ////////////////////////////////////////////////////////////////////////
        // Static Methods


        public static void AnimateData(BridgeObject bridgeObject, JArray dataArray)
        {
            GameObject go = bridgeObject.gameObject;

            if (leanTweenBridge == null)
            {
                Debug.LogError("LeanTweenBridge: AnimateData: no leanTweenBridge has been created.");
                return;
            }

            foreach (JObject data in dataArray)
            {
                LTDescr    result = null;
                GameObject target = go;

                float time = 1.0f;
                if (data.ContainsKey("time"))
                {
                    time = data.GetFloat("time");
                    if (time <= 0.0f)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: time must be > 0. data: " + data);
                        return;
                    }
                }

                if (data.ContainsKey("target"))
                {
                    string targetPath = data.GetString("target");

                    if (targetPath == "")
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: empty targetPath");
                        return;
                    }

                    Accessor accessor = null;
                    if (!Accessor.FindAccessor(
                            bridgeObject,
                            targetPath,
                            ref accessor))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: target: can't find accessor for targetPath: " + targetPath);
                        return;
                    }

                    object obj = null;
                    if (!accessor.Get(ref obj))
                    {
                        if (!accessor.conditional)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: target: can't get accessor: " + accessor + " targetPath: " + targetPath);
                            return;
                        }
                    }

                    GameObject goTarget = obj as GameObject;
                    if (goTarget == null)
                    {
                        Transform xform = obj as Transform;
                        if (xform != null)
                        {
                            goTarget = xform.gameObject;
                        }
                        else
                        {
                            Component component = obj as Component;
                            if (component != null)
                            {
                                goTarget = component.gameObject;
                            }
                        }
                    }

                    if (goTarget == null)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: null targetPath: " + targetPath + " obj: " + obj);
                        return;
                    }

                    //Debug.Log("LeanTweenBridge: AnimateData: targetPath: " + targetPath + " goTarget: " + goTarget);
                    target = goTarget;
                }

                var command = (string)data.GetString("command");
                if (string.IsNullOrEmpty(command))
                {
                    Debug.LogError("LeanTweenBridge: AnimateData: missing command from data: " + data);
                    return;
                }

                switch (command)
                {
                case "init":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "play":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancel":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancelAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pause":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pauseAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resume":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resumeAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "sequence":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "value":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "move":
                case "moveLocal":
                case "moveSpline":
                case "moveSplineLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (data.ContainsKey("position"))
                    {
                        Vector3 position = Vector3.zero;
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(data["position"], ref position))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: position must be a Vector3. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, position, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, position, time);
                            break;

                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: position not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("transform"))
                    {
                        Transform xform = null;

                        string path = data.GetString("transform");

                        Accessor accessor = null;
                        if (!Accessor.FindAccessor(
                                bridgeObject,
                                path,
                                ref accessor))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: transform must be a path. path: " + path + " data: " + data);
                            return;
                        }
                        object val = null;
                        if (!accessor.Get(ref val) ||
                            (val == null))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error getting path to transform. path: " + path + " data: " + data);
                            return;
                        }

                        xform = val as Transform;

                        if (xform == null)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path does not point to transform. path: " + path + " data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, xform, time);
                            break;

                        case "moveLocal":
                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: transform not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("path"))
                    {
                        Vector3[] path = null;
                        if (!Bridge.mainBridge.ConvertToType <Vector3[]>(data["path"], ref path))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path must be an Vector3[]. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, path, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, path, time);
                            break;

                        case "moveSpline":
                            result = LeanTween.moveSpline(target, path, time);
                            break;

                        case "moveSplineLocal":
                            result = LeanTween.moveSplineLocal(target, path, time);
                            break;
                        }
                    }
                    else if (data.ContainsKey("spline"))
                    {
                        LTSpline spline = null;
                        if (!Bridge.mainBridge.ConvertToType <LTSpline>(data["spline"], ref spline))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: spline must be a LTSpline. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "moveSpline":
                            result = LeanTween.moveSpline(target, spline, time);
                            break;

                        case "move":
                        case "moveLocal":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: spline not supported for " + command + ". data: " + data);
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: command: " + command + " should contain position, transform, path or spline. data: " + data);
                        return;
                    }

                    break;

                case "moveX":
                case "moveY":
                case "moveZ":

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to parameter. data: " + data);
                        return;
                    }

                    float moveTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "moveX":
                        result = LeanTween.moveX(target, moveTo, time);
                        break;

                    case "moveY":
                        result = LeanTween.moveY(target, moveTo, time);
                        break;

                    case "moveZ":
                        result = LeanTween.moveZ(target, moveTo, time);
                        break;
                    }

                    break;

                case "rotate":
                case "rotateLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateTo = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["to"], ref rotateTo))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    switch (command)
                    {
                    case "rotate":
                        result = LeanTween.rotate(target, rotateTo, time);
                        break;

                    case "rotateLocal":
                        result = LeanTween.rotateLocal(target, rotateTo, time);
                        break;
                    }

                    break;

                case "rotateX":
                case "rotateY":
                case "rotateZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float rotateToValue = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateX":
                        result = LeanTween.rotateX(target, rotateToValue, time);
                        break;

                    case "rotateY":
                        result = LeanTween.rotateY(target, rotateToValue, time);
                        break;

                    case "rotateZ":
                        result = LeanTween.rotateZ(target, rotateToValue, time);
                        break;
                    }

                    break;

                case "rotateAround":
                case "rotateAroundLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("axis"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing axis. data: " + data);
                        return;
                    }

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateAroundAxis = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["axis"], ref rotateAroundAxis))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    float rotateAroundTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateAround":
                        result = LeanTween.rotateAround(target, rotateAroundAxis, rotateAroundTo, time);
                        break;

                    case "rotateLocalLocal":
                        result = LeanTween.rotateAroundLocal(target, rotateAroundAxis, rotateAroundTo, time);
                        break;
                    }

                    break;

                case "scale":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 to      = Vector3.one;
                    JToken  toToken = data["to"];
                    if (toToken.IsNumber())
                    {
                        float s = (float)toToken;
                        to = new Vector3(s, s, s);
                    }
                    else if (toToken.IsObject())
                    {
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(toToken, ref to))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error converting to object to Vector3. data: " + data);
                            return;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to should be number or object. toToken: " + toToken + " " + toToken.Type + " data: " + data);
                        return;
                    }

                    result = LeanTween.scale(target, to, time);

                    break;

                case "scaleX":
                case "scaleY":
                case "scaleZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float scaleTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "scaleX":
                        result = LeanTween.scaleX(target, scaleTo, time);
                        break;

                    case "scaleY":
                        result = LeanTween.scaleY(target, scaleTo, time);
                        break;

                    case "scaleZ":
                        result = LeanTween.scaleZ(target, scaleTo, time);
                        break;
                    }

                    break;

                case "size":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    // TODO: handle RectTransform but not GameObject
                    break;

                case "alpha":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "color":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "colorText":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                default:
                    Debug.LogError("LeanTweenBridge: AnimateData: unknown command: " + command + " in data: " + data);
                    return;
                }

                if (result != null)
                {
/*
 *              pause
 *              resume
 *              axis
 *              delay
 *              direction
 *              ease
 *              from
 *              ignoreTimeScale
 *              loopClamp
 *              loopOnce
 *              loopPingPong
 *              onComplete
 *              onCompleteOnRepeat
 *              onCompleteOnStart
 *              onCompleteParam
 *              onStart
 *              onUpdate
 *              onUpdateParam
 *              orientToPath
 *              orientToPath2d
 *              overshoot
 *              passed
 *              period
 *              point
 *              recursive
 *              repeat
 *              scale
 *              speed
 *              time
 *              to
 *              useFrames
 *              updateNow
 */
                }
            }
        }
 protected void RotationUpdate(Vector3 rotationTo)
 {
     LeanTween.cancel(id);
     id = LeanTween.rotate(gameObject, rotationTo, timePerforme).setEase(_LeanTweenType).id;
 }
Beispiel #12
0
 public override void Execute()
 {
     owner.navMeshAgent.enabled = false;
     LeanTween.rotate(owner.gameObject, target, time).setEase(LeanTweenType.easeInCubic).setOnComplete(AnimationCompleteCallback);
 }
Beispiel #13
0
 public void cameraTweener()
 {
     LeanTween.move(gameObject, to, 2f);
     LeanTween.rotate(gameObject, new Vector3(8f, -90f, 0), 2f);
 }
Beispiel #14
0
 // Use this for initialization
 void Start()
 {
     LeanTween.move(gameObject, transform.position + new Vector3(1, -1, 1), move_speed).setOnComplete(() => RandomMove());
     LeanTween.rotate(gameObject, new Vector3(15, -15, 15), rot_speed).setOnComplete(() => RnadomRotation());
 }
Beispiel #15
0
 public void Rotate(float add)
 {
     LeanTween.rotate(gameObject, new Vector3(0, add, 0), 1f).setEasePunch();
 }
Beispiel #16
0
 void SpinMe(float delay)
 {
     LeanTween.rotate(rectTransform, -3240, 4f).setEase(LeanTweenType.easeInOutSine).setDelay(delay);
 }
Beispiel #17
0
 public static LTDescr LTRotate(this Transform self, Vector3 to, float time)
 {
     return(LeanTween.rotate(self.gameObject, to, time));
 }
    // Update is called once per frame
    private void OnGUI()
    {
        GUI.DrawTexture(grumpyRect.rect, grumpy);

        var staticRect = new Rect(0.0f * w, 0.0f * h, 0.2f * w, 0.14f * h);

        if (GUI.Button(staticRect, "Move Cat"))
        {
            if (LeanTween.isTweening(grumpyRect) == false)
            {
                // Check to see if the cat is already tweening, so it doesn't freak out
                var orig = new Vector2(grumpyRect.rect.x, grumpyRect.rect.y);
                LeanTween.move(grumpyRect, new Vector2(1.0f * Screen.width - grumpy.width, 0.0f * Screen.height), 1.0f)
                .setEase(LeanTweenType.easeOutBounce).setOnComplete(catMoved);
                LeanTween.move(grumpyRect, orig, 1.0f).setDelay(1.0f).setEase(LeanTweenType.easeOutBounce);
            }
        }

        if (GUI.Button(buttonRect1.rect, "Scale Centered"))
        {
            LeanTween.scale(buttonRect1, new Vector2(buttonRect1.rect.width, buttonRect1.rect.height) * 1.2f, 0.25f)
            .setEase(LeanTweenType.easeOutQuad);
            LeanTween.move(buttonRect1,
                           new Vector2(buttonRect1.rect.x - buttonRect1.rect.width * 0.1f,
                                       buttonRect1.rect.y - buttonRect1.rect.height * 0.1f), 0.25f).setEase(LeanTweenType.easeOutQuad);
        }

        if (GUI.Button(buttonRect2.rect, "Scale"))
        {
            LeanTween.scale(buttonRect2, new Vector2(buttonRect2.rect.width, buttonRect2.rect.height) * 1.2f, 0.25f)
            .setEase(LeanTweenType.easeOutBounce);
        }

        staticRect = new Rect(0.76f * w, 0.53f * h, 0.2f * w, 0.14f * h);
        if (GUI.Button(staticRect, "Flip Tile"))
        {
            LeanTween.move(beautyTileRect, new Vector2(0f, beautyTileRect.rect.y + 1.0f), 1.0f)
            .setEase(LeanTweenType.easeOutBounce);
        }

        GUI.DrawTextureWithTexCoords(
            new Rect(0.8f * w, 0.5f * h - beauty.height * 0.5f, beauty.width * 0.5f, beauty.height * 0.5f), beauty,
            beautyTileRect.rect);

        if (GUI.Button(buttonRect3.rect, "Alpha"))
        {
            LeanTween.alpha(buttonRect3, 0.0f, 1.0f).setEase(LeanTweenType.easeOutQuad);
            LeanTween.alpha(buttonRect3, 1.0f, 1.0f).setDelay(1.0f).setEase(LeanTweenType.easeInQuad);

            LeanTween.alpha(grumpyRect, 0.0f, 1.0f).setEase(LeanTweenType.easeOutQuad);
            LeanTween.alpha(grumpyRect, 1.0f, 1.0f).setDelay(1.0f).setEase(LeanTweenType.easeInQuad);
        }

        GUI.color = new Color(1.0f, 1.0f, 1.0f,
                              1.0f); // Reset to normal alpha, otherwise other gui elements will be effected

        if (GUI.Button(buttonRect4.rect, "Rotate"))
        {
            LeanTween.rotate(buttonRect4, 150.0f, 1.0f).setEase(LeanTweenType.easeOutElastic);
            LeanTween.rotate(buttonRect4, 0.0f, 1.0f).setDelay(1.0f).setEase(LeanTweenType.easeOutElastic);
        }

        GUI.matrix = Matrix4x4.identity;
    }
Beispiel #19
0
 //LeanTween.resumeAll
 //LeanTween.rotate
 public static LTDescr LeanRotate(this GameObject gameObject, Vector3 to, float time)
 {
     return(LeanTween.rotate(gameObject, to, time));
 }
Beispiel #20
0
    public void TokenClicked(int x, int y, Token selected)
    {
        player1emote.CloseEmoteButtons();
        player2emote.CloseEmoteButtons();
        bool sameToken = false;

        if (whiteWon || blackWon || gameMode != PlayerType.Local || EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        int rotationId = 0;

        //if the game is not over and same team
        if (!whiteWon && !blackWon && selected.isWhite == isWhiteTurn)
        {
            if (selectedToken != null)
            {
                LeanTween.cancelAll();
                if (isPlayer1White)
                {
                    LeanTween.rotate(selectedToken.gameObject, new Vector3(0, 0, 0), .01f);
                }
                else
                {
                    LeanTween.rotate(selectedToken.gameObject, new Vector3(0, 180, 0), .01f);
                }

                BoardHighlights.Instance.HideHighlights();
                Vector3 flatpos;
                flatpos.x = selectedToken.transform.position.x;
                flatpos.y = flatTokenYpos;
                flatpos.z = selectedToken.transform.position.z;
                //if already a selected token, make it stop floating
                LeanTween.move(selectedToken.gameObject, flatpos, 0.25f);

                //check to see if this is the same token
                if (selectedToken.currentX == selected.currentX && selectedToken.currentY == selected.currentY)
                {
                    sameToken     = true;
                    selectedToken = null;
                }
            }

            //make the token start floating a little
            //unless it was the previously selected token
            if (!sameToken)
            {
                //Debug.Log("selected: " + x + ", " + y);
                //select that token
                selectionX    = x;
                selectionY    = y;
                selectedToken = selected;

                Vector3 floatpos;
                floatpos.x = selectedToken.transform.position.x;
                floatpos.y = floatTokenYpos;
                floatpos.z = selectedToken.transform.position.z;
                LeanTween.move(selectedToken.gameObject, floatpos, .25f);

                //make it spin
                rotationId = LeanTween.rotateAround(selectedToken.gameObject, Vector3.up, 360f, 3).setLoopClamp().id;

                //Check East
                if (_core.IsMoveAllowed(selectionX, selectionY, Direction.East))
                {
                    //Highlight
                    if (isWhiteTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x + 1, y + 1);
                    }
                    else if (isBlackTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x + 1, y - 1);
                    }
                }

                //Check Forward
                if (_core.IsMoveAllowed(selectionX, selectionY, Direction.Forward))
                {
                    //Highlight
                    if (isWhiteTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x, y + 1);
                    }
                    else if (isBlackTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x, y - 1);
                    }
                }

                //Check West
                if (_core.IsMoveAllowed(selectionX, selectionY, Direction.West))
                {
                    //Highlight
                    if (isWhiteTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x - 1, y + 1);
                    }
                    else if (isBlackTurn)
                    {
                        BoardHighlights.Instance.HighlightTile(x - 1, y - 1);
                    }
                }
            }
        }
        else
        {
            if (!whiteWon && !blackWon && selected.isWhite != isWhiteTurn)
            {
                //they are trying to capture a piece
                TileClicked(x, y, selected.transform.position.x, selected.transform.position.z);
            }
        }
    }
Beispiel #21
0
 //LeanTween.rotate
 //LeanTween.rotate (RectTransform)
 public static LTDescr LeanRotate(this RectTransform rectTransform, Vector3 to, float time)
 {
     return(LeanTween.rotate(rectTransform, to, time));
 }
Beispiel #22
0
    private void MoveToken(int x, int y, float tileXPos, float tileZPos)
    {
        //Tween the position
        Vector3 newPosition = new Vector3()
        {
            x = tileXPos,
            y = flatTokenYpos,
            z = tileZPos
        };

        LeanTween.cancelAll();
        if (isPlayer1White)
        {
            LeanTween.rotate(selectedToken.gameObject, new Vector3(0, 0, 0), .01f);
        }
        else
        {
            LeanTween.rotate(selectedToken.gameObject, new Vector3(0, 180, 0), .01f);
        }
        LeanTween.move(selectedToken.gameObject, newPosition, .3f);
        // timeLeft = 60;

        string moveforLog = log.CoordsToNotations(selectedToken.currentX, selectedToken.currentY);

        selectedToken.SetBoardPosition(x, y);

        //destroy the captured token
        if (_capturedPiece != null)
        {
            Destroy(_capturedPiece);
            _capturedPiece = null;

            //add an x to the the log
            moveforLog += "x";

            //play the captured sound effect
            PlayMovementSoundEffect(true);
        }
        else
        {
            //play the normal sound effect
            PlayMovementSoundEffect(false);
        }

        moveforLog += log.CoordsToNotations(x, y);

        //Debug.Log(moveforLog);

        BoardHighlights.Instance.HideHighlights();
        selectedToken = null;

        if (!GameWon(y))
        {
            //toggle the turn
            ChangeTurn();
            //send the move to the log
            log.ShowNotations(moveforLog, !isWhiteTurn);
        }
        else
        {
            //send the move to the log
            log.ShowNotations(moveforLog, isWhiteTurn);
        }
    }
Beispiel #23
0
 public void Close()
 {
     LeanTween.rotate(door, closedRot, 1f).setEaseInSine();
 }
Beispiel #24
0
    void Update()
    {
        var playerDistance = Vector3.Distance(player.transform.position, transform.position);

        if (!canDash)
        {
            velocity.Set(0, 0, 0);
        }

        if (life <= 0)
        {
            OnDeathEffect();
        }

        if (!canDash && playerDistance > distanceToShoot)
        {
            velocity = player.transform.position - transform.position;
            velocity.Normalize();
        }

        if (!isAutoRotate && !canDash)
        {
            var targetVector = player.transform.position - transform.position;
            angleBetween = Mathf.Atan2(targetVector.y, targetVector.x) * Mathf.Rad2Deg;
            var lookSpeed = 3f;

            toLookAt = Quaternion.Euler(0, 0, angleBetween - 90);

            transform.rotation = Quaternion.Slerp(transform.rotation, toLookAt, lookSpeed * Time.deltaTime);
        }

        if (isAutoRotateFire)
        {
            degreeOffset++;
        }


        // transform.position += (velocity * speed * Time.deltaTime);
        if (canDash)
        {
            if (!isDashing)
            {
                velocity = Vector3.zero;

                var targetVector = player.transform.position - transform.position;
                var angleBetween = Mathf.Atan2(targetVector.y, targetVector.x) * Mathf.Rad2Deg;
                isDashing = true;
                LeanTween.rotate(gameObject, new Vector3(0, 0, angleBetween), 0.5f).setOnComplete(() =>
                {
                    velocity = targetVector.normalized;
                });
            }
            else
            {
                transform.position += velocity * speed * Time.deltaTime;
            }
        }
        else
        {
            RepelToOtherEnemies();
        }
        Shoot();
    }
Beispiel #25
0
        private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode)
        {
            float delay = item.delay + delayAdd;
            bool  code  = generateCode;
            float d     = item.duration;

            // Debug.Log("item:"+item.action);
            if (item.action == TweenAction.ALPHA)
            {
                tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ALPHA_VERTEX)
            {
                tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE)
            {
                tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL)
            {
                tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_X)
            {
                tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Y)
            {
                tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Z)
            {
                tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_X)
            {
                tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Y)
            {
                tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Z)
            {
                tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_CURVED)
            {
                tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_CURVED_LOCAL)
            {
                tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_SPLINE)
            {
                tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.ROTATE)
            {
                tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_AROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_AROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_LOCAL)
            {
                tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_X)
            {
                tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Y)
            {
                tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Z)
            {
                tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE)
            {
                tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.SCALE_X)
            {
                tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Y)
            {
                tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Z)
            {
                tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d);
            }
                        #if !UNITY_4_3 && !UNITY_4_5
            else if (item.action == TweenAction.CANVAS_MOVE)
            {
                tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_SCALE)
            {
                tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ALPHA)
            {
                tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.CANVAS_COLOR)
            {
                tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.TEXT_ALPHA)
            {
                tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.TEXT_COLOR)
            {
                tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.CANVAS_PLAYSPRITE)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.play(rectTransform, sprites).setFrameRate(" + item.frameRate + "f)");
                }
                else
                {
                    tween = LeanTween.play(GetComponent <RectTransform>(), item.sprites).setFrameRate(item.frameRate);
                }
            }
                        #endif
            else if (item.action == TweenAction.COLOR)
            {
                tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d);
            }
            else if (item.action == TweenAction.DELAYED_SOUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.delayedSound(gameObject, passAudioClipHere, " + vecToStr(item.from) + ", " + d + "f)");
                }
                else
                {
                    tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration);
                }
            }
            else
            {
                tween = null;
                Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:" + item);
                return;
            }


            // Append Extras
            if (generateCode)
            {
                if (delay > 0f)
                {
                    codeBuild.Append(".setDelay(" + delay + "f)");
                }
            }
            else
            {
                tween = tween.setDelay(delay);
            }
            if (item.ease == LeanTweenType.animationCurve)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setEase(");
                    append(item.animationCurve);
                    codeBuild.Append(")");
                }
                else
                {
                    tween.setEase(item.animationCurve);
                }
            }
            else
            {
                if (generateCode)
                {
                    if (item.ease != LeanTweenType.linear)
                    {
                        codeBuild.Append(".setEase(LeanTweenType." + item.ease + ")");
                    }
                }
                else
                {
                    tween.setEase(item.ease);
                }
            }
            // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease);
            if (item.between == LeanTweenBetween.FromTo)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setFrom(" + item.from + ")");
                }
                else
                {
                    tween.setFrom(item.from);
                }
            }
            if (item.doesLoop)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setRepeat(" + item.loopCount + ")");
                }
                else
                {
                    tween.setRepeat(item.loopCount);
                }

                if (item.loopType == LeanTweenType.pingPong)
                {
                    if (generateCode)
                    {
                        codeBuild.Append(".setLoopPingPong()");
                    }
                    else
                    {
                        tween.setLoopPingPong();
                    }
                }
            }
            if (generateCode)
            {
                codeBuild.Append(";\n");
            }
        }
Beispiel #26
0
        /// <summary>
        /// Moves camera from current position to a target position over a period of time.
        /// </summary>
        public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction,
                                          LeanTweenType sizeTweenType = LeanTweenType.easeInOutQuad, LeanTweenType posTweenType = LeanTweenType.easeInOutQuad, LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad)
        {
            if (camera == null)
            {
                Debug.LogWarning("Camera is null");
                return;
            }

            if (setCameraZ)
            {
                targetPosition.z = camera.transform.position.z;
            }

            // Stop any pan that is currently active
            StopPosTweens();
            swipePanActive = false;

            if (Mathf.Approximately(duration, 0f))
            {
                // Move immediately
                camera.orthographicSize   = targetSize;
                camera.transform.position = targetPosition;
                camera.transform.rotation = targetRotation;

                SetCameraZ(camera);

                if (arriveAction != null)
                {
                    arriveAction();
                }
            }
            else
            {
                sizeTween = LeanTween.value(camera.orthographicSize, targetSize, duration)
                            .setEase(sizeTweenType)
                            .setOnUpdate(x => camera.orthographicSize = x)
                            .setOnComplete(() =>
                {
                    camera.orthographicSize = targetSize;
                    if (arriveAction != null)
                    {
                        arriveAction();
                    }
                    sizeTween = null;
                });

                camPosTween = LeanTween.move(camera.gameObject, targetPosition, duration)
                              .setEase(posTweenType)
                              .setOnComplete(() =>
                {
                    camera.transform.position = targetPosition;
                    camPosTween = null;
                });

                camRotTween = LeanTween.rotate(camera.gameObject, targetRotation.eulerAngles, duration)
                              .setEase(rotTweenType)
                              .setOnComplete(() =>
                {
                    camera.transform.rotation = targetRotation;
                    camRotTween = null;
                });
            }
        }
Beispiel #27
0
 void EmitLeanTweenRotationFor(Transform t, GameObject go, Vector3 to, float twDuration, LeanTweenType ease)
 {
     t.rotation = Quaternion.identity;
     LeanTween.rotate(go, to, twDuration).setEase(ease).setOnComplete(() => EmitLeanTweenRotationFor(t, go, to, twDuration, ease));
 }
Beispiel #28
0
 public void ArrowUp()
 {//90
     LeanTween.rotate(gameObject, new Vector3(0f, 0f, 90f), 1f).setEase(UIController.Instance.m_curve);
 }
Beispiel #29
0
 public void MoveToShopKeeper(Action callback)
 {
     isFollowingPlayer = false;
     LeanTween.move(gameObject, new Vector3(-13.25f, 1, -5.64f), 1.5f);
     LeanTween.rotate(gameObject, new Vector3(0, -39, 0), 1.5f).setOnComplete(() => callback());
 }
Beispiel #30
0
    IEnumerator summonSpearAndPerformSpearAttack()
    {
        isAttacking = true;

        int whichDirection = -1 + 2 * Random.Range(0, 2);

        LeanTween.rotateLocal(upperArm, new Vector3(0, 0, 90), 0.75f).setEaseOutQuad();
        LeanTween.rotateLocal(lowerArm, new Vector3(0, 0, 180), 0.75f).setEaseOutQuad();

        yield return(new WaitForSeconds(0.75f));

        animator.Play("Forge Weapon");
        spearAnimator.gameObject.SetActive(true);
        spearAnimator.Play("Rise");
        forgeAudio.Play();

        yield return(new WaitForSeconds(9 / 12f));

        clawAnimator.Play("Claw Close");

        yield return(new WaitForSeconds(3 / 12f));

        LeanTween.rotateLocal(upperArm, new Vector3(0, 0, 270), 0.5f);
        LeanTween.rotateLocal(lowerArm, new Vector3(0, 0, 0), 0.5f);

        yield return(new WaitForSeconds(0.5f));

        for (int i = 0; i < 3; i++)
        {
            LeanTween.rotate(lowerArm, new Vector3(0, 0, angleToShip(lowerArm.transform)), 0.25f);

            yield return(new WaitForSeconds(0.25f));

            Vector3 directionToMove = new Vector3(Mathf.Cos((angleToShip(lowerArm.transform) + 180) * Mathf.Deg2Rad), Mathf.Sin((angleToShip(lowerArm.transform) + 180) * Mathf.Deg2Rad));
            LeanTween.move(lowerArm, (directionToMove * 4) + lowerArm.transform.position, 0.5f);

            yield return(new WaitForSeconds(0.5f));

            StartCoroutine(blinkWhite(spearAnimator.GetComponent <SpriteRenderer>()));

            yield return(new WaitForSeconds(0.6f));

            spearCollider.enabled = true;
            swipeAudio.Play();
            LeanTween.move(lowerArm, (directionToMove * -4) + lowerArm.transform.position, 0.1f);

            yield return(new WaitForSeconds(0.25f));

            spearCollider.enabled = false;
        }

        spearCollider.enabled = false;

        LeanTween.rotateLocal(upperArm, new Vector3(0, 0, 90), 0.75f).setEaseOutQuad();
        LeanTween.rotateLocal(lowerArm, new Vector3(0, 0, 180), 0.75f).setEaseOutQuad();

        yield return(new WaitForSeconds(0.75f));

        clawAnimator.Play("Claw Open");
        spearAnimator.Play("Sink");
        summonMagmaBalls();

        yield return(new WaitForSeconds(9 / 12f));

        spearAnimator.gameObject.SetActive(false);
        isAttacking = false;
    }