Esempio n. 1
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);
 }
Esempio n. 2
0
 ///Raise the OnSubtitlesRequest event
 public static void RequestSubtitles(SubtitlesRequestInfo info)
 {
     if (OnSubtitlesRequest != null)
     {
         OnSubtitlesRequest(info);
     }
     else
     {
         Logger.LogWarning("Subtitle Request event has no subscribers. Make sure to add the default '@DialogueGUI' prefab or create your own GUI.", "Dialogue Tree");
     }
 }
Esempio n. 3
0
        void OnOptionSelected(int index)
        {
            status = Status.Success;

            System.Action Finalize = ()=> { DLGTree.Continue(index); };

            if (saySelection){
                var tempStatement = availableChoices[index].statement.BlackboardReplace(graphBlackboard);
                var speechInfo = new SubtitlesRequestInfo( finalActor, tempStatement, Finalize );
                DialogueTree.RequestSubtitles(speechInfo);
            } else {
                Finalize();
            }
        }
        void OnOptionSelected(int index)
        {
            status = Status.Success;

            System.Action Finalize = () => { DLGTree.Continue(index); };

            if (saySelection)
            {
                var tempStatement = availableChoices[index].statement.BlackboardReplace(graphBlackboard);
                var speechInfo    = new SubtitlesRequestInfo(finalActor, tempStatement, Finalize);
                DialogueTree.RequestSubtitles(speechInfo);
            }
            else
            {
                Finalize();
            }
        }
Esempio n. 5
0
 protected override void OnExecute()
 {
     var info = new SubtitlesRequestInfo( (IDialogueActor)agent, statement, EndAction );
     DialogueTree.RequestSubtitles(info);
 }
		///Raise the OnSubtitlesRequest event
		public static void RequestSubtitles(SubtitlesRequestInfo info){
			if (OnSubtitlesRequest != null)
				OnSubtitlesRequest(info);
			else Debug.LogWarning("<b>DialogueTree:</b> Subtitle Request event has no subscribers. Make sure to add the default '@DialogueGUI' prefab or create your own GUI.");
		}
Esempio n. 7
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;
                    }

                    tempText += text[i];
                    yield return StartCoroutine(DelayPrint(subtitleDelays.characterDelay));
                    char c = text[i];
                    if (c == '.' || c == '!' || c == '?'){
                        yield return StartCoroutine(DelayPrint(subtitleDelays.sentenceDelay));
                    }
                    if (c == ','){
                        yield return StartCoroutine(DelayPrint(subtitleDelays.commaDelay));
                    }

                    actorSpeech.text = tempText;
                }

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

            if (waitForInput){
                while(!Input.anyKeyDown){
                    yield return null;
                }
            }

            yield return null;
            subtitlesGroup.gameObject.SetActive(false);
            info.Continue();
        }
Esempio n. 8
0
 void OnSubtitlesRequest(SubtitlesRequestInfo info)
 {
     StartCoroutine(Internal_OnSubtitlesRequestInfo(info));
 }