Ejemplo n.º 1
0
            IEnumerator Running()
            {
                //VariableManager.Inject(ref dialogue);

                string[] parts = dialogue.Split('[', ']');
                for (int i = 0; i < parts.Length; i++)
                {
                    bool isOdd = i % 2 != 0;
                    if (isOdd)
                    {
                        DialogueEvents.HandleEvent(parts[i], this);
                        allCurrentlyExecutedEvents.Add(parts[i]);
                        i++;
                    }

                    string targDialogue = parts[i];

                    VariableManager.Inject(ref targDialogue);


                    //Debug.Log("SAY THIS-" + targDialogue);
                    DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != "");


                    architect = DialogueSystem.instance.TextArchitect;
                    while (architect.isConstructing)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                running = null;
            }
Ejemplo n.º 2
0
    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();
    }
Ejemplo n.º 3
0
    IEnumerator Revealing()
    {
        banner.enabled    = true;
        titleText.enabled = true;
        switch (displayMethod)
        {
        case DISPLAY_METHOD.instant:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            break;

        case DISPLAY_METHOD.slowFade:
            banner.color    = GlobalF.SetAlpha(banner.color, 0);
            titleText.color = GlobalF.SetAlpha(titleText.color, 0);
            while (banner.color.a < 1)
            {
                banner.color    = GlobalF.SetAlpha(banner.color, Mathf.MoveTowards(banner.color.a, 1, fadeSpeed * Time.unscaledDeltaTime));
                titleText.color = GlobalF.SetAlpha(titleText.color, banner.color.a);
                yield return(new WaitForEndOfFrame());
            }
            break;

        case DISPLAY_METHOD.typeWriter:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            TextArchitect architect = new TextArchitect(titleText, title);
            while (architect.isConstructing)
            {
                yield return(new WaitForEndOfFrame());
            }
            break;
        }
        //title is displayed
        revealing = null;
    }
Ejemplo n.º 4
0
    IEnumerator typeWritter()
    {
        banner.color    = GlobalF.SetAlpha(banner.color, 1);
        titleText.color = GlobalF.SetAlpha(titleText.color, 1);
        TextArchitect architect = new TextArchitect(titleText, title);

        while (architect.isConstructing)
        {
            yield return(new WaitForEndOfFrame());
        }
    }
Ejemplo n.º 5
0
    void Initiate()
    {
        TextArchitect existingArchitect = null;

        if (activeArchitects.TryGetValue(tmpro, out existingArchitect))
        {
            existingArchitect.Terminate();
        }

        buildProcess = DIalogueSystem.instance.StartCoroutine(Construction());
        activeArchitects.Add(tmpro, this);
    }
Ejemplo n.º 6
0
    void Initiate()
    {
        //check if an architect for this text object is already running. if it is, terminate it. Do not allow more than one architect to affect the same text object at once.
        TextArchitect existingArchitect = null;

        if (activeArchitects.TryGetValue(tmpro, out existingArchitect))
        {
            existingArchitect.Terminate();
        }

        buildProcess = DialogueSystem.instance.StartCoroutine(Construction());
        activeArchitects.Add(tmpro, this);
    }
Ejemplo n.º 7
0
            IEnumerator Running()
            {
                allCurrentlyExecutedEvents.Clear();
                //take care of any tags that must be injected into the dialogue before we worry about events.

                TagManager.Inject(ref dialogue);

                //split the dialogue by the event characters.
                string[] parts = dialogue.Split('[', ']');

                for (int i = 0; i < parts.Length; i++)
                {
                    //events will always be odd indexed. Execute an event.
                    bool isOdd = i % 2 != 0;
                    if (isOdd)
                    {
                        DialogueEvents.HandleEvent(parts[i], this);
                        allCurrentlyExecutedEvents.Add(parts[i]);
                        i++;
                    }

                    string targDialogue = parts[i];

                    if (line.speaker != "narrator" && !line.speaker.Contains("*"))
                    {
                        print(line.speaker);
                        Character character = CharacterManager.instance.GetCharacter(line.speaker);
                        //This is a valid character that can show up on the screen. Get the character and make them speak.
                        //if (character != null)
                        character.Say(targDialogue, i > 0 ? true : pretext != "");
                        //This is a character that has no images to display. Only show the name and the dialogue.
                        //else
                        //DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != ""); does not work yet
                    }
                    else
                    {
                        DialogueSystem.instance.Say(targDialogue, line.speaker, i > 0 ? true : pretext != "");
                    }

                    //yield while the dialogue system's architect is constructing the dialogue.
                    architect = DialogueSystem.instance.currentArchitect; //TODO

                    while (architect.isConstructing)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }

                running = null;
            }
Ejemplo n.º 8
0
    private void StopSpeaking()
    {
        speechText.text = targetSpeech;

        if (isSpeaking)
        {
            StopCoroutine(speaking);
            speaking = null;
        }

        if (TextArchitect != null && TextArchitect.isConstructing)
        {
            TextArchitect.Stop();
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            architect = new TextArchitect(say, "", characterPerFrame, speed, useEncap, useTmpro);
        }

        if (useTmpro)
        {
            tmproText.text = architect.currentText;
        }
        else
        {
            text.text = architect.currentText;
        }
    }
Ejemplo n.º 10
0
    IEnumerator Speaking(string speech, bool additive, string speaker = "")
    {
        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 != "");

        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();
    }
Ejemplo n.º 11
0
    IEnumerator Speaking(string speech, bool additive, string speaker = "")
    {
        speechPanel.SetActive(true);

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

        targetSpeech = additiveSpeech + speech;

        if (textArchitect == null)
        {
            textArchitect = new TextArchitect(speechText, speech, additiveSpeech);
        }
        else
        {
            textArchitect.Renew(speech, additiveSpeech);
        }


        speakerNameText.text = DetermineSpeaker(speaker);        //temporary

        speakerNamePane.SetActive(speakerNameText.text != "");

        isWaitingForUserInput = false;

        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();
    }
Ejemplo n.º 12
0
    public IEnumerator Speaking(string speech, string speaker, bool additive)
    {
        speechPanel.SetActive(true);

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

        targetSpeech = preText + speech;

        if (TextArchitect == null)
        {
            TextArchitect = new TextArchitect(speechText, speech, preText, 1, speed);
        }
        else
        {
            TextArchitect.Renew(speech, preText);
        }

        speakerNameText.text = DetermineSpeaker(speaker);
        speakerPanel.SetActive(speakerNameText.text != "");

        isWaitingForUserInput = false;

        while (TextArchitect.isConstructing)
        {
            //if (Input.GetKeyDown(KeyCode.Space))
            //{
            //    TextArchitect.skip = true;
            //}

            yield return(new WaitForEndOfFrame());
        }

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

        StopSpeaking();
    }
Ejemplo n.º 13
0
            IEnumerator Running()
            {
                allCurrentlyExecutedEvents.Clear();
                TagManager.Inject(ref dialogue);
                string[] parts = dialogue.Split('[', ']');
                for (int i = 0; i < parts.Length; i++)
                {
                    bool isOdd = i % 2 != 0;
                    if (isOdd)
                    {
                        DialogueEvents.HandleEvents(parts[i], this);
                        allCurrentlyExecutedEvents.Add(parts[i]);
                        i++;
                    }

                    string targetDialogue = parts[i];
                    print("dialog = " + parts[i]);
                    if (line.speaker != "narator" && line.speaker != "MC")
                    {
                        Character character = CharacterManager.instance.GetCharacter(line.speaker);
                        character.say(targetDialogue, i > 0 ? true : pretext != "");
                    }
                    else if (line.speaker == "MC")
                    {
                        DIalogueSystem.instance.Say(targetDialogue, "Adovandria", i > 0 ? true : pretext != "");
                    }
                    else
                    {
                        DIalogueSystem.instance.Say(targetDialogue, line.speaker, i > 0 ? true : pretext != "");
                    }
                    architect = DIalogueSystem.instance.currentArchitect;

                    while (architect.isConstructing)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                running = null;
            }
Ejemplo n.º 14
0
    IEnumerator Speaking(string speech, bool additive, string speaker = "")
    {
        speechPanel.SetActive(true);

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

        targetSpeech = additiveSpeech + speech;


        TextArchitect textArchitect = new TextArchitect(speech, additiveSpeech);


        speakerNameText.text  = DetermineSpeaker(speaker);
        isWaitingForUserInput = false;


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

            speechText.text = textArchitect.currentText;


            yield return(new WaitForEndOfFrame());
        }
        //Is skipping prevented the display text from updating completely, force it to update.
        speechText.text = textArchitect.currentText;
        //text finished;
        isWaitingForUserInput = true;
        while (isWaitingForUserInput)
        {
            yield return(new WaitForEndOfFrame());
        }

        StopSpeaking();
    }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     architect = new TextArchitect(say, "", characterPerFrame, speed, useEncap, useTmpro);
 }