Example #1
0
        // Update is called once per frame
        void Update()
        {
            if (clips == null || clips.Length < 1 || dp == null)
            {
                return;
            }

            float time = Time.time;

            for (int i = 0; i < clips.Length; i++)
            {
                if (clips[i].fps < 0.1f || clips[i].keys == null || clips[i].keys.Length < 1)
                {
                    continue;
                }
                float framDuration = 1f / clips[i].fps;
                if (time - runtimeInfo[i].frameTimeStmp > framDuration)
                {
                    var cursor = runtimeInfo[i].cursor + 1;
                    if (cursor >= clips[i].keys.Length)
                    {
                        cursor = 0;
                    }
                    runtimeInfo[i].cursor        = cursor;
                    runtimeInfo[i].frameTimeStmp = time;
                    dp.SetSprite(i, clips[i].keys[cursor]);
                }
            }
        }
Example #2
0
        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);
        }