Esempio n. 1
0
 void BeginMessaging(NarratorTrigger nt)
 {
     activeMessager    = nt;
     timer             = 0;
     messageIndex      = 0;
     narratorText.text = "";
     currentMessage    = nt.GetNextMessage().ToCharArray();
 }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            UI.AdvanceNarrative();
        }

        levelTime += Time.deltaTime;
        if (levelTime < START_WAIT)
        {
            return;
        }

        foreach (NarratorTrigger nt in nts)
        {
            if (nt != activeMessager && nt.CanTrigger())
            {
                BeginMessaging(nt);
            }
        }

        if (activeMessager != null && messageIndex >= 0 && (timer += Time.deltaTime) < TEXT_PRINT_RATE)
        {
            timer = 0;
            if (messageIndex < currentMessage.Length)
            {
                narratorText.text += currentMessage [messageIndex++];
            }
            else if ((currentMessage = activeMessager.GetNextMessage().ToCharArray()).Length > 0)
            {
                UI.ToggleContinueButton(true);
                messageIndex = -1;
            }
            else
            {
                EndMessaging();
            }
        }
    }