示例#1
0
        /// <summary>
        /// Returns a SayDialog by searching for one in the scene or creating one if none exists.
        /// </summary>
        public static SayDialog GetSayDialog()
        {
            if (ActiveSayDialog == null)
            {
                SayDialog sd = null;

                // Use first active Say Dialog in the scene (if any)
                if (activeSayDialogs.Count > 0)
                {
                    sd = activeSayDialogs[0];
                }

                if (sd != null)
                {
                    ActiveSayDialog = sd;
                }

                if (ActiveSayDialog == null)
                {
                    // Auto spawn a say dialog object from the prefab
                    GameObject prefab = Resources.Load <GameObject>("Prefabs/SayDialog");
                    if (prefab != null)
                    {
                        GameObject go = Instantiate(prefab) as GameObject;
                        go.SetActive(false);
                        go.name         = "SayDialog";
                        ActiveSayDialog = go.GetComponent <SayDialog>();
                    }
                }
            }

            return(ActiveSayDialog);
        }
示例#2
0
        /// <summary>
        /// Hides any currently displayed Say Dialog.
        /// </summary>
        public virtual void HideSayDialog()
        {
            var sayDialog = SayDialog.GetSayDialog();

            if (sayDialog != null)
            {
                sayDialog.FadeWhenDone = true;
            }
        }
示例#3
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            // Override the active say dialog if needed
            if (character != null && character.SetSayDialog != null)
            {
                SayDialog.ActiveSayDialog = character.SetSayDialog;
            }

            if (setSayDialog != null)
            {
                SayDialog.ActiveSayDialog = setSayDialog;
            }

            var sayDialog = SayDialog.GetSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            var flowchart = GetFlowchart();

            sayDialog.SetActive(true);

            sayDialog.SetCharacter(character);
            sayDialog.SetCharacterImage(portrait);

            string displayText = storyText;

            var activeCustomTags = CustomTag.activeCustomTags;

            for (int i = 0; i < activeCustomTags.Count; i++)
            {
                var ct = activeCustomTags[i];
                displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith);
                if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "")
                {
                    displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith);
                }
            }

            string subbedText = flowchart.SubstituteVariables(displayText);

            sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate {
                Continue();
            });
        }
示例#4
0
        public override void OnStopExecuting()
        {
            var sayDialog = SayDialog.GetSayDialog();

            if (sayDialog == null)
            {
                return;
            }

            sayDialog.Stop();
        }
示例#5
0
        protected virtual SayDialog GetSayDialog(Character character)
        {
            SayDialog sayDialog = null;

            if (character != null)
            {
                if (character.SetSayDialog != null)
                {
                    sayDialog = character.SetSayDialog;
                }
            }

            if (sayDialog == null)
            {
                sayDialog = SayDialog.GetSayDialog();
            }

            return(sayDialog);
        }
示例#6
0
 /// <summary>
 /// Returns the current say dialog.
 /// </summary>
 public virtual SayDialog GetSayDialog()
 {
     return(SayDialog.GetSayDialog());
 }
示例#7
0
 /// <summary>
 /// Sync the active say dialog with what Lua thinks the SayDialog should be
 /// </summary>
 public virtual void SetSayDialog(SayDialog sayDialog)
 {
     SayDialog.ActiveSayDialog = sayDialog;
 }