예제 #1
0
    public static void PlayPortraitAnim(GameObject game)
    {
        Fungus.DialogPortrait dialogPortrait = game.GetComponent <Fungus.DialogPortrait>();

        Fungus.PortraitPresetData portraitPresetData = dialogPortrait.GetPresetData();
        if (portraitPresetData.animPresets.Length > 0)
        {
            Fungus.PortraitAnimClip[] clips = portraitPresetData.animPresets[1].clips;
            dialogPortrait.PlayAnim(clips);
            dialogPortrait.CurAlpha = 1;
        }

        UnityEngine.UI.GraphicRaycaster ray = game.GetComponent <UnityEngine.UI.GraphicRaycaster>();
        if (ray != null)
        {
            ray.enabled = false;
        }
    }
예제 #2
0
        // Start is called before the first frame update
        void OnEnable()
        {
            dp = GetComponent <DialogPortrait>();
            if (dp == null || dp.charLayers == null)
            {
                enabled = false;
                return;
            }
            int layerCount = dp.charLayers.Length;

            if (layerCount < 1)
            {
                enabled = false;
                return;
            }
            if (clips == null || clips.Length != layerCount)
            {
                clips = new PortraitAnimClip[layerCount];
            }
            if (clips != null && clips.Length > 0)
            {
                runtimeInfo = new AnimClipRuntimeInfo[clips.Length];
            }
        }
예제 #3
0
파일: Say.cs 프로젝트: atom-chen/UIDesigner
        public override void OnEnter()
        {
            if (needName && StorySystem.StoryDataUtilities.StoryUserName != null)
            {
                storyText = storyText.Insert(AfterHowManyNumber, StorySystem.StoryDataUtilities.StoryUserName);
            }

            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;
            }

            DialogPortrait diaPortrait = null;

            int[] diaPLayerSetting      = null;
            PortraitAnimClip[] animInfo = null;
            if (character != null && character.displayPortrait != null)
            {
                diaPortrait = character.displayPortrait;
            }

            if (diaPortrait != null)
            {
                diaPLayerSetting = new int[diaPortrait.charLayers.Length];
                var   presetData   = diaPortrait.GetPresetData();
                int[] layerSetting = null;
                if (portraitPresetIndex >= 0 &&
                    presetData != null &&
                    presetData.portraitPresets != null &&
                    presetData.portraitPresets.Length > portraitPresetIndex
                    )
                {
                    layerSetting = presetData.portraitPresets[portraitPresetIndex].spIndexes;
                }
                else
                {
                    layerSetting = portraitLayerSetting;
                }

                int overwriteSettingMax = layerSetting.Length;
                for (int i = 0; i < diaPLayerSetting.Length; i++)
                {
                    if (i < overwriteSettingMax)
                    {
                        diaPLayerSetting[i] = (layerSetting[i] >= 0) ? layerSetting[i] : character.defaultProtraitLayerSetting[i];
                    }
                    else
                    {
                        diaPLayerSetting[i] = layerSetting[i];
                    }
                }

                if (animPressetIndex >= 0 &&
                    presetData != null &&
                    presetData.animPresets != null &&
                    presetData.animPresets.Length > animPressetIndex
                    )
                {
                    animInfo = presetData.animPresets[animPressetIndex].clips;
                }
                else
                {
                    animInfo = animClips;
                }
            }

            DialogPortrait.ActivePortrait = diaPortrait;
            if (diaPortrait != null)
            {
                if (diaPLayerSetting != null && diaPLayerSetting.Length > 0)
                {
                    for (int i = 0; i < diaPLayerSetting.Length; i++)
                    {
                        diaPortrait.SetSprite(i, diaPLayerSetting[i]);
                    }
                }

                if (animInfo != null && animInfo.Length > 0)
                {
                    diaPortrait.PlayAnim(animInfo);
                }
            }

            var sayDialog = SayDialog.GetSayDialog();

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

            var flowchart = GetFlowchart();

            sayDialog.SetActive(true);

            sayDialog.SetCharacter(character);

            sayDialog.SetCharacterImage(portrait);

            string displayText = storyText;

            //if (playType == AnimPlayType.Start && !string.IsNullOrEmpty(sayDialogAnim))
            //{
            //    //  sayDialog.PlayAnim(sayDialogAnim);

            //}

            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);

            //stop voice via wwise
            if (!string.IsNullOrEmpty(PreVoiceClipName))
            {
                AudioManager.StopSound(PreVoiceClipName, 0);
            }//play voice via wwise
            if (!string.IsNullOrEmpty(voiceClipName))
            {
                AudioManager.TimeLinePlayVoice(voiceClipName);
            }
            sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate {
                Continue();
            }, diaPortrait);
        }
예제 #4
0
 /// <summary>
 /// Write a line of story text to the Say Dialog. Starts coroutine automatically.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="clearPrevious">Clear any previous text in the Say Dialog.</param>
 /// <param name="waitForInput">Wait for player input before continuing once text is written.</param>
 /// <param name="fadeWhenDone">Fade out the Say Dialog when writing and player input has finished.</param>
 /// <param name="stopVoiceover">Stop any existing voiceover audio before writing starts.</param>
 /// <param name="voiceOverClip">Voice over audio clip to play.</param>
 /// <param name="onComplete">Callback to execute when writing and player input have finished.</param>
 public virtual void Say(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, bool waitForVO, AudioClip voiceOverClip, Action onComplete, DialogPortrait portrait)
 {
     this.dialogPortrait = portrait;
     StartCoroutine(DoSay(text, clearPrevious, waitForInput, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, onComplete));
 }