Ejemplo n.º 1
0
    IEnumerator animateFlip(bool unflip)
    {
        // The first time we flip over a card, play the pattern associated
        if (!unflip)
        {
            long[] pattern   = MorseCode.GetPattern(GetComponent <Card> ().letter);           // code pattern goes here
            long[] msPattern = new long[pattern.Length];

            for (int i = 0; i < pattern.Length; i++)
            {
                msPattern[i] = pattern[i] * dotVibrationLength;
            }

            // stop any currently playing vibrations
            Vibration.Cancel();
            Vibration.Vibrate(msPattern, -1);
        }
        else
        {
            yield return(new WaitForSeconds(rotationSpeed / 2));

            Debug.Log("Sorry, that wasn't a match.");
        }

        // animate the card rotation
        for (int i = 0; i < 180; i += rotationSpeed)
        {
            gameObject.transform.Rotate(new Vector3(0, rotationSpeed, 0));
            yield return(null);
        }

        // and set back to unflipped status
        if (unflip)
        {
            isFlipped = false;
        }
    }