Ejemplo n.º 1
0
    private void UpdatePassiveDialogue()
    {
        DialogueData dialogue;

        m_dialogueAsset.m_dialogueData.TryGetValue(m_currentDialogueIndex, out dialogue);
        CharacterComponent characterComp;

        m_dialogueAsset.m_characterData.TryGetValue(dialogue.characterName, out characterComp);

        if (nextDialogue)
        {
            if (!dialogue.m_isStartNode && !dialogue.m_isEventNode)
            {
                Vector3 dialoguePosition = characterComp.GetCurrentOffset();

                // do all the actions for the current dialogue
                m_textDisplay.DisplayPassiveBubble(true, characterComp.GetCurrentBubblePos());
                m_textDisplay.Display(dialogue.dialogueText, dialoguePosition);

                //character comp related actions
                characterComp.OnCharacterTalk(dialogue.GetDialogueTextWithoutTags());
                SetAllCharacterEmotions(dialogue);
                nextDialogue = false;
            }
            else
            {
                if (dialogue.isConditionalBranching)
                {
                    m_currentDialogueIndex = CheckDialogueConditions(dialogue);
                    nextDialogue           = true;
                }
                else if (dialogue.m_nextDialogueData.Count == 1)
                {
                    m_currentDialogueIndex = dialogue.m_nextDialogueData[0];
                    nextDialogue           = true;
                }
                else if (dialogue.m_nextDialogueData.Count > 1)
                {
                    // display all branching options
                    DisplayDialogueOptions(dialogue.m_nextDialogueData);
                    nextDialogue = false;
                }
                else if (dialogue.m_nextDialogueData.Count == 0)
                {
                    isActive = false;
                    currentActiveDialogue = null;
                    m_textDisplay.DisplayPassiveBubble(false, new Vector3(0, 0, 0));
                    OnDialogueComplete();
                }
            }

            UpdateInventory(dialogue);
            UpdateQuests(dialogue);
            for (int i = 0; i < dialogue.eventObjects.Count; ++i)
            {
                dialogue.eventObjects[i].SendMessage(dialogue.eventFunctions[i]);
            }
        }


        bool isNextDialogueButtonPressed = Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Mouse0);

        if (isNextDialogueButtonPressed && !m_textDisplay.iSDone())
        {
            Vector3 dialoguePosition = characterComp.GetCurrentOffset();
            m_textDisplay.StopTypeWriterEffect();
            m_textDisplay.ClearDisplay();
            m_textDisplay.AddToDisplayImmediate(dialogue.dialogueText, dialoguePosition);
            return;
        }
        if (isNextDialogueButtonPressed && m_textDisplay.iSDone())
        {
            m_textDisplay.ClearDisplay();

            // next dialogue is not branching
            if (dialogue.m_nextDialogueData.Count == 1)
            {
                m_currentDialogueIndex = dialogue.m_nextDialogueData[0];
                hasPlayerOptions       = false;
                nextDialogue           = true;
            }
            // next dialogue is branching
            else if (dialogue.m_nextDialogueData.Count > 1)
            {
                if (dialogue.isConditionalBranching)
                {
                    m_currentDialogueIndex = CheckDialogueConditions(dialogue);
                    nextDialogue           = true;
                }
            }

            // dialogue is now complete
            if (dialogue.m_nextDialogueData.Count == 0)
            {
                isActive = false;
                currentActiveDialogue = null;
                m_textDisplay.DisplayPassiveBubble(false, new Vector3(0, 0, 0));
                OnDialogueComplete();
            }
        }
    }