예제 #1
0
    /// <summary>
    /// reads a new message in the chat
    /// </summary>
    /// <param name="_nextMessage"></param>
    void ReadNextMessage(int _message, ChatText _newText, Tab _currentTab)
    {
        if (_currentTab.tabChat.Count > _message)//check if there are any messages left in this conversation
        {
            if (_newText == null)
            {
                _newText = _currentTab.tabChat[_message];
            }


            for (int i = 0; i < _newText.chatText.Count; i++) //for each line in this message
            {
                if (i == 0)                                   //check if it is the 1st message so the name is added
                {
                    _currentTab.displayedText.Add("[" + _newText.characterName + "] " + _newText.chatText[i]);
                }
                else//dont add name
                {
                    _currentTab.displayedText.Add(_newText.chatText[i]);
                }


                //check if the scroll up is active
                if (!scrolling && currentChat == _currentTab.tabNum)
                {
                    GameObject newText = Instantiate(textPrefab, generalTextContainer.transform); //create a new line
                    if (i == 0)                                                                   //check if it is the 1st message so the name is added
                    {
                        newText.GetComponent <TextMeshProUGUI>().text = "[" + _newText.characterName + "] " + _newText.chatText[i];
                    }
                    else//dont add name
                    {
                        newText.GetComponent <TextMeshProUGUI>().text = _newText.chatText[i];
                    }
                    _currentTab.currentText += 1;
                    //chatNumb[0] += 1;//current chat possion

                    CheckOverflow(0);//check if overflow
                }
            }

            _currentTab.lastMessage = _newText;

            //check if it requires an awnser
            if (_newText.options.Count != 0)
            {
                if (currentChat == _currentTab.tabNum)//check if this is the active chat
                {
                    //set options
                    for (int i = 0; i < _newText.options.Count; i++)
                    {
                        optionsPanel.transform.GetChild(i).GetComponent <ChoiceController>().SetValues(tabs[currentChat].lastMessage.options[i]);
                    }
                }

                if (!scrolling && currentChat == _currentTab.tabNum)//show the options to pick if it is the active chat
                {
                    manager.ChatStartButton();
                }
                //wait for anwser
            }
            else
            {
                //start timer for next sentence
                StartCoroutine(WaitForNextSentence(_currentTab.tabChat[_message].timer, _currentTab, _message + 1, null));
            }
        }
    }
예제 #2
0
    /// <summary>
    /// reads a new message in the chat
    /// </summary>
    /// <param name="_nextMessage"></param>
    void ReadNextMessage(int _message, ChatText _newText, Tab _currentTab)
    {
        if (_newText != null)
        {
            //if its in say chat and has a speaker trigger the chat ballons
            if (!string.IsNullOrEmpty(_newText.speaker))
            {
                string textbubble = "";
                for (int i = 0; i < _newText.chatText.Count; i++)//for each line in this message
                {
                    textbubble += _newText.chatText[i] + "\n";
                }
                if (GameObject.Find(_newText.speaker))
                {
                    GameObject speakerObj = GameObject.Find(_newText.speaker);
                    speakerObj.transform.GetChild(0).GetComponent <NPCController>().SetChatBubble(textbubble);
                }
            }
        }



        if (_currentTab.tabChat.Count > _message)//check if there are any messages left in this conversation
        {
            if (_newText == null)
            {
                _newText = _currentTab.tabChat[_message];
            }


            for (int i = 0; i < _newText.chatText.Count; i++) //for each line in this message
            {
                if (i == 0)                                   //check if it is the 1st message so the name is added
                {
                    _currentTab.displayedText.Add("[" + _newText.characterName + "] " + _newText.chatText[i]);
                }
                else//dont add name
                {
                    _currentTab.displayedText.Add(_newText.chatText[i]);
                }


                //check if the scroll up is active
                if (!scrolling && currentChat == _currentTab.tabNum)
                {
                    GameObject newText = Instantiate(textPrefab, generalTextContainer.transform); //create a new line
                    if (i == 0)                                                                   //check if it is the 1st message so the name is added
                    {
                        newText.GetComponent <TextMeshProUGUI>().text = "[" + _newText.characterName + "] " + _newText.chatText[i];
                    }
                    else//dont add name
                    {
                        newText.GetComponent <TextMeshProUGUI>().text = _newText.chatText[i];
                    }
                    _currentTab.currentText += 1;
                    //chatNumb[0] += 1;//current chat possion

                    CheckOverflow(0);//check if overflow
                }
                else
                {
                    if (_currentTab.type != ChatType.chatPublic && _currentTab.type != ChatType.chatSay)
                    {
                        _currentTab.tabObj.GetComponent <TabController>().SomethingNew();
                    }
                }
            }

            _currentTab.lastMessage = _newText;

            //check if it requires an awnser
            if (_newText.options.Count != 0)
            {
                if (currentChat == _currentTab.tabNum)//check if this is the active chat
                {
                    //set options
                    for (int i = 0; i < _newText.options.Count; i++)
                    {
                        optionsPanel.transform.GetChild(i).GetComponent <ChoiceController>().SetValues(tabs[currentChat].lastMessage.options[i]);
                    }
                }

                if (!scrolling && currentChat == _currentTab.tabNum)//show the options to pick if it is the active chat
                {
                    manager.ChatStartButton();
                }
                //wait for anwser
            }
            else if (_newText.nextNpcText != null)
            {
                StartCoroutine(WaitForNextSentence(_newText.nextNpcText.timer, _currentTab, _currentTab.tabChat.Count - 1, _newText.nextNpcText));
            }
            else
            {
                //start timer for next sentence
                StartCoroutine(WaitForNextSentence(_currentTab.tabChat[_message].timer, _currentTab, _message + 1, null));
            }
        }
    }