void OnSubtitlesRequest(SubtitlesRequestInfo info)
 {
     if (info.actor.name.Equals(dialogActor.name))
     {
         StartCoroutine(Internal_OnSubtitlesRequestInfo(info));
     }
 }
Ejemplo n.º 2
0
        protected override void OnExecute()
        {
            var index         = Random.Range(0, statements.Count);
            var statement     = statements[index];
            var tempStatement = statement.BlackboardReplace(blackboard);
            var info          = new SubtitlesRequestInfo((IDialogueActor)agent, tempStatement, EndAction);

            DialogueTree.RequestSubtitles(info);
        }
        protected override void OnExecute()
        {
            var index           = Random.Range(0, statements.Count);
            var statement       = statements[index];
            var term            = terms[index];
            var termTranslation = languageSource.isNull ? LocalizationManager.GetTranslation(term) : languageSource.value.GetTranslation(term);

            statement.text = termTranslation;

            var tempStatement = statement.BlackboardReplace(blackboard);
            var info          = new SubtitlesRequestInfo(agent, tempStatement, EndAction);

            DialogueTree.RequestSubtitles(info);
        }
Ejemplo n.º 4
0
    IEnumerator Internal_OnSubtitlesRequestInfo(SubtitlesRequestInfo info)
    {
        var text  = info.statement.text;
        var audio = info.statement.audio;
        var actor = info.actor;

        /*subtitlesGroup.gameObject.SetActive(true);
         * actorSpeech.text = "";
         *
         * actorName.text = actor.name;
         * actorSpeech.color = actor.dialogueColor;
         *
         * actorPortrait.gameObject.SetActive( actor.portraitSprite != null );
         * actorPortrait.sprite = actor.portraitSprite;
         */
        var DS = dialogues[0];

        DS.gameObject.SetActive(true);
        TMP = DS.transform.GetComponentInChildren <TMPro.TextMeshPro>();
        //TMP.text = actor.name+"  "+text;
        TMP.text = "";
        int charAt = 0;

        while (charAt < text.Length)
        {
            TMP.text = TMP.text + text[charAt];
            charAt++;

            yield return(new WaitForSeconds(0.05f));
        }
        waitForInput = true;

        if (waitForInput)
        {
            //waitInputIndicator.gameObject.SetActive(true);
            while (!Input.GetMouseButtonDown(0))
            {
                yield return(null);
            }
            //waitInputIndicator.gameObject.SetActive(false);
        }

        //yield return null;
        //subtitlesGroup.gameObject.SetActive(false);
        info.Continue();
    }
Ejemplo n.º 5
0
        IEnumerator Internal_OnSubtitlesRequestInfo(SubtitlesRequestInfo info)
        {
            var text  = info.statement.text;
            var audio = info.statement.audio;
            var actor = info.actor;

            subtitlesGroup.gameObject.SetActive(true);
            actorSpeech.text = "";

            actorName.text    = actor.name;
            actorSpeech.color = actor.dialogueColor;

            actorPortrait.gameObject.SetActive(actor.portraitSprite != null);
            actorPortrait.sprite = actor.portraitSprite;

            if (audio != null)
            {
                var actorSource = actor.transform != null?actor.transform.GetComponent <AudioSource>() : null;

                var playSource = actorSource != null? actorSource : localSource;
                playSource.clip = audio;
                playSource.Play();
                actorSpeech.text = text;
                var timer = 0f;
                while (timer < audio.length)
                {
                    if (skipOnInput && Input.anyKeyDown)
                    {
                        playSource.Stop();
                        break;
                    }
                    timer += Time.deltaTime;
                    yield return(null);
                }
            }

            if (audio == null)
            {
                var tempText  = "";
                var inputDown = false;
                if (skipOnInput)
                {
                    StartCoroutine(CheckInput(() => { inputDown = true; }));
                }

                for (int i = 0; i < text.Length; i++)
                {
                    if (skipOnInput && inputDown)
                    {
                        actorSpeech.text = text;
                        yield return(null);

                        break;
                    }

                    if (subtitlesGroup.gameObject.activeSelf == false)
                    {
                        yield break;
                    }

                    char c = text[i];
                    tempText += c;
                    yield return(StartCoroutine(DelayPrint(subtitleDelays.characterDelay)));

                    PlayTypeSound();
                    if (c == '.' || c == '!' || c == '?')
                    {
                        yield return(StartCoroutine(DelayPrint(subtitleDelays.sentenceDelay)));

                        PlayTypeSound();
                    }
                    if (c == ',')
                    {
                        yield return(StartCoroutine(DelayPrint(subtitleDelays.commaDelay)));

                        PlayTypeSound();
                    }

                    actorSpeech.text = tempText;
                }

                if (!waitForInput)
                {
                    yield return(StartCoroutine(DelayPrint(subtitleDelays.finalDelay)));
                }
            }

            if (waitForInput)
            {
                waitInputIndicator.gameObject.SetActive(true);
                while (!Input.anyKeyDown)
                {
                    yield return(null);
                }
                waitInputIndicator.gameObject.SetActive(false);
            }

            yield return(null);

            subtitlesGroup.gameObject.SetActive(false);
            info.Continue();
        }
Ejemplo n.º 6
0
 void OnSubtitlesRequest(SubtitlesRequestInfo info)
 {
     StartCoroutine(Internal_OnSubtitlesRequestInfo(info));
 }
 //Function with same name as the event is called when the event is dispatched by the Dialogue Tree
 void OnSubtitlesRequest(SubtitlesRequestInfo info)
 {
     enabled      = true;
     currentActor = info.actor;
     StatementProcessor.ProcessStatement(info.statement, info.actor, info.Continue);
 }
Ejemplo n.º 8
0
        protected override void OnExecute()
        {
            var info = new SubtitlesRequestInfo((IDialogueActor)agent, statement, EndAction);

            DialogueTree.RequestSubtitles(info);
        }
		//Function with same name as the event is called when the event is dispatched by the Dialogue Tree
		void OnSubtitlesRequest(SubtitlesRequestInfo info){
			
			enabled = true;
			currentActor = info.actor;
			StatementProcessor.ProcessStatement(info.statement, info.actor, info.Continue);
		}