Exemplo n.º 1
0
 private void ShowSayMenu(bool flag)
 {
     LongList.Clear();
     LongList.HideSayDialog();
     LongList.SetActive(flag);
     ListBottomPanel.gameObject.SetActive(false);      // всегда выключен для диалога
 }
 private void Narrate()
 {
     if (story.canContinue || loading)
     {
         foreach (Flag flag in flags.Values)
         {
             flag.Reset();
         }
         if (!loading)
         {
             story.Continue();
             if (beforeFirstSync)
             {
                 SyncAllVariablesToFungus();
                 beforeFirstSync = false;
             }
         }
         string line = story.currentText;
         Debug.Log("»" + line);
         ProcessTags(story.currentTags);
         bool   verbatim   = flags["verbatim"].Get();
         Match  dialogLine = null;
         Sprite portrait   = null;
         if (!verbatim)
         {
             dialogLine = compiledDialogRegex.Match(line);
             if (!dialogLine.Success)
             {
                 verbatim = true;
             }
         }
         if (!verbatim)
         {
             line = dialogLine.Groups["text"].Value;
             string character = dialogLine.Groups["character"].Value;
             if (characters.ContainsKey(character))
             {
                 Character speaker      = characters[character];
                 string    portraitName = (dialogLine.Groups["portrait"].Success) ?
                                          dialogLine.Groups["portrait"].Value : null;
                 portrait = FindPortrait(speaker, portraitName);
                 sayDialog.SetCharacter(speaker);
             }
             else
             {
                 sayDialog.SetCharacterName(character, defaultCharacterColor);
             }
         }
         else
         {
             sayDialog.SetCharacterName("", defaultCharacterColor);
         }
         sayDialog.SetCharacterImage(portrait);
         Action nextStep;
         bool   fadeWhenDone;
         if (pauseTime > 0)
         {
             fadeWhenDone = true;
             nextStep     = Idle;
         }
         else
         {
             fadeWhenDone = false;
             nextStep     = Narrate;
         }
         narrationHandle++;
         int    originalNarrationHandle = narrationHandle;
         Action onSayComplete           = delegate()
         {
             if (IsNarrationAt(originalNarrationHandle))
             {
                 nextStep();
             }
             else
             {
                 Debug.Log("Discarding orphan action associated with expired narration handle " + originalNarrationHandle);
             }
         };
         StartCoroutine(sayDialog.DoSay(line, true, !flags["auto"].Get(), fadeWhenDone, true, true, null, onSayComplete));
         AutoSave();
     }
     else
     {
         List <Choice> choices = story.currentChoices;
         if (choices.Count == 0)
         {
             Debug.LogWarning("Story reached a stop");
         }
         else
         {
             menuDialog.SetActive(true);
             menuDialog.Clear();
             if (flags["hide"].Get())
             {
                 menuDialog.HideSayDialog();
             }
             foreach (Choice choice in choices)
             {
                 int    choiceIndex = choice.index;
                 string line        = choice.text;
                 Debug.Log(choiceIndex + "»" + line);
                 Block callbackBlock = gatewayFlowchart.FindBlock("Choose " + choiceIndex);
                 if (callbackBlock == null)
                 {
                     Debug.LogError("Choice block #" + choice.index + " does not exist in the Gateway Flowchart");
                 }
                 Match dialogLine = null;
                 if (!flags["verbatim"].Get())
                 {
                     dialogLine = compiledDialogRegex.Match(line);
                     if (dialogLine.Success)
                     {
                         line = dialogLine.Groups["text"].Value;
                     }
                 }
                 menuDialog.AddOption(line, true, false, callbackBlock);
                 if (choice == choices[0] && flags["timer"].Get())
                 {
                     menuDialog.ShowTimer(choiceTime, callbackBlock);
                 }
             }
         }
     }
 }