Beispiel #1
0
    public IEnumerator SetCharaState(ShowCharaSet data, int expression, string charaName)
    {
        LastShowPos = data.PosType;
        var charaData = GlobalConfig.Instance.NovelsCharas.ToList().Find(o => o.Key == data.CharaKey);

        if (CurrentShowDict.ContainsKey(data.PosType))
        {
            CurrentShowDict[data.PosType].CharaKey   = data.CharaKey;
            CurrentShowDict[data.PosType].State      = data.State;
            CurrentShowDict[data.PosType].Expression = expression;
            CurrentShowDict[data.PosType].IsFlipX    = data.IsFlipX;
            if (string.IsNullOrEmpty(charaName))
            {
                if (charaData != null)
                {
                    CurrentShowDict[data.PosType].Name = charaData.Name;
                }
            }
            else
            {
                CurrentShowDict[data.PosType].Name = charaName;
            }
        }


        switch (data.PosType)
        {
        case CharaShowData.EPosType.Left:
            if (CurrentShowDict[CharaShowData.EPosType.Right].State == CharaShowData.EEffType.Show)
            {
                CurrentShowDict[CharaShowData.EPosType.Right].State = CharaShowData.EEffType.Dark;
                Anim_Right.SetInteger("State", (int)CharaShowData.EEffType.Dark);
            }
            Anim_Left.SetInteger("State", (int)data.State);

            break;

        case CharaShowData.EPosType.Right:
            if (CurrentShowDict[CharaShowData.EPosType.Left].State == CharaShowData.EEffType.Show)
            {
                CurrentShowDict[CharaShowData.EPosType.Left].State = CharaShowData.EEffType.Dark;
                Anim_Left.SetInteger("State", (int)CharaShowData.EEffType.Dark);
            }
            Anim_Right.SetInteger("State", (int)data.State);
            break;

        case CharaShowData.EPosType.Center:
            SetCharaClose(CharaShowData.EPosType.Left);
            SetCharaClose(CharaShowData.EPosType.Right);
            Anim_Center.SetInteger("State", (int)data.State);
            break;
        }

        //设置对话框位置
        if (CurrentDialogType == EDialogType.DialogBox)
        {
            if (data.PosType == CharaShowData.EPosType.Left)
            {
                ImageSwitch_DialogBg.SetImage(0);
            }
            else
            {
                ImageSwitch_DialogBg.SetImage(1);
            }
        }

        FreshSprite();
        yield return(new WaitForSeconds(0.3f));
    }
Beispiel #2
0
        public IEnumerator Run()
        {
            while (NovelsManager.Instance == null || UINovelsPanel.Instance == null)
            {
                yield return(null);
            }

            var cacheContent = NovelsManager.Instance.CacheContent;

            var lastType = EContentType.None;

            for (int i = 0; i < Contents.Count; i++)
            {
                var currentType = Contents[i].GetType();

                //全屏文本或文本内容类型切换时清理上一次的文本
                if (currentType == EContentType.Black || (lastType != EContentType.None && currentType != lastType))
                {
                    NovelsManager.Instance.CacheContent = cacheContent = "";
                    UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent);
                }
                lastType = currentType;

                var str = Contents[i].GetStr() + "";

                switch (currentType)
                {
                case EContentType.Dialog:
                {
                    var dialogContent = Contents[i] as DialogueContent;
                    if (dialogContent == null)
                    {
                        continue;
                    }

                    yield return(UINovelsPanel.Instance.DialogEnter(dialogContent.DialogBoxType));

                    //关闭立绘
                    if ((dialogContent.Close & DialogueContent.EClose.Left) == DialogueContent.EClose.Left)
                    {
                        UINovelsPanel.Instance.SetCharaClose(CharaShowData.EPosType.Left);
                    }

                    if ((dialogContent.Close & DialogueContent.EClose.Right) == DialogueContent.EClose.Right)
                    {
                        UINovelsPanel.Instance.SetCharaClose(CharaShowData.EPosType.Right);
                    }

                    if ((dialogContent.Close & DialogueContent.EClose.Center) == DialogueContent.EClose.Center)
                    {
                        UINovelsPanel.Instance.SetCharaClose(CharaShowData.EPosType.Center);
                    }

                    //寻找显示数据
                    ShowCharaSet showData = null;
                    if (!string.IsNullOrEmpty(dialogContent.ShowStr) &&
                        GlobalConfig.Instance.CharaMap.ContainsKey(dialogContent.ShowStr))
                    {
                        showData = GlobalConfig.Instance.CharaMap[dialogContent.ShowStr];
                    }

                    //清理文本
                    if (dialogContent.IsClearCache ||
                        (showData != null && showData.PosType != UINovelsPanel.Instance.LastShowPos) ||
                        dialogContent.DialogBoxType != UINovelsPanel.Instance.CurrentDialogType)
                    {
                        NovelsManager.Instance.CacheContent = cacheContent = "";
                        UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent);
                    }

                    //显示立绘
                    if (showData != null)
                    {
                        yield return(UINovelsPanel.Instance.SetCharaState(showData, (int)dialogContent.Expression, dialogContent.CharaName));
                    }

                    if (dialogContent.IsNextLine)
                    {
                        if (!string.IsNullOrEmpty(cacheContent))
                        {
                            cacheContent += "\n";
                        }
                    }

                    //文本特效
                    switch (dialogContent.TextEffect)
                    {
                    case ETextEffect.None:
                    {
                        cacheContent += str;
                        UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent);
                    }
                    break;

                    case ETextEffect.Step:
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            var charArr   = str.ToCharArray();
                            var charIndex = 0;
                            while (charIndex < charArr.Length)
                            {
                                UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent + str.Substring(0, charIndex));
                                charIndex += 1;
                                AudioManager.Instance.PlaySound(GlobalConfig.Instance.SFX_TextAppear, AudioGroupType.Effect);
                                if (dialogContent.EffectTime != 0)
                                {
                                    yield return(new WaitForSeconds(dialogContent.EffectTime));
                                }
                                else
                                {
                                    yield return(new WaitForSeconds((float)SaveManager.Instance.Cfg.CharSpeed / 1000));
                                }
                            }
                            cacheContent += str;
                            UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent);
                        }
                    }
                    break;

                    case ETextEffect.Fade:
                        cacheContent += str;
                        UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.Dialog, cacheContent);
                        yield return(UINovelsPanel.Instance.TextFadeIn(UINovelsPanel.EShowType.Dialog, dialogContent.EffectTime));

                        break;
                    }


                    //点击下一步
                    if (dialogContent != null && dialogContent.IsNeedClick && !SaveManager.Instance.Cfg.IsSkip)
                    {
                        NovelsManager.Instance.IsAcceptConfirm = false;
                        UINovelsPanel.Instance.Image_NextStepTip.gameObject.SetActive(true);

                        while (true)
                        {
                            if (NovelsManager.Instance.IsAcceptConfirm)
                            {
                                NovelsManager.Instance.IsAcceptConfirm = false;
                                UINovelsPanel.Instance.Image_NextStepTip.gameObject.SetActive(false);
                                break;
                            }
                            yield return(null);
                        }
                    }

                    var tmpWait = dialogContent.LeaveWait;
                    if (tmpWait == 0)
                    {
                        tmpWait = (float)SaveManager.Instance.Cfg.ForceTextWait / 1000;
                    }

                    yield return(new WaitForSeconds(tmpWait));

                    //关闭对话框
                    if (dialogContent.IsCloseDialog)
                    {
                        yield return(UINovelsPanel.Instance.DialogLeave());
                    }

                    //关闭黑屏框
                    if (dialogContent.IsCloseBlack)
                    {
                        yield return(UINovelsPanel.Instance.BlackLeave(0.5f));
                    }
                }
                break;

                case EContentType.Black:
                {
                    var blackContent = Contents[i] as BlackScreenContent;
                    if (blackContent == null)
                    {
                        continue;
                    }

                    yield return(UINovelsPanel.Instance.BlackEnter(blackContent.BGType, blackContent.EnterFade));

                    switch (blackContent.TextEffect)
                    {
                    case ETextEffect.None:
                    {
                        cacheContent += str;
                        UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.BlackScreen, cacheContent);
                    }
                    break;

                    case ETextEffect.Step:
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            var charArr   = str.ToCharArray();
                            var charIndex = 0;
                            while (charIndex < charArr.Length)
                            {
                                UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.BlackScreen, str.Substring(0, charIndex));
                                charIndex += 1;
                                AudioManager.Instance.PlaySound(GlobalConfig.Instance.SFX_TextAppear, AudioGroupType.Effect);
                                yield return(new WaitForSeconds((float)SaveManager.Instance.Cfg.CharSpeed / 1000));
                            }
                        }
                    }
                    break;

                    case ETextEffect.Fade:
                        cacheContent += str;
                        UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.BlackScreen, cacheContent);
                        yield return(UINovelsPanel.Instance.TextFadeIn(UINovelsPanel.EShowType.BlackScreen, blackContent.EffectTime));

                        break;
                    }

                    UINovelsPanel.Instance.SetContent(UINovelsPanel.EShowType.BlackScreen, str);

                    if (blackContent.IsNeedClick && !SaveManager.Instance.Cfg.IsSkip)
                    {
                        while (true)
                        {
                            if (NovelsManager.Instance.IsAcceptConfirm)
                            {
                                NovelsManager.Instance.IsAcceptConfirm = false;
                                break;
                            }
                            yield return(null);
                        }
                    }

                    if (blackContent.StayTime > 0)
                    {
                        yield return(new WaitForSeconds(blackContent.StayTime));
                    }

                    if (blackContent.IsClose)
                    {
                        yield return(UINovelsPanel.Instance.BlackLeave(blackContent.LeaveFade));
                    }

                    yield return(new WaitForSeconds((float)SaveManager.Instance.Cfg.ForceTextWait / 1000));

                    NovelsManager.Instance.IsAcceptConfirm = false;
                }
                break;

                case EContentType.Event:
                {
                    if (GlobalConfig.Instance.EventMap.ContainsKey(str))
                    {
                        yield return(GlobalConfig.Instance.EventMap[str].Run());
                    }
                }
                break;

                case EContentType.Audio:
                {
                    var audioContent = Contents[i] as SEAudioContent;
                    var lenth        = AudioManager.Instance.PlaySound(audioContent.Data, AudioGroupType.Effect);
                    if (audioContent.IsWait)
                    {
                        yield return(new WaitForSeconds(lenth));
                    }
                }
                break;

                case EContentType.Popup:
                {
                    var popupContent = Contents[i] as PopupContent;
                    yield return(UIPopupWindow.Instance.Open(popupContent.Data));
                }
                break;
                }
            }
        }