rotateAroundLocal() public static méthode

public static rotateAroundLocal ( GameObject gameObject, Vector3 axis, float add, float time ) : LTDescr,
gameObject GameObject
axis Vector3
add float
time float
Résultat LTDescr,
Exemple #1
0
    public void Shake()
    {
        float height = Mathf.PerlinNoise(jumIter, 0f) * 5;

        height = height * height * 0.2f;

        float shakeAmt        = height; // degrees to shake the camera
        float shakePeriodTime = 0.25f;  // period of each shake
        float dropOffTime     = 1.25f;  // how long it takes to settle down to nothing

        LTDescr shakeTween = LeanTween
                             .rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime)
                             .setEase(LeanTweenType.easeShake)
                             .setLoopClamp()
                             .setRepeat(-1);



        LeanTween.value(gameObject, shakeAmt, 0, dropOffTime)
        .setOnUpdate((float val) =>
        {
            shakeTween.setTo(Vector3.right * val);
        })
        .setEase(LeanTweenType.easeOutQuad);
    }
    void Awake()
    {
        //Screen.showCursor = false;
        distanceBetweenShoulders = rightShoulder.position.x - leftShoulder.position.x;
        virtualWidth             = 2 * distanceBetweenShoulders;
        virtualHeight            = rightShoulder.position.y - hips.position.y;
        virtualCenter            = new Vector3(virtualWidth * 0.5f, virtualHeight, 0f);

        totalScreenWidth  = Screen.width;
        totalScreenHeight = Screen.height;
        print("RESOLUTION: " + totalScreenWidth + " " + totalScreenHeight);
        //Debug.Break ();
        print("Current " + Screen.currentResolution.width + " " + Screen.currentResolution.height);
        actualScreenWidth  = Screen.currentResolution.width;
        actualScreenHeight = Screen.currentResolution.height;
        GameObject g = new GameObject();

        g.name           = "BoundingBox";
        boundingBox      = g.AddComponent <BoxCollider> ();
        boundingBox.size = new Vector3(virtualWidth, virtualHeight, virtualHeight);
        bottomLeftCube   = GameObject.CreatePrimitive(PrimitiveType.Cube);
        topRightCube     = GameObject.CreatePrimitive(PrimitiveType.Cube);
        handClampedCube  = GameObject.CreatePrimitive(PrimitiveType.Cube);
        bottomLeftCube.renderer.enabled     = topRightCube.renderer.enabled = handClampedCube.renderer.enabled = false;
        bottomLeftCube.transform.localScale = topRightCube.transform.localScale = handClampedCube.transform.localScale = Vector3.one * 0.05f;
        //handCursor.color = new Color(handCursor.color.r, handCursor.color.g, handCursor.color.b, 1f);
        //handCursor.CrossFadeAlpha (1f, 1f, true);
        LeanTween.rotateAroundLocal(handCursor.gameObject, Vector3.forward, -15f, 1f).setEase(LeanTweenType.easeInOutSine);
        //enabled = false;
        LeanTween.rotateZ(handCursor.gameObject, -15f, 1f).setLoopPingPong().setDelay(1f).setEase(LeanTweenType.easeInOutSine);
        LeanTween.value(gameObject, UpdateCanvasGroupAlpha, 0f, 1f, 1f);
        enabled = false;
        print("Set up correctly");
    }
Exemple #3
0
        private void OnButtonHit(Button button)
        {
            string key = button.name;

            if (key.Equals("StartGUI"))
            {
                if (!gameStarted && !animationRunning)
                {
                    animationRunning    = true;
                    button.interactable = false;
                    LeanTween.moveLocalY(errorText.gameObject, 0, backgroundSpeed).setEase(backgroundEase);
                    LeanTween.rotateAroundLocal(button.gameObject, new Vector3(0, 0, 1), 5, 0.2f)
                    .setEase(LeanTweenType.easeShake)
                    .setRepeat(3)
                    .setOnComplete(() =>
                    {
                        LeanTween.moveLocalY(errorText.gameObject, -130, 0.3f).setDelay(2).setOnComplete(() => animationRunning = false);
                        button.interactable = true;
                    });
                }
                else if (gameStarted)
                {
                    button.interactable = false;
                    GUIEvents.current.OnManualControl();
                }
            }
        }
Exemple #4
0
    void Start()
    {
        tween1 = LeanTween.rotateAroundLocal(gameObject, Vector3.up, 1f, 0.2f).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1);
        tween2 = LeanTween.rotateAroundLocal(gameObject, Vector3.right, 1f, 0.25f).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1).setDelay(0.05f);

        LeanTween.delayedCall(gameObject, 3f, stopShake);
    }
Exemple #5
0
    public void ScreenShake()
    {
        /**************
        * Camera Shake
        **************/
        if (!LeanTween.isTweening(camx.gameObject))
        {
            float height = Mathf.PerlinNoise(jumpIter, 0f) * 5f;
            height = height * height * 0.2f;

            float   shakeAmt        = height * 0.9f;                    // the degrees to shake the camera
            float   shakePeriodTime = 0.2f;                             // The period of each shake
            float   dropOffTime     = 0.3f;                             // How long it takes the shaking to settle down to nothing
            LTDescr shakeTween      = LeanTween.rotateAroundLocal(camx.gameObject, Vector3.right, shakeAmt, shakePeriodTime)
                                      .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking
                                      .setLoopClamp()
                                      .setRepeat(-1);

            // Slow the camera shake down to zero
            LeanTween.value(camx.gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate(
                (float val) =>
            {
                shakeTween.setTo(Vector3.right * val);
            }
                ).setEase(LeanTweenType.easeOutQuad).setOnComplete(
                () =>
            {
                LeanTween.cancel(camx.gameObject);
                camx.transform.rotation = Quaternion.identity;
            });
        }
    }
Exemple #6
0
    IEnumerator Rotate(float angle, float rotationTime)
    {
        clockwise = !clockwise;

        if (tweenID != 0)
        {
            LeanTween.pause(tweenID);
            tweaningPaused = true;
            yield return(new WaitForSeconds(stopTimer));

            tweaningPaused = false;
            LeanTween.resume(tweenID);
        }

        if (clockwise)
        {
            tweenID = LeanTween.rotateAroundLocal(gameObject, Vector3.forward, angle, rotationTime).id;
        }
        else
        {
            tweenID = LeanTween.rotateAroundLocal(gameObject, Vector3.back, angle, rotationTime).id;
        }

        yield return(null);
    }
Exemple #7
0
    public override void Collected()
    {
        if (!isCollected)
        {
            collectionSound.start();

            if (SoundManager.manager.hype > 50 && SoundManager.manager.hype < 60)
            {
                SoundManager.manager.hype = 80f;
            }

            if (SoundManager.manager.hype < 100)
            {
                SoundManager.manager.hype += 10f;
            }

            if (SoundManager.manager.hype > 100)
            {
                SoundManager.manager.hype = 100;
            }

            collect_time = Time.time + delay;
            isCollected  = true;
            LeanTween.rotateAroundLocal(gameObject, new Vector3(0, 0, 1), 720, 1).setEase(LeanTweenType.easeOutBack);
        }
    }
Exemple #8
0
        //<summary>
        //move incorrect letters back to original position so user
        // can try spelling word again
        //</summary>
        public void ResetIncorrectLetters(float delayTime)
        {
            List <GameObject> incorrectLetters = IncorrectObjects(Constants.Tags.TAG_TARGET_BLANK);

            foreach (GameObject go in incorrectLetters)
            {
                // make sure letters are scaled back to original size
                go.transform.localScale = new Vector3(WordCreation.letterScale,
                                                      WordCreation.letterScale, 1);
                // change letter back to original color
                LeanTween.color(go, Color.white, .1f).setDelay(delayTime);
                Debug.Log("Resetting incorrect letter " + go.name);
                // move letter up in y-direction and away from the target blanks
                Vector3 posn = new Vector3(go.transform.position.x, 0, -2);
                //spin incorrect letters
                LeanTween.rotateAroundLocal(go, Vector3.up, 360f, 1);
                LeanTween.move(go, posn, 1.0f).setDelay(delayTime);
                // begin pulsing letters
                go.GetComponent <PulseBehavior>().StartPulsing(go, delayTime);
                // allow for letters to be dragged again by user
                go.GetComponent <GestureManager>().EnableGestures(go);
                //reset the blank variable so user can try again with these letters
                go.GetComponent <Properties>().isinblank = false;
            }
        }
Exemple #9
0
        //<summary>
        // move incorrect sound blanks back to original position
        // so user can try matching them to letters again
        //</summary>
        public void ResetIncorrectSounds(float delayTime)
        {
            List <GameObject> incorrectSounds = IncorrectObjects(Constants.Tags.TAG_TARGET_LETTER);

            foreach (GameObject go in incorrectSounds)
            {
                // make sure sound blank is correct scale
                go.transform.localScale = new Vector3(.3f, .3f, 1);
                Debug.Log("Resetting incorrect sound " + go.name);
                // move sound blank up in y-direction and away from the target letters/jars
                Vector3 posn = new Vector3(go.transform.position.x, 0, -2);
                LeanTween.move(go, posn, 1.0f).setDelay(delayTime);
                // start pulsing sound blank
                go.GetComponent <PulseBehavior>().StartPulsing(go, delayTime);
                // allow for touch gestures for sound blank again
                go.GetComponent <GestureManager>().EnableGestures(go);
                // find the jar that the sound object was dragged onto
                Vector2      position = go.transform.position;
                Collider2D[] jar      = Physics2D.OverlapCircleAll(position, 2f, 1, 1.5f, 0);
                //spin incorrect letters
                LeanTween.rotateAroundLocal(go, Vector3.up, 360f, 1);
                // change color of letter back to white
                LeanTween.color(jar[0].gameObject, Color.white, .01f).setDelay(delayTime);
                //reset the is in blank variable so user can try again with incorrect sounds
                go.GetComponent <Properties>().isinblank = false;
            }
        }
 public void RunRoomFailedAnimation()
 {
     print("RUN failed animation");
     LeanTween.rotateAroundLocal(createRoomBtn, new Vector3(0, 0, 1), 5, 0.2f)
     .setEase(LeanTweenType.easeShake)
     .setRepeat(3);
 }
Exemple #11
0
    void bigGuyJump()
    {
        float height = Mathf.PerlinNoise(jumpIter, 0f) * 10f;

        height = height * height * 0.3f;
        // //Debug.Log("height:"+height+" jumpIter:"+jumpIter);

        LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() => {
            LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete(() => {
                LeanTween.cancel(gameObject);

                /**************
                * Camera Shake
                **************/

                float shakeAmt        = height * 0.2f;                    // the degrees to shake the camera
                float shakePeriodTime = 0.42f;                            // The period of each shake
                float dropOffTime     = 1.6f;                             // How long it takes the shaking to settle down to nothing
                LTDescr shakeTween    = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime)
                                        .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking
                                        .setLoopClamp()
                                        .setRepeat(-1);

                // Slow the camera shake down to zero
                LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate(
                    (float val) => {
                    shakeTween.setTo(Vector3.right * val);
                }
                    ).setEase(LeanTweenType.easeOutQuad);


                /********************
                * Shake scene objects
                ********************/

                // Make the boxes jump from the big stomping
                GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn");                 // I just arbitrarily tagged the boxes with this since it was available in the scene
                foreach (GameObject box in boxes)
                {
                    box.GetComponent <Rigidbody>().AddForce(Vector3.up * 100 * height);
                }

                // Make the lamps spin from the big stomping
                GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController");         // I just arbitrarily tagged the lamps with this since it was available in the scene
                foreach (GameObject lamp in lamps)
                {
                    float z = lamp.transform.eulerAngles.z;
                    z       = z > 0.0f && z < 180f ? 1 : -1;       // push the lamps in whatever direction they are currently swinging
                    lamp.GetComponent <Rigidbody>().AddForce(new Vector3(z, 0f, 0f) * 15 * height);
                }

                // Play BOOM!
                LeanAudio.play(boomAudioClip, transform.position, height * 0.2f);       // Like this sound? : http://leanaudioplay.dentedpixel.com/?d=a:fvb:8,0,0.003005181,0,0,0.01507768,0.002227979,0,0,8~8,8.130963E-06,0.06526042,0,-1,0.0007692695,2.449077,9.078861,9.078861,0.01541314,0.9343268,-40,-40,0.05169491,0.03835937,-0.08621139,-0.08621139,8~0.1,0,0,~44100

                // Have the jump happen again 2 seconds from now
                LeanTween.delayedCall(2f, bigGuyJump);
            });
        });
        jumpIter += 5.2f;
    }
Exemple #12
0
    public void SnapToTargetAngleAction(int targetToolIndex, float time)
    {
        float c_angle = (360f + transform.localEulerAngles.z) % 360f;
        float t_angle = stickerTools [targetToolIndex].IdealAngle - c_angle;

        LeanTween.rotateAroundLocal(gameObject, Vector3.forward, t_angle, time).setOnComplete(CheckRaycast).setEaseInOutBack();
    }
Exemple #13
0
        public void ShowSignIn()
        {
            Tracker.ScreenVisit(SCREEN_NAME.SIGN_IN);

            #if PLAY_STORE || UNITY_IOS || UNITY_TVOS
            Social.localUser.Authenticate((bool success) => {
                isSignedIn = success;
                DataStorage.IgnoreSignIn = !success;

                if (!success)
                {
                    if (signInFailedEffect)
                    {
                        return;
                    }

                    signInFailedEffect    = true;
                    float shakeAmount     = 20;
                    float shakePeriodTime = .25f;
                    LTDescr shakeTween    = LeanTween.rotateAroundLocal(buttons[0].gameObject,
                                                                        Vector3.forward, shakeAmount, shakePeriodTime)
                                            .setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1);
                    LeanTween.value(buttons[0].gameObject, shakeAmount, 0f, 2).setOnUpdate((float val) => {
                        shakeTween.setTo(Vector3.right * val);
                    }).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => { signInFailedEffect = false; });

                    return;
                }

                buttons[0].gameObject.SetActive(false);
                buttons[1].gameObject.SetActive(true);
            });
            #endif
        }
    void bigGuyJump()
    {
        float height = Mathf.PerlinNoise(jumpIter, 0f) * 10f;

        height = height * height * 0.3f;
        // Debug.Log("height:"+height+" jumpIter:"+jumpIter);

        LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() => {
            LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete(() => {
                LeanTween.cancel(gameObject);

                /**************
                * Camera Shake
                **************/

                float shakeAmt        = height * 0.2f;                    // the degrees to shake the camera
                float shakePeriodTime = 0.42f;                            // The period of each shake
                float dropOffTime     = 1.6f;                             // How long it takes the shaking to settle down to nothing
                LTDescr shakeTween    = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime)
                                        .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking
                                        .setLoopClamp()
                                        .setRepeat(-1);

                // Slow the camera shake down to zero
                LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate(
                    (float val) => {
                    shakeTween.setTo(Vector3.right * val);
                }
                    ).setEase(LeanTweenType.easeOutQuad);


                /********************
                * Shake scene objects
                ********************/

                // Make the boxes jump from the big stomping
                GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn");                 // I just arbitrarily tagged the boxes with this since it was available in the scene
                foreach (GameObject box in boxes)
                {
                    box.rigidbody.AddForce(Vector3.up * 100 * height);
                }

                // Make the lamps spin from the big stomping
                GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController");         // I just arbitrarily tagged the lamps with this since it was available in the scene
                foreach (GameObject lamp in lamps)
                {
                    float z = lamp.transform.eulerAngles.z;
                    z       = z > 0.0f && z < 180f ? 1 : -1;       // push the lamps in whatever direction they are currently swinging
                    lamp.rigidbody.AddForce(new Vector3(z, 0f, 0f) * 15 * height);
                }

                // Play BOOM!
                playAudio(boomAudioClip, transform.position, height * 0.2f, 0.34f);

                // Have the jump happen again 2 seconds from now
                LeanTween.delayedCall(2f, bigGuyJump);
            });
        });
        jumpIter += 5.2f;
    }
Exemple #15
0
    public void ShakeCamera(Vector3 side, bool isUp)
    {
        LeanTween.cancel(gameObject);
        transform.localRotation = Quaternion.Euler(Vector3.zero);

        float height = Mathf.PerlinNoise(force1, 0f) * force2;

        height = height * height * 0.3f;

        /**************
        * Camera Shake
        **************/

        float   shakeAmt   = height * 0.2f * (isUp ? -1 : 1);  // the degrees to shake the camera
        LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, side, shakeAmt, shakePeriodTime)
                             .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking
                             .setLoopClamp()
                             .setRepeat(-1);

        // Slow the camera shake down to zero
        LeanTween.value(gameObject, shakeAmt, 0f, time).setOnUpdate(
            (float val) => {
            shakeTween.setTo(side * val);
        }
            ).setEase(LeanTweenType.easeOutQuad);

        // Play BOOM!
        LeanAudio.play(boomAudioClip, transform.position, height * 0.2f);         // Like this sound? : http://leanaudioplay.dentedpixel.com/?d=a:fvb:8,0,0.003005181,0,0,0.01507768,0.002227979,0,0,8~8,8.130963E-06,0.06526042,0,-1,0.0007692695,2.449077,9.078861,9.078861,0.01541314,0.9343268,-40,-40,0.05169491,0.03835937,-0.08621139,-0.08621139,8~0.1,0,0,~44100
    }
Exemple #16
0
    public void Shoot(Unit shooter)
    {
        target = shooter.target;

        var shooterPos           = shooter.gameObject.transform.position;
        var lookVector           = target.transform.position - shooterPos;
        var normalizedLookVector = lookVector.normalized;

        var distSquare = lookVector.magnitude;
        var spdSquare  = distSquare / (shooter.attackDelay * shooter.attackDelay);

        moveSpeed  = Mathf.Sqrt(spdSquare);
        moveSpeed *= 1.4f;
        moveValue  = moveSpeed * new Vector2(normalizedLookVector.x, normalizedLookVector.z);

        gameObject.transform.position = new Vector3(
            shooterPos.x, shooterPos.y + 0.5f, shooterPos.z);
        gameObject.transform.LookAt(target.transform);
        gameObject.transform.eulerAngles = new Vector3(-180.0f, target.transform.eulerAngles.y, -180.0f);

        SoundManager.GetInstance().Play(EFFECT_TYPE.BowShoot);
        LeanTween.rotateAroundLocal(gameObject, Vector3.up, 720.0f, shooter.attackDelay);

        ChangeState <UnitStateWalkAndSeek>();
        StartCoroutine("RemoveSelftAfter", shooter.attackDelay);
    }
    void Start()
    {
        // Time.timeScale = 1f/4f;

        // *********** Main Window **********
        // Scale the whole window in
        mainWindow.localScale = Vector3.zero;
        LeanTween.scale(mainWindow, new Vector3(1f, 1f, 1f), 0.6f).setEase(LeanTweenType.easeOutBack);
        LeanTween.alphaCanvas(mainWindow.GetComponent <CanvasGroup>(), 0f, 1f).setDelay(2f).setLoopPingPong().setRepeat(2);

        // Fade the main paragraph in while moving upwards
        mainParagraphText.anchoredPosition3D += new Vector3(0f, -10f, 0f);
        LeanTween.textAlpha(mainParagraphText, 0f, 0.6f).setFrom(0f).setDelay(0f);
        LeanTween.textAlpha(mainParagraphText, 1f, 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f);
        LeanTween.move(mainParagraphText, mainParagraphText.anchoredPosition3D + new Vector3(0f, 10f, 0f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f);

        // Flash text to purple and back
        LeanTween.textColor(mainTitleText, new Color(133f / 255f, 145f / 255f, 223f / 255f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f).setLoopPingPong().setRepeat(-1);

        // Fade button in
        LeanTween.textAlpha(mainButton2, 1f, 2f).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad);
        LeanTween.alpha(mainButton2, 1f, 2f).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad);


        // *********** Pause Button **********
        // Drop pause button in
        pauseWindow.anchoredPosition3D += new Vector3(0f, 200f, 0f);
        LeanTween.moveY(pauseWindow, pauseWindow.anchoredPosition3D.y + -200f, 0.6f).setEase(LeanTweenType.easeOutSine).setDelay(0.6f);

        // Punch Pause Symbol
        RectTransform pauseText = pauseWindow.Find("PauseText").GetComponent <RectTransform>();

        LeanTween.moveZ(pauseText, pauseText.anchoredPosition3D.z - 80f, 1.5f).setEase(LeanTweenType.punch).setDelay(2.0f);

        // Rotate rings around in opposite directions
        LeanTween.rotateAroundLocal(pauseRing1, Vector3.forward, 360f, 12f).setRepeat(-1);
        LeanTween.rotateAroundLocal(pauseRing2, Vector3.forward, -360f, 22f).setRepeat(-1);


        // *********** Chat Window **********
        // Flip the chat window in
        chatWindow.RotateAround(chatWindow.position, Vector3.up, -180f);
        LeanTween.rotateAround(chatWindow, Vector3.up, 180f, 2f).setEase(LeanTweenType.easeOutElastic).setDelay(1.2f);

        // Play a series of sprites on the window on repeat endlessly
        LeanTween.play(chatRect, chatSprites).setLoopPingPong();

        // Animate the bar up and down while changing the color to red-ish
        LeanTween.color(chatBar2, new Color(248f / 255f, 67f / 255f, 108f / 255f, 0.5f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong().setDelay(1.2f);
        LeanTween.scale(chatBar2, new Vector2(1f, 0.7f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong();

        // Write in paragraph text
        string origText = chatText.text;

        chatText.text = "";
        LeanTween.value(gameObject, 0, (float)origText.Length, 6f).setEase(LeanTweenType.easeOutQuad).setOnUpdate((float val) => {
            chatText.text = origText.Substring(0, Mathf.RoundToInt(val));
        }).setLoopClamp().setDelay(2.0f);
    }
Exemple #18
0
        /// <summary>
        /// Rotates the gameObject back and forth around the given axis.
        /// </summary>
        /// <param name="gameObject"></param>
        /// <param name="axis"></param>
        /// <param name="angle"></param>
        /// <param name="duration"></param>
        /// <param name="loops"></param>
        /// <param name="ease"></param>
        /// <param name="onComplete"></param>
        public static void Wobble(
            GameObject gameObject,
            Vector3 axis,
            float angle,
            float duration,
            int loops,
            LeanTweenType ease = LeanTweenType.linear,
            Action onComplete  = null)
        {
            loops = Mathf.Clamp(loops, 0, int.MaxValue);

            var wobbleDuration     = duration / (loops + 1);
            var halfWobbleDuration = wobbleDuration * 0.5f;
            var halfAngle          = angle * 0.5f;

            void Start()
            {
                WobbleStart();
            }

            void WobbleStart()
            {
                LeanTween.rotateAroundLocal(gameObject, axis, -halfAngle, halfWobbleDuration)
                .setEase(ease)
                .setOnComplete(() =>
                {
                    if (loops == 0)
                    {
                        WobbleEnd();
                    }
                    else
                    {
                        WobbleLoop();
                    }
                });
            }

            void WobbleLoop()
            {
                LeanTween.rotateAroundLocal(gameObject, axis, angle, halfWobbleDuration)
                .setLoopPingPong(loops)
                .setEase(ease)
                .setOnComplete(WobbleEnd);
            }

            void WobbleEnd()
            {
                LeanTween.rotateAroundLocal(gameObject, axis, halfAngle, halfWobbleDuration)
                .setEase(ease)
                .setOnComplete(OnComplete);
            }

            void OnComplete()
            {
                onComplete?.Invoke();
            }

            Start();
        }
    // TEST CODE - need to refine
    public void Shake()
    {
        StopShake();
        tween1 = LeanTween.rotateAroundLocal(gameObject, new Vector3(0, 0, 1f), 0.5f, 0.2f).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1);
        tween2 = LeanTween.rotateAroundLocal(gameObject, new Vector3(0, 0, -1f), 0.5f, 0.25f).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1).setDelay(0.05f);

        LeanTween.delayedCall(gameObject, 0.5f, StopShake);
    }
Exemple #20
0
 protected override void OnPuzzleCompleted()
 {
     anchorPoint.connectedBody = null;
     ropeJoint.connectedBody   = null;
     LeanTween.rotateAroundLocal(gearPiece, Vector3.forward, 360f, 5f).setLoopClamp();
     LeanTween.move(gearPiece, gearPiece.transform.position + new Vector3(3f, 0f, 0f), 1f);
     gearPiece.transform.GetChild(0).gameObject.SetActive(false);
 }
Exemple #21
0
        void Start()
        {
            LTDescr ltDescr = LeanTween.rotateAroundLocal(gameObject, axis, add, time);

            ltDescr.setDelay(delay);
            ltDescr.setRepeat(repeat);
            ltDescr.setDestroyOnComplete(destroyOnComplete);
        }
    public void Rotate()
    {
        isButy = true;

        LeanTween.rotateAroundLocal(gameObject, rotationAxis, (rotationCorrection), rotationTime)
        .setEase(rotationEasing)
        .setOnComplete(OnRotationComplete);
    }
Exemple #23
0
    public void RingRotation(GameObject ringObj, int i)
    {
        print("In function!");
        // x axis
        float angle = (i % 2 == 0)  ? -360f : 360f;

        LeanTween.rotateAroundLocal(ringObj, ringObj.transform.up, angle, 2.2f).setRepeat(999).setDelay(Random.Range(2, 4));
    }
Exemple #24
0
 public static LTDescr TweenShake(this Transform transform, float amplitude = .2f, float duration = .42f,
                                  int loopsCount = 1)
 {
     return(LeanTween.rotateAroundLocal(transform.gameObject,
                                        new Vector3(Random.Range(0f, 1f), Random.Range(0f, 1f), z: Random.Range(0f, 1f)),
                                        amplitude, duration)
            .setEase(LeanTweenType.easeShake)
            .setLoopClamp(loopsCount));
 }
Exemple #25
0
 public static LTDescr TweenShakeZ(this Transform transform, float amplitude = .2f, float duration = .42f,
                                   int loopsCount = 1)
 {
     return(LeanTween.rotateAroundLocal(transform.gameObject,
                                        Vector3.forward,
                                        Random.Range(-amplitude - .1f, amplitude + .1f), duration)
            .setEase(LeanTweenType.easeShake)
            .setLoopClamp(loopsCount));
 }
 // Start is called before the first frame update
 void Start()
 {
     NextDialogue();
     lastPos = marty.transform.position;
     timeSwitchManager.enabled = false;
     marty.enabled             = false;
     victoryPanel.SetActive(false);
     LeanTween.rotateAroundLocal(gearPuzzlePiece.gameObject, Vector3.forward, 360f, 5f).setLoopClamp();
 }
    void Update()
    {
        LeanTween.dtManual = Time.deltaTime;
        if (Input.GetKeyDown(KeyCode.Q))
        {
            LeanTween.scale(this.gameObject, Vector3.one * 3f, 1.0f).setEase(LeanTweenType.easeSpring).setUseManualTime(true);
            print("scale punch time independent!");
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            LeanTween.scale(this.gameObject, Vector3.one * 3f, 1.0f).setEase(LeanTweenType.easeSpring);
            print("scale punch!");
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            // LeanTween.rotate(this.gameObject, Vector3.one, 1.0f).setEase(LeanTweenType.punch);
            LeanTween.rotateAroundLocal(this.gameObject, this.transform.forward, -80f, 5.0f).setPoint(new Vector3(1.25f, 0f, 0f));
            print("rotate punch!");
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            // LeanTween.move(this.gameObject, new Vector3(0f,0f,1f), 1.0f).setEase(LeanTweenType.punch);
            print("move punch!");

            LeanTween.moveX(this.gameObject, 1f, 1f).setOnComplete(destroyOnComp).setOnCompleteParam(this.gameObject);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            LeanTween.color(this.gameObject, new Color(1f, 0f, 0f, 0.5f), 1f);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            LeanTween.delayedCall(gameObject, 0.3f, delayedMethod).setRepeat(4).setOnCompleteOnRepeat(true).setOnCompleteParam("hi");
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            Color      to = new Color(Random.Range(0f, 1f), 0f, Random.Range(0f, 1f), 0.0f);
            GameObject l  = GameObject.Find("LCharacter");
            LeanTween.color(l, to, 4.0f).setRepeat(2).setLoopPingPong().setEase(LeanTweenType.easeOutBounce);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            LeanTween.value(gameObject, updateColor, new Color(1.0f, 0.0f, 0.0f, 1.0f), Color.blue, 4.0f);//.setRepeat(2).setLoopPingPong().setEase(LeanTweenType.easeOutBounce);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            LeanTween.delayedCall(0.05f, enterMiniGameStart).setOnCompleteParam(new object[] { "" + 5 });
        }
    }
Exemple #28
0
        public void RotateFast(Direction dir)
        {
            LeanTween.cancel(_rotor);

            var rot  = Quaternion.Inverse(_rotor.transform.localRotation);
            var axis = rot * dir.Rotated(1).Axis();

            LeanTween.rotateAroundLocal(_rotor, axis, 900f, NodeRotateTime * 3)
            .setEase(LeanTweenType.easeInOutSine);
        }
        public void init()
        {
            transform.localPosition = _localPosition;

            LeanTween.rotateAroundLocal(transform.parent.gameObject, _zAxis, 360, rotateTime).setEase(LeanTweenType.easeInOutQuint).setDelay(rotateDelay);
            LeanTween.rotateAroundLocal(gameObject, -_zAxis, 360, rotateTime).setEase(LeanTweenType.easeInOutQuint).setDelay(rotateDelay);
            LeanTween.moveLocal(gameObject, Vector3.zero, moveTime).setDelay(moveDelay);
            Logic.UI.CommonAnimations.CommonFadeToAnimation fadeto = Logic.UI.CommonAnimations.CommonFadeToAnimation.Get(gameObject);
            fadeto.init(1f, 0, moveTime, moveDelay);
        }
    private IEnumerator ReprocutionAnimCo()
    {
        LeanTween.rotateAroundLocal(_sprite.gameObject, Vector3.forward, _forceMax, _durationMin)
        .setEase(LeanTweenType.easeShake)         // this is a special ease that is good for shaking
        .setLoopClamp();

        yield return(new WaitForSeconds(_animal.ReproductionTime));

        CancelAnims();
    }