コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        //Subtract the passed time from the timer
        letterTimer -= Time.deltaTime;
        Color c = dialogueBox.transform.parent.Find("arrow").GetComponent <Image>().color;

        if (bufferText.Count <= 0)
        {
            c = new Color(150, 150, 255, 1.0f);
            dialogueBox.transform.parent.Find("arrow").GetComponent <Image>().color = c;
        }
        else
        {
            c = new Color(c.r, c.b, c.g, .5f);
            dialogueBox.transform.parent.Find("arrow").GetComponent <Image>().color = c;
        }
        if (bufferText.Count <= 0 && (Input.GetKeyDown(KeyCode.Mouse0) || Input.touchCount > 0 || Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton1)))
        {
            ClearText();
            if (dialogue != null && dialogue.Count > 0)
            {
                SetText(dialogue.Dequeue());
            }
            letterTimer = letterPause * scrollSpeed;
            isClicked   = false;
        }
        //Display all text on left click
        else if ((Input.GetKeyDown(KeyCode.Mouse0) || Input.touchCount > 0 || Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton1)))   //&& dialogueBox.transform.parent.GetComponent<DialogueBox>().isClicked()) {
        {
            StringBuilder stringBuilder = new StringBuilder("", bufferText.Count);
            while (bufferText.Count > 0)
            {
                stringBuilder.Append(bufferText.Dequeue());
            }
            DisplayText(stringBuilder.ToString());
            isClicked = false;
        }
        //Check if enqueued text is null, if it has any characters,
        //and if the timer on the character delay is up
        if (bufferText != null && bufferText.Count > 0 && letterTimer <= 0.0f)
        {
            for (int i = 0; i < (int)(letterTimer * -10000f); i += (int)(letterPause * scrollSpeed * 10000f))
            {
                if (bufferText.Count > 0)
                {
                    DisplayText(bufferText.Dequeue() + "");
                }
                else
                {
                    break;
                }
            }
            letterTimer = letterPause * scrollSpeed;
        }

        textScrollTimer -= Time.deltaTime;
        if (bufferText.Count > 0 && textScrollTimer <= 0 && bufferText.Peek() != ' ')
        {
            //play sound for text scrolling
            //AudioManager.GetComponent<AudioManager>().PlayTextScroll();
            textScrollTimer = textScrollPause * scrollSpeed;
        }
        if (finishedDialogueSequence && dialogue.Count == 0 && (Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton1)))
        {
            finishedDialogueSequence = false;
            dialogueContainer.SetActive(false);
            flagMan.DialogueEnded(currentSequenceName);                                                         //Tell the flagmanager
            GameObject.Find("InteractionManagerGO").GetComponent <InteractionManager>().DialogueActive = false; //Tell the interaction manager
        }
        if (dialogue != null && dialogue.Count == 0)
        {
            finishedDialogueSequence = true;
        }


        dialogueBox.text.Replace("<br>", "\n");
    }