示例#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);
        }
    }
示例#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);
            }
        }
    }
示例#3
0
 // disable all objects on start
 void Start()
 {
     DialogueBox.SetActive(false);
     NextImg.SetActive(false);
     ExitImg.SetActive(false);
     textComponent.text = string.Empty;
 }
示例#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);
 }
示例#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);
     }
 }