protected AbstractNarratorDialogUI(DialogUnitInfo info) : base(info)
        {
            Create(info.abstractAbstractDialogInfoAsset.NarratorUiKeys);

            text      = m_TransFrom.Find(TextPath).GetComponent <Text>();
            text.text = info.wordToNarrator;

            Show();

            if (info.enableFadeOut)
            {
                text.gameObject.AddComponent <TypeWriterEffect>().StartWriter(
                    info.wordToNarrator.Length / info.narratorSpeed,
                    () => MainLoop.Instance.StartCoroutine(FadeOutText(text, info.fadeOutTime, () => DestroyThis())),
                    () => canGoNext,
                    info.abstractAbstractDialogInfoAsset.affectedByTimeScale);
            }
            else
            {
                text.gameObject.AddComponent <TypeWriterEffect>().StartWriter(
                    info.wordToNarrator.Length / info.narratorSpeed,
                    () => enbaleGoNext = true,
                    () => canGoNext,
                    info.abstractAbstractDialogInfoAsset.affectedByTimeScale);
            }
        }
Exemple #2
0
        protected AbstractNarratorDialogUI(DialogUnitInfo info) : base(info)
        {
            Create(info.abstractAbstractDialogInfoAsset.NarratorUiKeys);

            text      = m_TransFrom.Find(TextPath).GetComponent <Text>();
            text.text = info.wordToNarrator;

            image = m_TransFrom.Find(ImagePath).GetComponent <Image>();

            switch (info.m_NarratorType)
            {
            case NarratorType.Color:
                image.sprite = null;
                image.color  = info.m_NarratorColor;
                break;

            case NarratorType.Image:
                image.sprite = info.m_NarratorImage;
                image.color  = info.m_NarratorColor;
                break;

            case NarratorType.Object:
                var obj = Object.Instantiate(info.m_NarratorObject, m_TransFrom.parent);
                obj.transform.SetAsFirstSibling();
                image.sprite = info.m_NarratorImage;
                image.color  = info.m_NarratorColor;
                break;
            }


            Show();

            if (info.enableFadeOut)
            {
                text.gameObject.AddComponent <TypeWriterEffect>().StartWriter(
                    info.wordToNarrator.Length / info.narratorSpeed,
                    () => MainLoop.Instance.StartCoroutine(FadeOutText(text, info.fadeOutTime, () => DestroyThis())),
                    () => canGoNext,
                    info.abstractAbstractDialogInfoAsset.affectedByTimeScale);
            }
            else
            {
                text.gameObject.AddComponent <TypeWriterEffect>().StartWriter(
                    info.wordToNarrator.Length / info.narratorSpeed,
                    () => enbaleGoNext = true,
                    () => canGoNext,
                    info.abstractAbstractDialogInfoAsset.affectedByTimeScale);
            }
        }
        public AbstractWordDialogUI(DialogUnitInfo unitInfo) : base(unitInfo)
        {
            Text words = null;

            //判断显示类型,是字幕式,还是对话框
            switch (unitInfo.showType)
            {
            case ShowType.Caption:
                Create(unitInfo.abstractAbstractDialogInfoAsset.CaptionWordUiKeys[unitInfo.wordPrefabIndex]);

                m_TransFrom.Find(SpeakerTextPath).GetComponent <Text>().text = unitInfo.SpeakerName;
                words = m_TransFrom.Find(CaptionWordTextPath).GetComponent <Text>();

                break;

            case ShowType.Dialog:
                Create(unitInfo.abstractAbstractDialogInfoAsset.DialogWordUiKeys[unitInfo.wordPrefabIndex]);

                _data = m_TransFrom.GetComponent <DialogData>();

                m_TransFrom.position = unitInfo.fromNull
                        ? _data.GetSuitPos()
                        : _data.GetSuitPos(Scripts.DialogSystem.GetCharacterObj(unitInfo.SpeakerName).transform);


                words = m_TransFrom.Find(DialogWordTextPath).GetComponent <Text>();
                break;
            }

            words.text = unitInfo.words;

            Show();

            words.gameObject.AddComponent <TypeWriterEffect>().StartWriter(
                unitInfo.abstractAbstractDialogInfoAsset.wordFinishTime,
                () => enableGoNext = true,
                () => canGoNext,
                unitInfo.abstractAbstractDialogInfoAsset.affectedByTimeScale);
        }
Exemple #4
0
        public AbstractChooseDialogUI(DialogUnitInfo dialogUnitInfo) : base(dialogUnitInfo)
        {
            Create(dialogUnitInfo.abstractAbstractDialogInfoAsset.ChooseUiKeys);

            m_TransFrom.Find(SpeakerTextPath).GetComponent <Text>().text = dialogUnitInfo.SpeakerName;
            var speaker = m_TransFrom.Find(SpeakerTextPath).GetComponent <Text>();

            speaker.text = dialogUnitInfo.SpeakerName;
            var title = m_TransFrom.Find(TitleTextPath).GetComponent <Text>();

            title.text = dialogUnitInfo.title;

            Show();

            //打字机效果
            var titleEffect = title.gameObject.AddComponent <TypeWriterEffect>();

            titleEffect.StartWriter(
                dialogUnitInfo.abstractAbstractDialogInfoAsset.wordFinishTime,
                () => { MainLoop.Instance.StartCoroutine(ShowChoices(dialogUnitInfo)); },
                () => canGoNext,
                dialogUnitInfo.abstractAbstractDialogInfoAsset.affectedByTimeScale);
        }
 public DialogUnitUI(DialogUnitInfo info)
 {
     m_dialogUnitInfo = info;
 }
Exemple #6
0
        private IEnumerator ShowChoices(DialogUnitInfo dialogUnitInfo)
        {
            GameObject defaultObj = null;
            var        index      = 0;

            //显示选项
            foreach (var choice in dialogUnitInfo.Choices)
            {
                if (choice.enable.BoolValue == false)
                {
                    continue;
                }

                var obj = ResourceMgr.InstantiateGameObject(choiceObjPath, ChoiceParent);

                if (index++ == dialogUnitInfo.defaultIndex)
                {
                    defaultObj = obj;
                }


                var text = obj.transform.Find(textPathOnChoice).GetComponent <Text>();
                text.text = choice.text;

                //添加回调
                text.gameObject.AddComponent <UIInputer>().eventOnPointerClick += (dat) =>
                {
                    clicked = true;

                    Hide();
                    if (choice.targetDialogInfoAsset == null)
                    {
                        CEventCenter.BroadMessage(Scripts.DialogSystem.ChooseNotBack, dialogUnitInfo.abstractAbstractDialogInfoAsset.name);
                        DestroyThis();
                    }
                    else
                    {
//                        Debug.Log("选项:"+choice.text+"  willBack:"+choice.willBack);
                        if (!choice.willBack)
                        {
//                            Debug.Log($"广播消息:{Scripts.DialogSystem.ChooseNotBack},名字:{dialogUnitInfo.abstractAbstractDialogInfoAsset.name}");
                            CEventCenter.BroadMessage(Scripts.DialogSystem.ChooseNotBack, dialogUnitInfo.abstractAbstractDialogInfoAsset.name);
//                            Debug.Log("开始选项协程:"+choice.targetDialogInfoAsset.name);
                            MainLoop.Instance.StartCoroutine(
                                Scripts.DialogSystem.RunDialogAwait(choice.targetDialogInfoAsset, () =>
                            {
                                if (dialogUnitInfo.sendToExWord)
                                {
                                    dialogUnitInfo.words = choice.text;
                                    CEventCenter.BroadMessage(Scripts.DialogSystem.ExternWord, dialogUnitInfo);
                                }
                                DestroyThis();
                            }));
                        }
                        else
                        {
//                            Debug.Log("Else???");
                            MainLoop.Instance.StartCoroutine(
                                Scripts.DialogSystem.RunDialog(choice.targetDialogInfoAsset, () =>
                            {
                                if (dialogUnitInfo.sendToExWord)
                                {
                                    dialogUnitInfo.words = choice.text;
                                    CEventCenter.BroadMessage(Scripts.DialogSystem.ExternWord, dialogUnitInfo);
                                }
                                DestroyThis();
                            }));
                        }
                    }
                };
                yield return(new WaitForSeconds(.4f));
            }

            //如果有时间限制
            if (dialogUnitInfo.timeLimit)
            {
                var timer = 0f;
                MainLoop.Instance.UpdateForSeconds(() =>
                {
                    if (!m_TransFrom)
                    {
                        return;
                    }
                    onTimeLeave?.Invoke(timer, dialogUnitInfo.limitTime, defaultObj);
                    timer += Time.deltaTime;
                }, dialogUnitInfo.limitTime, () =>
                {
                    if (!m_TransFrom)
                    {
                        return;
                    }
                    //如果到现在没有点击下去
                    if (!clicked)
                    {
                        Hide();
                        MainLoop.Instance.StartCoroutine(
                            Scripts.DialogSystem.RunDialog(
                                dialogUnitInfo.Choices[dialogUnitInfo.defaultIndex].targetDialogInfoAsset,
                                () =>
                        {
                            if (dialogUnitInfo.sendToExWord)
                            {
                                dialogUnitInfo.words = dialogUnitInfo.Choices[dialogUnitInfo.defaultIndex].text;
                                CEventCenter.BroadMessage(Scripts.DialogSystem.ExternWord, dialogUnitInfo);
                            }
                            if (!dialogUnitInfo.Choices[dialogUnitInfo.defaultIndex].willBack)
                            {
                                CEventCenter.BroadMessage(Scripts.DialogSystem.ChooseNotBack);
                            }
                            DestroyThis();
                        }));
                    }
                });
            }
        }
Exemple #7
0
 public HighFiveCaptionChooseUi(DialogUnitInfo dialogUnitInfo) : base(dialogUnitInfo)
 {
 }
 public HighFiveNarratorUi(DialogUnitInfo info) : base(info)
 {
 }
Exemple #9
0
 public HighFiveCaptionWordUi(DialogUnitInfo unitInfo) : base(unitInfo)
 {
 }