IEnumerator Speaking(string speech, bool additive, string speaker = "", CharacterDialogueDetails.CDD dialogueDetails = null)
    {
        speechPanel.SetActive(true);

        string additiveSpeech = additive ? speechText.text : "";

        targetSpeech = additiveSpeech + speech;

        //create a new architect the very first time. Any time other than that and we renew the architect.
        if (textArchitect == null)
        {
            textArchitect = new TextArchitect(speechText, speech, additiveSpeech);
        }
        else
        {
            textArchitect.Renew(speech, additiveSpeech);
        }

        speakerNameText.text = DetermineSpeaker(speaker);//temporary
        speakerNamePane.SetActive(speakerNameText.text != "");

        //get or create a fresh set of dialogue details to make the dialogue system look a certain way for certain characters.
        string speakerValue = speakerNameText.text;

        if (speakerValue.Contains("<color="))
        {
            speakerValue = speakerValue.Split('>')[1];
        }
        if (dialogueDetails == null)
        {
            dialogueDetails = new CharacterDialogueDetails.CDD(speakerValue);
        }
        SetDialogueDetails(dialogueDetails);

        isWaitingForUserInput = false;

        if (isClosed)
        {
            OpenAllRequirementsForDialogueSystemVisibility(true);
        }

        while (textArchitect.isConstructing)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                textArchitect.skip = true;
            }

            yield return(new WaitForEndOfFrame());
        }

        //text finished
        isWaitingForUserInput = true;
        while (isWaitingForUserInput)
        {
            yield return(new WaitForEndOfFrame());
        }

        StopSpeaking();
    }
    void SetDialogueDetails(CharacterDialogueDetails.CDD cdd)
    {
        //set the color of the name field.
        speakerNameText.text = cdd.nameColor + speakerNameText.text;

        //Set the font for this character.
        speechText.font = cdd.speechFont;
    }
    /// <summary>
    /// Say something and show it on the speech box.
    /// </summary>
    public void Say(string speech, string speaker = "", bool additive = false, CharacterDialogueDetails.CDD dialogueDetails = null)
    {
        StopSpeaking();

        if (additive)
        {
            speechText.text = targetSpeech;
        }

        speaking = StartCoroutine(Speaking(speech, additive, speaker, dialogueDetails));
    }
Esempio n. 4
0
    /// <summary>
    /// Make this character say something.
    /// </summary>
    /// <param name="speech">Speech.</param>
    public void Say(string speech, bool add = false)
    {
        if (!enabled)
        {
            enabled = true;
        }

        if (!isInScene)
        {
            FadeIn();
        }

        //get the details for the dialogue system related to this character. details are saved on file.
        CharacterDialogueDetails.CDD c = CharacterDialogueDetails.instance.GetDetailsForCharacter(characterName);
        Debug.Log(characterName);

        dialogue.Say(speech, displayName, add, c);
    }