예제 #1
0
    public DialogueThread CurrentThread(List <SequenceCounter> phases)
    {
        // Find a thread that matches the first eligible phase.
        DialogueThread relevant = FindFirstRelevantPhase(phases);

        // Relevant thread still dosen't exist.  Just return an empty list.
        if (relevant == default(DialogueThread))
        {
            return(new DialogueThread());
        }

        relevant.CallingGameObject = gameObject;
        return(relevant);
    }
예제 #2
0
    private DialogueThread FindFirstRelevantPhase(List <SequenceCounter> phases)
    {
        DialogueThread relevant = default(DialogueThread);

        foreach (SequenceCounter phase in phases)
        {
            DialogueThread thread = NPCText.FirstOrDefault(t => t.EligibleForUse(phase));
            if (thread == default(DialogueThread))
            {
                if (DebugMode)
                {
                    Debug.Log("Phase " + phase + " will not be used...");
                }

                continue;
            }

            if (DebugMode)
            {
                Debug.Log("Found an eligible thread for dialogue phase " + phase);
            }
            relevant = thread;
            break;
        }

        if (relevant == default(DialogueThread))
        {
            if (DebugMode)
            {
                Debug.Log("Was unable to find a matching phase.  Using default dialogue instead...");
            }
            relevant = NPCText.FirstOrDefault(x => x.IsDefaultText == true);
        }

        if (relevant == default(DialogueThread))
        {
            Debug.LogError("Was unable to find default dialogue.  Revise this immediately!");
        }

        relevant.CallingGameObject = gameObject;
        return(relevant);
    }
예제 #3
0
    private void AcquireTextFromAvailableEntities()
    {
        EntityText availableEntity = _textProviders.FirstOrDefault(t => t.CanTalk == true);

        // Code Case: We no longer have an entity, but we still show there being dialogue.
        // User Case: Player has left a trigger with text still shown.
        // Desired Result: Stop showing text, reset line counter.
        if(availableEntity == default(EntityText)
           && DialogueAvailable)
        {
            _currentThread.ResetIndex();
            DialogueAvailable = false;
            HideElements();
        }
        // Code Case: We have an entity, and we do not see any current dialogue.
        // User Case: Player has initiated a conversation sequence.
        // Desired Result: Start showing text, set line counter to first item, set speaker name.
        //                 Also, lock the player's player control script.
        else if(availableEntity != default(EntityText)
                && (! DialogueAvailable))
        {
            _currentThread = availableEntity.CurrentThread(_ambassador.SequenceCounters);
            _currentThread.ResetIndex();

            DialogueText currentText = _currentThread.GetCurrentText();
            if(currentText != null)
            {
                PresentLine(currentText);
                DialogueAvailable = true;

                PlayerHasControl(false);
                ShowElements();
            }
        }

        // Code Case: We have both an entity and show dialogue
        // User Case: An conversation is on-going
        // Desired Result: Do not mess with it!

        // Code Case: We have no entity and show no dialogue [Default State]
        // User Case: User is doing some non-conversation activity
        // Desired Result: Do nothing.
    }
예제 #4
0
    private void AcquireTextFromAvailableEntities()
    {
        if (_textProviders == null ||
            _textProviders.Length == 0)
        {
            return;
        }

        EntityText availableEntity = _textProviders.FirstOrDefault(t => t.CanTalk == true);

        if (DebugMode)
        {
            Debug.Log("There is " + (availableEntity == default(EntityText) ? "no" : "an") + " NPC that can talk.");
        }

        // Code Case: We no longer have an entity, but we still show there being dialogue.
        // User Case: Player has left a trigger with text still shown.
        // Desired Result: Stop showing text, reset line counter.
        if (availableEntity == default(EntityText) &&
            DialogueAvailable)
        {
            if (DebugMode)
            {
                Debug.Log("User has left a text trigger, so hide text.");
            }

            _currentThread.ResetIndex();
            DialogueAvailable = false;
            HideElements();
        }
        // Code Case: We have an entity, and we do not see any current dialogue.
        // User Case: Player has initiated a conversation sequence.
        // Desired Result: Start showing text, set line counter to first item, set speaker name.
        //                 Also, lock the player's player control script.
        else if (availableEntity != default(EntityText) &&
                 (!DialogueAvailable))
        {
            if (DebugMode)
            {
                Debug.Log("Player has initiated a conversation.");
            }

            _currentThread = availableEntity.CurrentThread(_ambassador.SequenceCounters);
            _currentThread.ResetIndex();

            DialogueText currentText = _currentThread.GetCurrentText();
            if (currentText != null)
            {
                PresentLine(currentText);
                DialogueAvailable = true;

                PlayerHasControl(false);
                ShowElements();
            }
        }

        // Code Case: We have both an entity and show dialogue
        // User Case: An conversation is on-going
        // Desired Result: Do not mess with it!

        // Code Case: We have no entity and show no dialogue [Default State]
        // User Case: User is doing some non-conversation activity
        // Desired Result: Do nothing.
    }