Exemple #1
0
    public void OnClickOnLetter(Letter l)
    {
        if (lockTouchLetters)
        {
            return;
        }
        bool correct = l.id == correctLetterID;

        l.SetAnimationState(Letter.LetterAnimState.Click);
        if (correct)
        {
            completedLettersCount++;
            SpriteTweeners.SpriteMoveToPointViaCurve(this, l.transform, l.parentLetter.transform.position, moveCurve2, flyTime);
            l.SetColor(Color.red, flyTime);
            l.interactable = false;
            if (completedLettersCount == lettersOnTopObjects.Length)
            {
                OnWin();
            }
        }
        else
        {
            StopAllCoroutines();
            l.ColorOnFail();
            StartCoroutine(RestartLevelOnFail());
        }
        if (playCorrectLetterRoutine != null)
        {
            StopCoroutine(playCorrectLetterRoutine);
        }
        playCorrectLetterRoutine = StartCoroutine(PlayCorrectLetter(alphabetData.GetLetterByID(l.id).ac, completedLettersCount, correct));
    }
Exemple #2
0
    IEnumerator RestartLevelOnFail()
    {
        lockTouchLetters      = true;
        completedLettersCount = 0;
        for (int i = 0; i < correctLetters.Count; i++)
        {
            currentLetters[correctLetters[i]].interactable = true;
            currentLetters[correctLetters[i]].SetColor(Color.gray, flyTime);
            SpriteTweeners.SpriteMoveToPointViaCurve(this, currentLetters[correctLetters[i]].transform, points[correctLetters[i]], moveCurve2, flyTime);
        }
        yield return(new WaitForSeconds(1.2f));

        MixAllPoints();
        MirrorPoints();
        for (int i = 0; i < currentLetters.Count; i++) //smoothly move letters to positions
        {
            SpriteTweeners.SpriteMoveToPointViaCurve(this, currentLetters[i].transform, points[i], moveCurve3, flyTime, false);
        }
        yield return(new WaitForSeconds(flyTime + 2));

        lockTouchLetters = false;

        yield break;
    }
Exemple #3
0
    IEnumerator TutorPartProcess()
    {
        for (int i = 0; i < lettersOnTopObjects.Length; i++)
        {
            TextMesh tm = lettersOnTopObjects[i].GetComponentInChildren <TextMesh>();
            tm.color = Color.red;
            tm.text  = currentLeterData.letter.ToString();
            if (i % 2 == 1)
            {
                tm.text = tm.text.ToLower();
            }
            lettersOnTopObjects[i].gameObject.SetActive(false);
            lettersOnTopObjects[i].SetDrawOrder(layerName, 0);
            lettersOnTopObjects[i].id = correctLetterID;
        }
        yield return(null);

        AudioManager.PlayVoiceOneShot(taskAC, true);
        foreach (Letter l in lettersOnTopObjects)
        {
            l.gameObject.SetActive(true);
            l.SetAnimationState(Letter.LetterAnimState.Appear);
            yield return(new WaitForSeconds(0.2f));
        }
        currentLetters = new List <Letter>();

        //generating points
        Bounds  bounds = new Bounds();
        Vector3 tempPos;

        tempPos = Camera.main.ScreenToWorldPoint(Screen.height * Vector3.up + Screen.width * Vector3.right);
        Vector3 max = new Vector3(tempPos.x - borderOffset, lettersOnTopObjects[0].transform.position.y - borderOffset - 0.7f, 0);

        tempPos = Camera.main.ScreenToWorldPoint(Vector2.zero);
        Vector3 min = new Vector3(tempPos.x + borderOffset, tempPos.y + borderOffset, 0);

        bounds.SetMinMax(min, max);

        points = null;
        GeneratePoints(ref points, curLettersPointsCount, bounds);

        //generation ended

        for (int i = 0; i < points.Count; i++) // spawn all letters on positions
        {
            Letter newLetter = Instantiate(letterPrefab, points[i], Quaternion.identity).GetComponent <Letter>();
            currentLetters.Add(newLetter);
            int letterID = 0;
            do
            {
                letterID = Random.Range(0, alphabetData.lettersList.Count);
            } while (letterID == correctLetterID);

            newLetter.Init(this, letterID, alphabetData.GetLetterByID(letterID).letter,
                           fonts[Random.Range(0, fonts.Count)], Random.Range(0, 2) == 0);
            newLetter.transform.localScale = Vector3.one * defaultLocalScaleForLetter;
            newLetter.SetDrawOrder(layerName, 0);
            newLetter.interactable = true;
            newLetter.gameObject.SetActive(false);
        }

        yield return(new WaitForSeconds(.3f));

        correctLetters = new List <int>();

        for (int i = 0; i < lettersOnTopObjects.Length; i++) // generating Correct Letters and moving them to start positions
        {
            int indexForCorrectLetter;
            do
            {
                indexForCorrectLetter = Random.Range(0, currentLetters.Count);
            } while (correctLetters.Contains(indexForCorrectLetter));
            correctLetters.Add(indexForCorrectLetter);
            Letter l = currentLetters[indexForCorrectLetter];
            l.SetParentLetter(lettersOnTopObjects[i]);
            l.gameObject.SetActive(true);
            l.transform.position = lettersOnTopObjects[i].transform.position;
        }
        yield return(null);

        for (int i = 0; i < correctLetters.Count; i++) //smoothly move letters to positions
        {
            lettersOnTopObjects[i].SetColor(Color.white, 0);
            currentLetters[correctLetters[i]].SetDrawOrder(layerName, 1);
            SpriteTweeners.SpriteMoveToPointViaCurve(this, currentLetters[correctLetters[i]].transform, points[correctLetters[i]], moveCurve1, flyTime, false);
            currentLetters[correctLetters[i]].SetColor(Color.gray, flyTime);
            yield return(new WaitForSeconds(0.2f));
        }
        yield return(new WaitForSeconds(0.8f));

        for (int i = 0; i < currentLetters.Count; i++) // other letters appear
        {
            if (currentLetters[i].id != correctLetterID)
            {
                currentLetters[i].gameObject.SetActive(true);
                currentLetters[i].SetColor(Color.gray, 0);
                currentLetters[i].SetAnimationState(Letter.LetterAnimState.Appear);
            }
        }
        MixAllPoints();
        yield return(new WaitForSeconds(1));

        for (int i = 0; i < currentLetters.Count; i++) // mix letters
        {
            SpriteTweeners.SpriteMoveToPointViaCurve(this, currentLetters[i].transform, points[i], moveCurve2, 0.7f);
        }

        lockTouchLetters = false;
        yield break;
    }