private void VisitNode(DialogueData data, int childCount, TreeList <IDialogueContext> tree, List <IDialogueContext> contexts)
    {
        IDialogueContext context = data.GetDialogueContext();

        contexts.Add(context);
        tree.Insert(new TreeNode <IDialogueContext>(context, childCount));
    }
    public override void Speak(Conversation conversation, Speaker speaker)
    {
        RespondSpeaker respondSpeaker = (RespondSpeaker)speaker;

        if (respondSpeaker)
        {
            currentContext = respondSpeaker.Respond(type);
            currentContext.Speak(conversation, respondSpeaker);
        }
    }
 public void Next()
 {
     if (contexts.Count > 0)
     {
         IDialogueContext current = contexts.Dequeue();
         current.Speak(this, GetSpeaker(current));
     }
     else
     {
         Debug.Log("Conversation has no more contexts");
         ConversationMgr.Instance.EndConversation();
     }
 }
    private Speaker GetSpeaker(IDialogueContext context)
    {
        if (context.OnlyPlayer())
        {
            return(speakers[playerSpeaker]);
        }

        if (context.ProceedToNextSpeaker())
        {
            return(speakers[++currentSpeakerIndex % speakerCount]);
        }

        return(speakers[currentSpeakerIndex % speakerCount]);
    }
    private Speaker GetSpeaker(IDialogueContext context)
    {
        if (context.OnlyPlayer())
        {
            // If the current context also proceeds to next speaker then increment after returning the player speaker index.
            return(speakers[(context.ProceedToNextSpeaker()) ? playerSpeaker++ : playerSpeaker]);
        }

        if (context.ProceedToNextSpeaker())
        {
            return(speakers[currentSpeakerIndex++ % speakerCount]);
        }

        return(speakers[currentSpeakerIndex % speakerCount]);
    }
 public DialogueContextContainer(IDialogueContext context)
 {
     this.context     = context;
     this.nextContext = null;
 }
 public void EnqueueContext(IDialogueContext context)
 {
     contexts.Enqueue(context);
 }