rotateAround() 공개 정적인 메소드

public static rotateAround ( GameObject gameObject, Vector3 axis, float add, float time ) : LTDescr,
gameObject GameObject
axis Vector3
add float
time float
리턴 LTDescr,
예제 #1
0
        // Play animation for kid spiraling into level icon with sound ("Whee!")
        void ShrinkKid(Vector3 posn)
        {
            GameObject kid = GameObject.FindGameObjectWithTag("Kid");

            // Rotate kid 360 degrees
            LeanTween.rotateAround(kid, Vector3.forward, 360f, 1f);

            // Shrink kid
            LeanTween.scale(kid, new Vector3(.1f, .1f, 1f), 1f);

            // Move kid to the position of the level icon
            LeanTween.move(kid, posn, 1f);

            // Fade out kid
            LeanTween.alpha(kid, 0f, .1f).setDelay(.9f);

            // if the current scene is Word Tree
            if (Application.loadedLevelName == "2. Word Tree")
            {
                // Load audio onto kid
                kid.AddComponent <AudioSource> ().clip = Resources.Load("Audio/TumbleSound") as AudioClip;
                // Play audio clip attached to kid if it exists
                if (kid.audio.clip != null)
                {
                    kid.audio.Play();
                }
            }
        }
예제 #2
0
    void Start()
    {
        // Setup
        GameObject avatarRotate = createSpriteDude("avatarRotate", new Vector3(-2.51208f, 10.7119f, -14.37754f));
        GameObject avatarScale  = createSpriteDude("avatarScale", new Vector3(2.51208f, 10.2119f, -14.37754f));
        GameObject avatarMove   = createSpriteDude("avatarMove", new Vector3(-3.1208f, 7.100643f, -14.37754f));

        // Rotate Example
        LeanTween.rotateAround(avatarRotate, Vector3.forward, -360f, 5f);

        // Scale Example
        LeanTween.scale(avatarScale, new Vector3(1.7f, 1.7f, 1.7f), 5f).setEase(LeanTweenType.easeOutBounce);
        LeanTween.moveX(avatarScale, avatarScale.transform.position.x + 1f, 5f).setEase(LeanTweenType.easeOutBounce);          // Simultaneously target many different tweens on the same object

        // Move Example
        LeanTween.move(avatarMove, avatarMove.transform.position + new Vector3(1.7f, 0f, 0f), 2f).setEase(LeanTweenType.easeInQuad);

        // Delay
        LeanTween.move(avatarMove, avatarMove.transform.position + new Vector3(2f, -1f, 0f), 2f).setDelay(3f);

        // Chain properties (delay, easing with a set repeating of type ping pong)
        LeanTween.scale(avatarScale, new Vector3(0.2f, 0.2f, 0.2f), 1f).setDelay(7f).setEase(LeanTweenType.easeInOutCirc).setLoopPingPong(3);

        // Call methods after a certain time period
        LeanTween.delayedCall(gameObject, 0.2f, advancedExamples);
    }
 void Start()
 {
     LeanTween.scale(gameObject, new Vector3(1f, 1f, 1f), 0.15f);
     LeanTween.rotateAround(gameObject, Vector3.back, 360f, 0.3f).setLoopClamp();
     LeanTween.moveX(gameObject, 2.0f, 1.0f).setEase(LeanTweenType.easeOutExpo);
     Destroy(gameObject, 1.0f);
 }
예제 #4
0
 void Start()
 {
     for (int i = 0; i < boxy.Length; i++)
     {
         LeanTween.rotateAround(boxy[i], Vector3.forward, 360f, duration).setLoopClamp();
     }
 }
        //<summary>
        // play celebratory animation when word is completed
        // word object spins around to a cheerful sound
        //</summary>
        public static void CelebratoryAnimation(float delayTime)
        {
            float      time = 1f;        // time to complete animation
            GameObject go   = GameObject.FindGameObjectWithTag(Constants.Tags.TAG_WORD_OBJECT);

            Debug.Log("Spinning " + go.name);
            // spin object around once
            LeanTween.rotateAround(go, Vector3.forward, 360f, time).setDelay(delayTime);
            // scale object up
            LeanTween.scale(go, new Vector3(go.transform.localScale.x * 1.3f, go.transform.localScale.y *
                                            1.3f, 1), time).setDelay(delayTime);
            // move object down
            LeanTween.moveY(go, 1.5f, time).setDelay(delayTime);
            // move target letters down
            GameObject[] tar = GameObject.FindGameObjectsWithTag(Constants.Tags.TAG_TARGET_LETTER);
            foreach (GameObject letter in tar)
            {
                LeanTween.moveY(letter, -3f, time).setDelay(delayTime);
            }
            // play sound
            Debug.Log("Playing clip for congrats");
            AudioSource audio = go.AddComponent <AudioSource>();

            audio.clip = Resources.Load("Audio/CongratsSound") as AudioClip;
            if (audio.clip != null)
            {
                audio.PlayDelayed(delayTime);
            }
            else
            {
                Debug.LogWarning("Cannot find audio clip");
            }
        }
        //<summary>
        // explode letters of word
        // currently handles words with 3-5 letters
        //</summary>
        IEnumerator ExplodeWord(float delayTime)
        {
            // wait for scene to load before exploding
            yield return(new WaitForSeconds(delayTime));

            // find movable letters
            GameObject[]  gos          = GameObject.FindGameObjectsWithTag(Constants.Tags.TAG_MOVABLE_LETTER);
            Vector3[]     posn         = new Vector3[gos.Length]; // contains desired position to move each letter to
            Vector3[]     shuffledPosn = new Vector3[gos.Length]; // contains the new positions after being shuffled
            System.Random rnd          = new System.Random();
            //randomize the positions that letters can explode too
            this.points = this.points.OrderBy(x => rnd.Next()).ToList();
            //move each letter to a random position
            for (int i = 0; i < gos.Length; i++)
            {
                //if we have more letters than points to move them to, then we should not
                //try to move the letters; otherwise, app will throw error and crash
                if (i >= points.Count)
                {
                    Debug.LogError("We have more letters (" + gos.Length + ") than positions to "
                                   + "explode them to (" + points.Count + ")! We moved all we can.");
                    break;
                }
                //move letter to new position and spin letter
                LeanTween.move(gos[i], points[i], 1.0f);
                LeanTween.rotateAround(gos[i], Vector3.forward, 360f, 1.0f);
            }
        }
예제 #7
0
    public void Move(int i, int j)
    {
        if (this.x != i || this.y != j)
        {
            LeanTween.move(this.gameObject.GetComponent <RectTransform> (), new Vector3(106 + 196 * i, 406 + 200 * j, 0), 0.3f);
            ManagerClassic.cubeList [this.x, this.y] = null;
            ManagerClassic.isBlank [this.x, this.y]  = true;
            this.x = i;
            this.y = j;
            ManagerClassic.cubeList [this.x, this.y] = this;
            ManagerClassic.isBlank [this.x, this.y]  = false;
        }

        if (needChanged)
        {
            LeanTween.move(otherCube.GetComponent <RectTransform> (), new Vector3(106 + 196 * i, 406 + 200 * j, 0), 0.3f);
            Destroy(otherCube.gameObject, 0.3f);
            int xx = otherCube.x;
            int yy = otherCube.y;
            ManagerClassic.isBlank [xx, yy] = true;
            LeanTween.rotateAround(gameObject, Vector3.up, 360f, 0.3f);
            StartCoroutine(ChangeImage());
        }


        this.needChanged = false;
    }
예제 #8
0
    private void addRandomTrackPoint()
    {
        float randX = Mathf.PerlinNoise(0f, randomIter);

        randomIter += randomIterWidth;

        Vector3 randomInFrontPosition = new Vector3((randX - 0.5f) * 20f, 0f, zIter * 40f);

        // placing the box is just to visualize how the paths get created
        GameObject box = objectQueue(cubes, ref cubesIter);

        box.transform.position = randomInFrontPosition;

        // Line the roads with trees
        GameObject tree  = objectQueue(trees, ref treesIter);
        float      treeX = zIter % 2 == 0 ? -15f : 15f;

        tree.transform.position = new Vector3(randomInFrontPosition.x + treeX, 0f, zIter * 40f);

        // Animate in new tree (just for fun)
        LeanTween.rotateAround(tree, Vector3.forward, 0f, 1f).setFrom(zIter % 2 == 0 ? 180f : -180f).setEase(LeanTweenType.easeOutBack);

        trackPts.Add(randomInFrontPosition); // Add a future spline node
        if (trackPts.Count > trackMaxItems)
        {
            trackPts.RemoveAt(0); // Remove the trailing spline node
        }
        zIter++;
    }
예제 #9
0
    /// <summary>
    /// Animation for a correct sequence
    /// </summary>
    public void SuccessAnimation()
    {
        IsRunning = true;

        for (int i = 0; i < displayElements.Length; i++)
        {
            TurnOn(i, false);
        }


        float originalSize = displayObject.sizeDelta.x;

        LeanTween.value(this.gameObject, UpdateDeltaSize, originalSize, 1.3f * originalSize, 0.5f).setOnComplete(
            () => LeanTween.value(this.gameObject, UpdateDeltaSize, 1.3f * originalSize, originalSize, 0.5f).setEaseOutBounce());
        LeanTween.rotateAround(displayObject, Vector3.forward, 360, 1.0f).setEaseOutSine();
        LeanTween.delayedCall(1.5f, () => IsRunning = false);

        RectTransform rect = Instantiate(SuccesEffect, displayObject.position, Quaternion.identity);

        rect.SetParent(displayObject);
        rect.SetAsFirstSibling();
        LeanTween.rotateAround(rect, Vector3.forward, 360, 2.0f).setEaseOutQuad();
        LeanTween.alphaCanvas(rect.GetComponent <CanvasGroup>(), 0, 2.0f).setEaseOutQuad();
        LeanTween.scale(rect, Vector3.one * 5.0f, 2.0f).setEaseOutQuad().setOnComplete(() => Destroy(rect.gameObject));
    }
예제 #10
0
 public void RotateAnimation()
 {
     LeanTween.value(this.gameObject, UpdateDeltaSize, originalSize, 1.3f * originalSize, animationTime / 2).setOnComplete(
         () => LeanTween.value(this.gameObject, UpdateDeltaSize, 1.3f * originalSize, originalSize, animationTime / 2).setEaseOutSine());
     LeanTween.rotateAround(displayObject, Vector3.forward, -360, animationTime).setEaseOutSine();
     LeanTween.delayedCall(animationTime, LoopAnimation);
 }
예제 #11
0
 private void AnimateGridSawOne()
 {
     LeanTween.rotateAround(gridSaw[0], Vector3.forward, 360f, duration / 2f).setLoopClamp().setIgnoreTimeScale(true);
     LeanTween.rotateAround(gridSaw[3], Vector3.forward, 360f, duration / 2f).setLoopClamp().setIgnoreTimeScale(true);
     LeanTween.move(gridSaw[0], cacheGridOne, duration).setEaseInOutQuad().setIgnoreTimeScale(true).setLoopPingPong();
     LeanTween.move(gridSaw[3], cacheGridTwo, duration).setEaseInOutQuad().setIgnoreTimeScale(true).setLoopPingPong();
 }
    private void Start()
    {
        _objectToAnimate = this.gameObject;

        if (fx)
        {
            float r = Random.value;
            if (r <= probability)
            {
                _delay = Random.Range(0f, 2f);
                StartCoroutine(Delay());
            }
            else
            {
                fxPrefab.Stop();
            }
        }

        if (move)
        {
            LeanTween.moveY(_objectToAnimate, _objectToAnimate.transform.position.y + Random.Range(minAmount, maxAmount),
                            Random.Range(1f, 2.5f)).setEaseLinear().setLoopPingPong();
        }

        if (rotate)
        {
            LeanTween.rotateAround(_objectToAnimate, Vector3.up, direction * 360, rotationSpeed).setLoopClamp();
        }
    }
예제 #13
0
 void ChangeDirection(UnoGamePlayData.TurnDirection _turnDirection)
 {
     if (_turnDirection == UnoGamePlayData.TurnDirection.ClockWise)
     {
         if (tweenRotateAround != null)
         {
             LeanTween.cancel(tweenRotateAround.uniqueId);
         }
         if (mySprite.transform.localScale.x < 0)
         {
             Vector3 _localScale = mySprite.transform.localScale;
             _localScale.x *= -1;
             mySprite.transform.localScale = _localScale;
         }
         tweenRotateAround = LeanTween.rotateAround(gameObject, Vector3.forward, -360f, rotTime).setLoopCount(-1);
     }
     else
     {
         if (tweenRotateAround != null)
         {
             LeanTween.cancel(tweenRotateAround.uniqueId);
         }
         if (mySprite.transform.localScale.x > 0)
         {
             Vector3 _localScale = mySprite.transform.localScale;
             _localScale.x *= -1;
             mySprite.transform.localScale = _localScale;
         }
         tweenRotateAround = LeanTween.rotateAround(gameObject, Vector3.forward, 360f, rotTime).setLoopCount(-1);
     }
 }
    IEnumerator StartInstantiateGuide(GameObject obj1, GameObject obj2, GameObject dot1, GameObject dot2)
    {
        obj1.SetActive(true);
        obj2.SetActive(false);
        dot1.SetActive(false);
        dot2.SetActive(false);
        LeanTween.rotateAround(obj1, Vector3.forward, 115f, 3f);
        while ((int)obj1.transform.eulerAngles.z != 115)
        {
            yield return(new WaitForFixedUpdate());
        }
        dot1.SetActive(true);

        yield return(new WaitForSeconds(0.5f));

        obj1.transform.localRotation = Quaternion.Euler(0, 0, 0);
        obj1.SetActive(false);
        obj2.SetActive(true);
        dot1.SetActive(false);
        dot2.SetActive(false);
        LeanTween.rotateAround(obj2, Vector3.forward, -115f, 3f);
        while ((int)obj2.transform.eulerAngles.z != 245)
        {
            yield return(new WaitForFixedUpdate());
        }
        dot2.SetActive(true);
        yield return(new WaitForSeconds(0.5f));

        obj2.transform.localRotation = Quaternion.Euler(0, 0, 0);
        //yield return new WaitForSeconds(0.1f);
        StartCoroutine(StartInstantiateGuide(obj1, obj2, dot1, dot2));
    }
예제 #15
0
 void Start()
 {
     LeanTween.rotateAround(gameObject, gameObject.transform.rotation.eulerAngles, 360f, 5f)
     .setDelay(1f)
     .setEase(LeanTweenType.easeOutBounce);
     Debug.Log("exported curve:" + curveToString(exportCurve));
 }
예제 #16
0
    private IEnumerator CountDownTimer()
    {
        if (countDownTimer != null)
        {
            countDownTimer.gameObject.SetActive(true);
            int dummyCounter = 3;
            for (int i = 0; i < 3; i++)
            {
                countDownTimer.SetText(dummyCounter.ToString());
                yield return(waitCountDown);

                dummyCounter--;
            }
            countDownTimer.SetText("GO!");
            yield return(waitCountDown);

            LeanTween.scale(countDownTimer.gameObject, Vector3.zero, 0.5f).setEaseInBack().setOnComplete(
                () =>
            {
                go = true;
                countDownTimer.gameObject.SetActive(false);
            });
            LeanTween.rotateAround(countDownTimer.gameObject, Vector3.forward, 180f, 0.3f).setDelay(0.2f);
        }
    }
    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);
    }
예제 #18
0
파일: TestingAllCS.cs 프로젝트: cjIrisZ/mdp
    public void rotateAroundExample()
    {
        Debug.Log("rotateAroundExample");

        GameObject lChar = GameObject.Find("LCharacter");

        LeanTween.rotateAround(lChar, Vector3.up, 360.0f, 1.0f).setUseEstimatedTime(useEstimatedTime);
    }
예제 #19
0
 void Start()
 {
     if (obstacleType == ObstacleType.SAW_BLADE)
     {
         LeanTween.moveX(gameObject, (transform.position.x + sawMoveDistance), sawMoveTime).setLoopPingPong();
         LeanTween.rotateAround(gameObject, Vector3.forward, sawSpinAmount, sawMoveTime).setLoopClamp();
     }
 }
예제 #20
0
 IEnumerator AnimateRotationManuallyCo()
 {
     while (true)
     {
         LeanTween.rotateAround(gameObject, transform.forward, 360f, data.duration * 2);
         yield return(new WaitForSeconds(data.duration * 2));
     }
 }
예제 #21
0
    // Use this for initialization
    void Start()
    {
        ball1 = GameObject.Find("Sphere1");

        LeanTween.rotateAround(ball1, Vector3.forward, -90f, 1.0f, new Hashtable());

        LeanTween.move(ball1, new Vector3(2f, 0f, 7f), 1.0f, new object[] { "delay", 1.0f });
    }
예제 #22
0
    // Use this for initialization
    void Start()
    {
        ball1 = GameObject.Find("Sphere1");

        LeanTween.rotateAround(ball1, Vector3.forward, -90f, 1.0f);

        LeanTween.move(ball1, new Vector3(2f, 0f, 7f), 1.0f).setDelay(1.0f).setRepeat(-1);
    }
예제 #23
0
    void RotateToMousePosition()
    {
        _afterPartOfPathMoving = AfterPartOfPathMoving();
        StartCoroutine(_afterPartOfPathMoving);
        LTDescr _movePartOfPath = LeanTween.rotateAround(gameObject, Vector3.forward, 180f, _rotateDuration).setEase(LeanTweenType.linear);

        _tweenId = _movePartOfPath.id;
    }
예제 #24
0
 void UpsideDown()
 {
     if (Input.GetKeyDown(KeyCode.Space) && !LeanTween.isTweening(mainCamera))
     {
         LeanTween.rotateAround(mainCamera, Vector3.forward, 180f, 0.5f).setEaseSpring();
         Physics2D.gravity = -Physics2D.gravity;
     }
 }
예제 #25
0
    //=====================================================

    public void OnCloseDoor(float delayBeforeClosing = 0.0f)
    {
        // Log that door is to close again (after opening)
        if (_isRotatingDoor == true)
        {
            // If door is opening
            if (_isOpen == false)
            {
                _queueCloseDoor = true;
            }

            return;
        }

        // Return if door is already closed
        if (_isOpen == false)
        {
            return;
        }

        // Start closing door
        _isRotatingDoor = true;

        // Determine rotation - puzzle doors only open in one direction
        var rotateBy = (_hingePosition == eHingePosition.LEFT) ? -_rotateOpenBy : _rotateOpenBy;

        // Tween door to closed position
        _tweenId = LeanTween.rotateAround(_thisGameObject, Vector3.up, -rotateBy, _rotateDuration)
                   .setDelay(delayBeforeClosing)
                   .setEase(LeanTweenType.easeInQuad)
                   .setOnComplete(() => { _isRotatingDoor = false; _isOpen = false; _tweenId = -1; })
                   .id;

        // Play audio fx
        if (_audioSource != null)
        {
            _audioSource.Play();
        }

        // Return if there's no second door or this is a second door
        if (_isDoubleDoor == true)
        {
            return;
        }
        if (_hasDoubleDoor == false)
        {
            return;
        }

        // Close second door
        CheckReferences();

        if (_doubleDoor != null)
        {
            _doubleDoor.GetComponent <Door>().OnCloseDoor(delayBeforeClosing);
        }
    }
예제 #26
0
    private void playAttackAnimation(GameObject gameObject)
    {
        float jumpHeight   = 0.5f;
        float jumpTime     = 0.1f;
        float rotationTime = 0.2f;

        LeanTween.move(gameObject, limitMovement(gameObject.transform.position + new Vector3(0, jumpHeight, 0)), jumpTime).setEase(LeanTweenType.easeInQuad);
        LeanTween.rotateAround(gameObject, new Vector3(0, 1f, 0), 300, rotationTime);
    }
예제 #27
0
 void Start()
 {
     if (!godMode)
     {
         //LeanTween.rotateAround(rotateProjectile[0], Vector3.left, -360f, 1f).setLoopClamp();
         LeanTween.rotateAround(rotateProjectile[1], Vector3.forward, -360f, 3f).setLoopClamp();
         //LeanTween.rotateAround(rotateProjectile[0], Vector3.forward, 360f, 2f).setLoopClamp().setRecursive(false);
     }
 }
예제 #28
0
 private void TurnLeft()
 {
     isMoving = true;
     LeanTween.rotateAround(gameObject, Vector3.up, -90f, 0.2f).setOnComplete(() =>
     {
         ShowLocation();
         isMoving = false;
     });
 }
예제 #29
0
        // explode letters of word
        // currently handles words with 3-5 letters
        IEnumerator ExplodeWord(float delayTime)
        {
            // wait for scene to load before exploding
            yield return(new WaitForSeconds(delayTime));

            // find movable letters
            GameObject[] gos = GameObject.FindGameObjectsWithTag("MovableLetter");

            Vector3[] posn         = new Vector3[gos.Length]; // contains desired position to move each letter to
            Vector3[] shuffledPosn = new Vector3[gos.Length]; // contains the new positions after being shuffled

            int y1 = 3;                                       // y-position
            int y2 = 2;                                       // y-position
            int z  = -2;                                      // z-position

            // set final positions for letters after explosion
            if (gos.Length == 3)
            {
                posn = new Vector3[3] {
                    new Vector3(-6, 0, z),
                    new Vector3(5, y2, z),
                    new Vector3(7, -y1, z)
                };
            }
            if (gos.Length == 4)
            {
                posn = new Vector3[4] {
                    new Vector3(-7, -y1, z),
                    new Vector3(-5, y2, z),
                    new Vector3(5, y2, z),
                    new Vector3(7, -y1, z)
                };
            }
            if (gos.Length == 5)
            {
                posn = new Vector3[5] {
                    new Vector3(-7, -y2, z),
                    new Vector3(-5, y2, z),
                    new Vector3(4, y1, z),
                    new Vector3(8, 0, z),
                    new Vector3(7, -y1, z)
                };
            }

            // shuffle the letters' positions
            shuffledPosn = ShuffleArray(posn);

            for (int i = 0; i < gos.Length; i++)
            {
                // move letter to desired position
                LeanTween.move(gos[i], shuffledPosn[i], 1.0f);

                // rotate letter around once
                LeanTween.rotateAround(gos[i], Vector3.forward, 360f, 1.0f);
            }
            Debug.Log("Exploded draggable letters");
        }
예제 #30
0
        // give user hint about what letter a particular sound is pronouncing
        public static void ShowSoundHint()
        {
            // find movable sound blanks
            GameObject[] mov = GameObject.FindGameObjectsWithTag("MovableBlank");

            // loop through sound blanks
            foreach (GameObject go in mov)
            {
                // choose first sound blank that is still draggable
                // i.e. hasn't been dragged onto a jar/letter yet
                if (go.GetComponent <PanGesture> ().enabled == true)
                {
                    // get position of sound blank
                    Vector3 posn = go.transform.position;

                    // sound blank rotates halfway around and fades out
                    LeanTween.rotateAround(go, Vector3.right, 180, 1f);
                    LeanTween.alpha(go, 0f, .5f).setDelay(.5f);

                    // create letter if one doesn't already exist
                    if (GameObject.Find("Hint" + go.name) == null)
                    {
                        ObjectProperties letter = ObjectProperties.CreateInstance("Hint" + go.name, "Hint", posn, new Vector3(WordCreation.letterScale * .9f, WordCreation.letterScale * .9f, 1), "Letters/" + go.name, null);
                        ObjectProperties.InstantiateObject(letter);
                    }

                    // find the letter just created / already created
                    GameObject hint = GameObject.Find("Hint" + go.name);

                    // move letter to center of corresponding sound blank
                    hint.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, 3);

                    // play phoneme sound of letter
                    go.audio.PlayDelayed(1f);

                    // letter fades in and moves in front of background to z = -3
                    LeanTween.alpha(hint, 0f, .01f);
                    LeanTween.moveZ(hint, -3, .01f).setDelay(1f);
                    LeanTween.alpha(hint, 1f, .01f).setDelay(1f);

                    // letter changes color to green and then back to black
                    LeanTween.color(hint, Color.green, 1f).setDelay(1f);
                    LeanTween.color(hint, Color.black, 1f).setDelay(2f);

                    // letter fades out and moves behind background to z = 3
                    LeanTween.alpha(hint, 0f, .01f).setDelay(3f);
                    LeanTween.moveZ(hint, 3, .01f).setDelay(3f);

                    // sound blank rotates back around and fades in
                    LeanTween.alpha(go, 1f, .5f).setDelay(3f);
                    LeanTween.rotateAround(go, Vector3.left, 180, 1f).setDelay(3f);

                    // exit loop once a hint letter has been created
                    break;
                }
            }
        }