Esempio n. 1
0
    // if a dialogue is open and I click on submit,
    // I stop text animation and with another click I go to the next string or I close dialogue
    // If I click Escape (optionally) I immediately close dialogue
    void Update()
    {
        if (!DialogueBox.activeSelf)
        {
            return;
        }

        if (Input.GetButtonDown("Submit") || Input.GetButtonDown("Jump"))
        {
            if (textComponent.text == GlobalVariables.Dialogues[index])
            {
                NextImg.SetActive(false);
                ExitImg.SetActive(false);
                NextLine();
            }
            else
            {
                if (coroutine != null)
                {
                    StopCoroutine(coroutine);
                }
                textComponent.text = GlobalVariables.Dialogues[index];
                ShowNextImg();
            }
        }
        else if (Input.GetButtonDown("Escape"))
        {
            if (coroutine != null)
            {
                StopCoroutine(coroutine);
            }
            StartCoroutine(DelayEnableInput()); // I delay enable input because player still receive input (is not in pause)
            DialogueBox.SetActive(false);
        }
    }
Esempio n. 2
0
    // if I press submit or cancel, I close dialogue score ui
    void Update()
    {
        if (!DialogueBox.activeSelf)
        {
            return;
        }

        if (Input.GetButtonDown("Submit") || Input.GetButtonDown("Jump"))
        {
            if (textComponent.text == text)
            {
                ExitImg.SetActive(false);
                DialogueBox.SetActive(false);
                StartCoroutine(DelayEnableInput());
                StartCoroutine(DelayEnableScoreUI());   // I delayed disactive of this object because when player press submit he can reopen this dialogue
            }
            else
            {
                if (coroutine != null)
                {
                    StopCoroutine(coroutine);
                }
                textComponent.text = text;
                ExitImg.SetActive(true);
            }
        }
    }
Esempio n. 3
0
 // disable all objects on start
 void Start()
 {
     DialogueBox.SetActive(false);
     NextImg.SetActive(false);
     ExitImg.SetActive(false);
     textComponent.text = string.Empty;
 }
Esempio n. 4
0
 // same animation of DialogueUI
 IEnumerator TypeLine(string x)
 {
     foreach (char c in x.ToCharArray())
     {
         textComponent.text += c;
         yield return(new WaitForSeconds(textSpeed));
     }
     ExitImg.SetActive(true);
 }
Esempio n. 5
0
 // If this is the last string I show the exit image, otherwise I show the next image
 private void ShowNextImg()
 {
     if (index == endIndex)
     {
         ExitImg.SetActive(true);
     }
     else
     {
         NextImg.SetActive(true);
     }
 }