Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        //once conversation starts
        if (conversationAlive)
        {
            timer += Time.deltaTime;
            //depending on voice speed of character move the tick letter by letter
            if (timer >= currConversation.conv.voiceSpeed)
            {
                if (tickPosition == 0)
                {
                    convText.text = "";
                }

                if (tickPosition >= currLine.Length)
                {
                    //Auto skip to next line

                    /*
                     * if (NextLineConversation()){
                     *  conversationAlive = false;
                     * }
                     * else
                     * {
                     *  timer = -1f;
                     *  tickPosition = 0;
                     * }*/

                    return;
                }

                char letter = currLine[tickPosition];
                convText.text += letter;

                tickPosition++;
                timer = 0f;

                int numberAlphabet = char.ToUpper(letter) - 64;
                if (numberAlphabet < 0 || numberAlphabet > 24)
                {
                    return;
                }

                if (tickPosition % 3 == 0)
                {
                    currConversation.PlayVoice(allSoundsDialog[numberAlphabet]);
                }
            }
        }
    }