private IEnumerator StartDialogue(string npcName, string flag)
        {
            _inDialogue = true;
            _eventHandler.onDialogueStart.Invoke();

            Dialogue dialogue = BuildDialogueWithFlag(npcName, flag);

            //Debug.Log($"Dialogue found:\n {dialogue.ToString()}");

            DialogueMenu.SetNamePlate(npcName);
            DialogueMenu.ShowDialogueWindow();

            //Debug.Log($"Show dialogue for {npcName}");

            while (dialogue.HasNextLine())
            {
                var newLine = dialogue.NextLine();

                StartCoroutine(DialogueMenu.PrintLineToBox(newLine));
                //Debug.Log($"Showing line: {newLine}");

                yield return(new WaitUntil(DialogueMenu.AtEndOfLine));

                yield return(new WaitUntil(() => GameManager.isPressingInteractButton));

                yield return(new WaitForEndOfFrame());
            }

            DialogueMenu.HideDialogueWindow();
            _eventHandler.onDialogueEnd.Invoke();
            //Debug.Log("Hide dialogue window.");
        }
Beispiel #2
0
        private void Awake()
        {
            _instance = this;

            onDialogueShown  = new UnityEvent();
            onDialogueHidden = new UnityEvent();
            onStartOfLine    = new UnityEvent();
            onEndOfLine      = new UnityEvent();
        }