Example #1
0
    // Update is called once per frame
    void Update()
    {
        counter += Time.deltaTime;
        if (index < textLength)
        {
            if (counter >= 0.05)
            {
                actualText      = actualText + story[index];
                textToShow.text = actualText;
                index++;
                counter = 0;
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (completed)
            {
                if (SceneManager.GetActiveScene().name != "Story_8")
                {
                    SceneManager.LoadScene("Story_" + numberStory);
                }

                else
                {
                    music.DestroyItem();
                    SceneManager.LoadScene("1_UpperMantle");
                }
            }
            else
            {
                for (int j = 0; j < textLength; j++)
                {
                    completeText = completeText + story[j];
                }

                textToShow.text = completeText;
                index           = textLength;
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape) && escaped)
        {
            music.DestroyItem();
            SceneManager.LoadScene("1_UpperMantle");
        }
        if (Input.GetKeyDown(KeyCode.Escape) && !escaped)
        {
            textEscape.enabled = true;
            escaped            = true;
        }

        if (index == textLength)
        {
            textSpace.enabled = true;
            completed         = true;
        }
    }