コード例 #1
0
    public void OnMouseExit()
    {
        if (this.enabled)
        {
            ConversationTrigger.RemoveToken(displayTokens[0]);
            if (displayTokens.Length > 1)
            {
                ConversationTrigger.RemoveToken(displayTokens[1]);
            }

            ConversationController.Disable();
        }
    }
コード例 #2
0
 public void disableTooltips()
 {
     allTooltips = FindObjectsOfType <Tooltip>();
     for (int i = 0; i < allTooltips.Length; i++)
     {
         allTooltips[i].enabled = false;
         for (int t = 0; t < allTooltips[i].displayTokens.Length; t++)
         {
             ConversationTrigger.RemoveToken(allTooltips[i].displayTokens[t]);
         }
     }
     // makes any currently displayed tooltip go away
     ConversationController.Disable();
 }
コード例 #3
0
    void Update()
    {
        // Skipping line scrolling or advancing a conversation.
        if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) || !enableScroll)
        {
            if (scrolling)
            {
                if (enableScroll)
                {   // only make the "boop" sound if this is regular scrolling text - with tooltips it gets annoying
                    audioSource.PlayOneShot(scrollTextSound);
                }
                EnableLetters();                        // Enable everything, thereby skipping the scrolling effect.
                numScrolled = letters.Length;
            }
            else if (conversationMode && conversationIdx < conversation.Length - 1)
            {
                //Debug.Log("Going to next line");
                conversationIdx++;                                              // Go to the next line.
                textBase.text = conversation[conversationIdx];                  // Set that line.
                scrollTimer   = 0f;                                             // Reset scroll timer to allow another line to scroll in.
                numScrolled   = 0;                                              // Reset numScrolled for fresh state.

                nextLine = true;                                                // This pokes LateUpdate, asking it to re-grab the text images.
            }
            else
            {
                // This else clause is for when we reach the end of a conversation. 0 choices means end, 1 choice means direct link, 2+ choices means show choices.
                if (ConversationController.currentlyEnabled)
                {
                    switch (choices.Length)
                    {
                    case 0:
                        // Apply the nowhere conversation to safely end the conversation.
                        if (enableScroll)
                        {
                            ConversationController.Disable();
                        }
                        break;

                    case 1:
                        // Apply the conversation relating to the only choice.
                        // Also make sure to add any token which may be a part of this single choice.
                        ApplyConversation(ConversationsDB.convos[choiceConvoPointers[0]]);
                        //Debug.Log("Adding token: " + choiceTokens[0]);
                        ConversationTrigger.AddToken(choiceTokens[0]);
                        break;

                    default:
                        // More than 1 choice, so show them.
                        ShowChoices();
                        break;
                    }
                }
            }
        }
        // Update Timer
        scrollTimer += Time.deltaTime;

        // Scrolling text effect.
        if (scrollTimer >= (numScrolled + 1) * letterDelay && numScrolled < letters.Length && !initializing && !nextLine)
        {
            //Debug.Log("Scrolling");
            scrolling = true;

            if (letters[numScrolled] != null)
            {
                letters[numScrolled].enabled = true;
            }

            numScrolled++;
            audioSource.PlayOneShot(scrollLetterSound);
        }
        // Keep track of whether text is currently scrolling or not.
        if (!initializing && numScrolled >= letters.Length)
        {
            scrolling = false;
        }
    }