コード例 #1
0
    // ------------------------------------------------------------------------
    // selected a chat option
    public void SelectOption(MessageSO message, int selection)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            return;
        }

        //Debug.Log("selected option " + selection + " for message " + message.Node);

        // record in message that this option has been chosen
        message.SelectOption(message.Branch[selection]);

        // run chosen message
        m_RunBubblesCoroutine = RunChatBubbles(message);
        StartCoroutine(m_RunBubblesCoroutine);

        // tell game controller about message type
        GameController.RecordDialogueChoice(message.MessageTypes[selection]);

        // fire events
        SelectedOption();

        // run next chat
        MoveConversation();
    }
コード例 #2
0
    // ------------------------------------------------------------------------
    private void RunChatOptions(MessageSO message)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            return;
        }
        if (!message.Player)
        {
            Debug.LogError("Hecked up message data. NPC has chat options.");
            return;
        }
        if (!message.HasOptions)
        {
            Debug.LogError("Attempting to draw options for message with no options.");
            return;
        }

        //Debug.Log("running chat options: " + message.Node);

        for (int i = 0; i < message.Options.Length; i++)
        {
            VisitedOption(message, i);
        }
    }
コード例 #3
0
    // ------------------------------------------------------------------------
    // actually does the waiting to create delay between messages
    private IEnumerator RunChatBubbles(MessageSO message, int index = 0)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            yield break;
        }

        //Debug.Log("running chat bubble: " + message.Node);

        // visit all of the messages in this node
        for (int i = index; i < message.Messages.Length; i++)
        {
            //Debug.Log("visited message: " + message.Node + "." + i);
            m_nextMessageIndex = i + 1;

            VisitedMessage(message, i);

            float t = 6;
            if (message.Delays != null && i < message.Delays.Length)
            {
                t = message.Delays[i];
            }

            yield return(new WaitForSeconds(t));
        }
    }
コード例 #4
0
    // ------------------------------------------------------------------------
    private IEnumerator RunMessage(MessageSO message)
    {
        if (message == null)
        {
            Debug.LogError("Message null.");
            yield break;
        }

        //Debug.Log("running message: " + message.Node);

        m_lastMessage = message;

        // draw either player or friend messages
        if (message.Player)
        {
            RunChatOptions(message);
        }
        else
        {
            m_RunBubblesCoroutine = RunChatBubbles(message);
            yield return(StartCoroutine(m_RunBubblesCoroutine));
        }

        // if we're not waiting on an option selection, draw the next message
        if (!message.HasOptions)
        {
            MoveConversation();
        }
    }
コード例 #5
0
    // ------------------------------------------------------------------------
    // Functions
    // ------------------------------------------------------------------------
    public void Setup(
        MessageSO message,
        int index,
        ChatRunner chatRunner
        )
    {
        Text.text = message.Options[index];

        Button.onClick.AddListener(
            delegate { chatRunner.SelectOption(message, index); }
            );
    }
コード例 #6
0
ファイル: ChatUI.cs プロジェクト: lindenreid/ggj20
    // ------------------------------------------------------------------------
    private void DrawChatOptionBubble(MessageSO message, int option)
    {
        FireOpened();

        SpiritChatParent.SetActive(false);
        PlayerChatParent.SetActive(true);
        SpiritIcon.gameObject.SetActive(true);

        GameObject bubble =
            Instantiate(MessageOptionPrefab, MessageOptionsParent)
            as GameObject;

        MessageOptionUI ui = bubble.GetComponent <MessageOptionUI>();

        Assert.IsNotNull(ui, "MessageOptionUI null.");
        ui.Setup(message, option, ChatRunner);
    }
コード例 #7
0
ファイル: ChatUI.cs プロジェクト: lindenreid/ggj20
    // ------------------------------------------------------------------------
    private void DrawChatBubble(MessageSO message, int index)
    {
        FireOpened();

        SpiritChatParent.SetActive(true);
        PlayerChatParent.SetActive(false);
        SpiritIcon.gameObject.SetActive(true);

        SpiritSO spirit = ChatRunner.ActiveChat.SpiritSO;

        SpiritIcon.sprite = spirit.Icon;
        SpiritIcon.SetNativeSize();
        SpiritIcon.rectTransform.sizeDelta *= SpritIconSize;

        SpiritName.text = spirit.Name;
        SpiritText.text = message.Messages[index];
    }
コード例 #8
0
    // ------------------------------------------------------------------------
    public void MoveConversation()
    {
        if (m_activeChat == null)
        {
            Debug.Log("Trying to move in conversation that hasn't been set.");
            return;
        }

        // find next message in convo (if this isn't a leaf)
        if (!m_lastMessage.IsLeafMessage)
        {
            MessageSO nextMessage = null;
            // find the next message's node
            if (m_lastMessage.Selection != null)
            {
                nextMessage = m_lastMessage.Selection;
            }
            else
            {
                nextMessage = m_lastMessage.Branch[0];
            }

            // run it
            if (nextMessage != null)
            {
                m_RunMessageCoroutine = RunMessage(nextMessage);
                StartCoroutine(m_RunMessageCoroutine);
            }
            else
            {
                Debug.LogError("Could not find next message from node " + m_lastMessage.Node);
            }
        }
        else
        {
            // if this is a leaf node, send leaf node event
            // don't run more messages
            FinishChat();
        }
    }
コード例 #9
0
 // ------------------------------------------------------------------------
 public void SelectOption(MessageSO option)
 {
     Selection = option;
 }
コード例 #10
0
 // ------------------------------------------------------------------------
 // Functions
 // ------------------------------------------------------------------------
 public void Reset()
 {
     Selection = null;
 }
コード例 #11
0
 // ------------------------------------------------------------------------
 // Functions
 // ------------------------------------------------------------------------
 public void Reset()
 {
     m_nextMessageIndex  = 0;
     m_waitingForGameEnd = false;
     m_lastMessage       = null;
 }