コード例 #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
ファイル: 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);
        }