Beispiel #1
0
    /**
     * update the speaking function
     */
    private void updateSpeaking()
    {
        // nothing to speak or cannot speak?
        if ((m_currentSpokenText == null && m_speakingQueue.Count == 0) || m_textDisplayScript == null)
        {
            return;
        }

        // update the position from the current
        if (m_lastSpeakingTimeStamp + MAXIMAL_SPEAKING_TIME > Time.time)
        {
            if (m_mainCamera != null && m_currentSpokenText != null)
            {
                m_currentSpokenText.position = m_mainCamera.WorldToScreenPoint(this.transform.position + new Vector3(0, m_realAntonioHeight, 0));
            }
            return;
        }

        // destroy the current spoken text if necessary?
        if (m_currentSpokenText != null)
        {
            Destroy(m_currentSpokenText.gameObject);
            m_currentSpokenText = null;
        }

        // must speak something?
        if (m_speakingQueue.Count != 0)
        {
            m_currentSpokenText     = m_textDisplayScript.createNewSpokenText(m_speakingQueue.Dequeue(), this.transform.position);
            m_lastSpeakingTimeStamp = Time.time;
        }
    }
Beispiel #2
0
    /**
     * Handles the timing and displaying of the text-parts.
     * Returns true to indicate new text is available to be handled, otherwise false
     */
    private bool onNextTextPart()
    {
        // Local variables
        TextPart part = null;

        // Increase index
        ++m_currentTextPartIndex;

        // Reached or hidden?
        if ((m_text.IsShowParts == false || m_currentTextPartIndex >= m_text.TextPartCount) && m_isHandleNextTextPart == true)
        {
            // Display choices
            if (onDisplayChoices() == false)
            {
                // Auto generated/executed choice available
                if (m_text.AutoChoiceType != DialogueText.ChoiceType.CHOICE_NONE)
                {
                    // Exit?
                    if (m_text.AutoChoiceType == DialogueText.ChoiceType.CHOICE_EXIT)
                    {
                        onConversationExit(m_text.ExitValue);
                    }
                    else
                    {
                        if (!setTextByID(m_text.NextTextID))
                        {
                            onConversationExit(AdvancedDialogue.DIALOGUE_NO_CHOICE_EXIT_VALUE);
                        }
                        else
                        {
                            return(true);
                        }
                    }

                    return(false);
                }

                // No choices available!
                onConversationExit(AdvancedDialogue.DIALOGUE_NO_CHOICE_EXIT_VALUE);
            }
            return(false);
        }

        // Get text part
        part = m_text.getTextPartByIndex(m_currentTextPartIndex);

        // Show text
        if (m_currentOnScreenTextObject != null)
        {
            GameObject.Destroy(m_currentOnScreenTextObject.gameObject);
            m_currentOnScreenTextObject = null;
        }
        m_currentOnScreenTextObject = m_window.createNewSpokenText("<size=18><color=silver><b>" + part.Character + ":</b></color></size> " + part.Text, Vector3.zero);

        // Create timer
        if (m_timer != null)
        {
            m_timer.Stop();
            m_timer = null;
        }
        m_timer           = new Timer(part.DisplayTime * 1000);
        m_timer.Enabled   = true;
        m_timer.AutoReset = false;
        m_timer.Elapsed  += (object _s, ElapsedEventArgs _e) => { m_isHandleNextTextPart = true; };

        return(false);
    }