| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105 | 
							- using FairyGUI;
 
- using UnityEngine;
 
- using UI.Main;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Text.RegularExpressions;
 
- using System;
 
- using YooAsset;
 
- using GFGGame.Launcher;
 
- using UnityEngine.UI;
 
- namespace GFGGame
 
- {
 
-     public delegate void OnCompleteStoryDialogCall(bool isSkip, object param);
 
-     public class StoryDialogView : BaseView
 
-     {
 
-         private UI_StoryDialogUI _ui;
 
-         private UI_CompArrow _arrow;
 
-         private GameObject _sceneObject;
 
-         private GameObject _animObject;
 
-         private EffectUI _effectUI1;
 
-         private DressUpObj _dressUpObj;
 
-         private GameObject _dressUpSceneObj;
 
-         private GameObject _selfHeadImgObj;
 
-         private GTextField _wordTextField;
 
-         //剧情完成回调
 
-         private OnCompleteStoryDialogCall _onCompleteStoryDialogCall;
 
-         private object _onCompleteStoryDialogCallParam;
 
-         //回顾
 
-         private List<string> _dialogListLookBack;
 
-         //自动播放
 
-         private int _speedAutoPlay = 1;
 
-         private bool _autoPlay = false;
 
-         //剧情状态
 
-         private List<StoryDialogCfg> _stepListToRead;
 
-         private StoryDialogCfg _currentStepCfg;
 
-         private string _nextStepId;
 
-         private string[] _wordList;
 
-         private int _wordIndex = 0;
 
-         private bool _isShowLetters;
 
-         private bool _canClickBtnNext;
 
-         private string _currentWords;
 
-         private string _storyStartID;
 
-         private string lastTextFieldType;   // 上一段文本框的类型
 
-         private bool IsTeaParty;    //是否是茶话会里的对话
 
-         TypingFadeEffectPro _typingEffect;
 
-         //屏幕效果中
 
-         private Action<object> _onScreenEffectComplete;
 
-         public override void Dispose()
 
-         {
 
-             if (_sceneObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             if(_animObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_animObject);
 
-                 _animObject = null;
 
-             }
 
-             _wordTextField = null;
 
-             _arrow = null;
 
-             _isShowLetters = false;
 
-             EffectUIPool.Recycle(_effectUI1);
 
-             _effectUI1 = null;
 
-             _onScreenEffectComplete = null;
 
-             _typingEffect = null;
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_StoryDialogUI.PACKAGE_NAME;
 
-             _ui = UI_StoryDialogUI.Create();
 
-             viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             isReturnView = true;
 
-             _ui.m_dialogText.target.visible = false;
 
-             _ui.m_dialogName.target.visible = false;
 
-             _ui.m_dialogHead.target.visible = false;
 
-             _ui.m_list.visible = false;
 
-             _ui.m_btnNext.width = GRoot.inst.width;
 
-             _ui.m_btnNext.height = GRoot.inst.height;
 
-             _ui.m_mask1.height = (GRoot.inst.height - 1920) / 2;
 
-             _ui.m_mask2.height = (GRoot.inst.height - 1920) / 2;
 
-             _ui.m_mask1.y = 0;
 
-             _ui.m_mask2.y = GRoot.inst.height - _ui.m_mask2.height;
 
-             _ui.m_btnNext.AddRelation(GRoot.inst, RelationType.Size);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnNext.onClick.Add(OnClickBtnNext);
 
-             _ui.m_btnLookBack.onClick.Add(OnClickBtnLookBack);
 
-             _ui.m_btnSkip.onClick.Add(OnBtnSkip);
 
-             _ui.m_list.onClickItem.Add(OnClickListItem);
 
-             _ui.m_btnSpeedUp.onClick.Add(OnClickBtnSpeedUp);
 
-             _ui.m_btnAutoPlay.onClick.Add(OnClickBtnAutoPlay);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             // 初始化
 
-             MusicManager.Instance.Stop();
 
-             MusicManager.Instance.SetVolume(0);
 
-             _ui.m_hideAnimMask.Play();
 
-             if (_sceneObject == null)
 
-             {
 
-                 _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneStoryDialog"));
 
-             }
 
-             if (_dressUpObj == null)
 
-             {
 
-                 _dressUpObj = new DressUpObj();
 
-             }
 
-             CreateHeadImg();
 
-             _speedAutoPlay = FightDataManager.Instance.dialogSpeed;
 
-             lastTextFieldType = "";
 
-             UpdateSpeedUpBtn();
 
-             _dialogListLookBack = new List<string>();
 
-             object[] datas = viewData as object[];
 
-             _storyStartID = (string)datas[0];
 
-             bool skipable = (bool)datas[1];
 
-             _onCompleteStoryDialogCall = (OnCompleteStoryDialogCall)datas[2];
 
-             if (datas.Length > 3)
 
-             {
 
-                 _onCompleteStoryDialogCallParam = datas[3];
 
-             }
 
-             IsTeaParty = (bool)datas[4];
 
-             _autoPlay = _lastStartAutoPlay;
 
-             if (LauncherConfig.netType != LauncherConfig.EnumNetType.LOCAL && !InstanceZonesDataManager.CheckLevelPass(MainStoryDataManager.currentLevelCfgId))
 
-             {
 
-                 // 临时设置都可以跳过对话
 
-                 skipable = false;
 
-             }
 
-             else
 
-             {
 
-                 skipable = true;
 
-             }
 
-             _ui.m_btnSkip.visible = skipable;
 
-             _ui.m_c1.selectedIndex = 0;
 
-             if (_storyStartID == MainStoryDataManager.priorId)
 
-             {
 
-                 _ui.m_c1.selectedIndex = 1;
 
-                 OnClickBtnAutoPlay();
 
-                 _speedAutoPlay = 1;
 
-                 FightDataManager.Instance.dialogSpeed = _speedAutoPlay;
 
-             }
 
-             // 茶会修改参数
 
-             if (IsTeaParty)
 
-             {
 
-                 _autoPlay = true;
 
-                 _ui.m_c1.selectedIndex = 2;
 
-                 _speedAutoPlay = 1;
 
-             }
 
-             _ui.m_btnAutoPlay.selected = _autoPlay;
 
-             _ui.m_btnBack.visible = InstanceZonesDataManager.CheckLevelPass(100001001);
 
-             StoryDialogDataManager.Instance.Clear();
 
-             InitStepListById(_storyStartID);
 
-             // 检查资源的初始化
 
-             Timers.inst.StartCoroutine(CheckResLoad());
 
-         }
 
-         private bool _lastStartAutoPlay = false;
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             Timers.inst.Remove(UpdateShake);
 
-             Timers.inst.Remove(OnScreenEffectComplete);
 
-             ScreenBlackController.Instance.HideBlack();
 
-             if (!IsTeaParty)
 
-             {
 
-                 _lastStartAutoPlay = _autoPlay;
 
-             }
 
-             StopAutoPlay();
 
-             VoiceManager.Instance.StopVoice();
 
-             if (_sceneObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             if (_animObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_animObject);
 
-                 _animObject = null;
 
-             }
 
-             _dressUpObj.TakeOffAll();
 
-             MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
 
-             _onCompleteStoryDialogCall = null;
 
-             _onCompleteStoryDialogCallParam = null;
 
-             StoryDialogDataManager.Instance.Clear();
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 3);
 
-             DestroyHeadImg();
 
-         }
 
-         protected override void TryCompleteGuide()
 
-         {
 
-             base.TryCompleteGuide();
 
-             GuideController.TryCompleteGuide(ConstGuideId.ENTER_CHAPTER_5, 3);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             Over(false);
 
-         }
 
-         private void OnClickBtnNext()
 
-         {
 
-             if (!_canClickBtnNext || IsTeaParty)
 
-             {
 
-                 return;
 
-             }
 
-             StopAutoPlay();
 
-             if (_onScreenEffectComplete != null)
 
-             {
 
-                 Timers.inst.Remove(OnScreenEffectComplete);
 
-                 _onScreenEffectComplete.Invoke(null);
 
-             }
 
-             else
 
-             {
 
-                 ShowNextWords();
 
-             }
 
-         }
 
-         private void OnClickBtnLookBack()
 
-         {
 
-             StopAutoPlay();
 
-             if (_ui.m_btnSkip.visible)
 
-             {
 
-                 ViewManager.Show<StoryLookBackView>(_storyStartID);
 
-             }
 
-             else
 
-             {
 
-                 ViewManager.Show<StoryLookBackView>(_dialogListLookBack);
 
-             }
 
-         }
 
-         private void OnBtnSkip()
 
-         {
 
-             Over(true);
 
-         }
 
-         private void OnClickListItem(EventContext context)
 
-         {
 
-             UI_ListDialogItem dialogItem = UI_ListDialogItem.Proxy(context.data as GObject);
 
-             _dialogListLookBack.Add(dialogItem.m_txtContent.text);
 
-             string stepID = (string)dialogItem.target.data;
 
-             if (stepID == null)
 
-             {
 
-                 stepID = "0";
 
-             }
 
-             UI_ListDialogItem.ProxyEnd();
 
-             OnStepComplete(stepID);
 
-         }
 
-         private void OnClickBtnSpeedUp()
 
-         {
 
-             //如果没有自动播放先开始自动播放
 
-             if (!_autoPlay)
 
-             {
 
-                 _ui.m_btnAutoPlay.selected = true;
 
-                 OnClickBtnAutoPlay();
 
-             }
 
-             _speedAutoPlay = _speedAutoPlay * 2;
 
-             if (_speedAutoPlay > GameConst.MAX_SPEED_AUTO_PLAY)
 
-             {
 
-                 _speedAutoPlay = 1;
 
-             }
 
-             FightDataManager.Instance.dialogSpeed = _speedAutoPlay;
 
-             UpdateSpeedUpBtn();
 
-             //if (_speedAutoPlay > 1)
 
-             //{
 
-             //    VoiceManager.Instance.StopVoice();
 
-             //}
 
-                 
 
-         }
 
-         private void OnClickBtnAutoPlay()
 
-         {
 
-             _autoPlay = _ui.m_btnAutoPlay.selected;
 
-             if (_autoPlay)
 
-             {
 
-                 ShowNextWords();
 
-             }
 
-         }
 
-         private void InitStepListById(string dialogID)
 
-         {
 
-             var temp = StoryDialogCfgArray.Instance.GetCfgsByid(dialogID);
 
-             _stepListToRead = new List<StoryDialogCfg>(temp);
 
-         }
 
-         private void ShowNextStep(string nextStepId)
 
-         {
 
-             if (nextStepId != null)
 
-             {
 
-                 InitStepListById(nextStepId);
 
-             }
 
-             if (_stepListToRead != null && _stepListToRead.Count > 0)
 
-             {
 
-                 StoryDialogCfg storyDialogCfg = (StoryDialogCfg)_stepListToRead[0];
 
-                 _stepListToRead.RemoveAt(0);
 
-                 Timers.inst.StartCoroutine(InitStepContent(storyDialogCfg));
 
-             }
 
-             else
 
-             {
 
-                 Over();
 
-             }
 
-         }
 
-         private void OnStepComplete(string nextStepId = null)
 
-         {
 
-             _nextStepId = nextStepId;
 
-             _ui.m_dialogText.target.visible = false;
 
-             _ui.m_dialogName.target.visible = false;
 
-             _ui.m_dialogHead.target.visible = false;
 
-             float delay = 0;
 
-             //屏幕效果
 
-             if (_currentStepCfg != null)
 
-             {
 
-                 if (_currentStepCfg.blackScreenDur > 0)
 
-                 {
 
-                     delay = _currentStepCfg.blackScreenDur;
 
-                     ScreenBlackController.Instance.ShowBlack(delay, this.viewCom, 0);
 
-                 }
 
-                 else if (_currentStepCfg.blankScreenDur > 0)
 
-                 {
 
-                     delay = _currentStepCfg.blankScreenDur;
 
-                     UpdatePic("0");
 
-                     UpdateAnim("0");
 
-                 }
 
-             }
 
-             if (delay > 0)
 
-             {
 
-                 //转换成秒
 
-                 delay = delay / 1000f;
 
-                 _onScreenEffectComplete = OnScreenEffectComplete;
 
-                 Timers.inst.Add(delay, 1, OnScreenEffectComplete);
 
-                 StoryDialogDataManager.Instance.dialogShowDelay = 0.6f;
 
-             }
 
-             else
 
-             {
 
-                 OnScreenEffectComplete();
 
-             }
 
-         }
 
-         private void OnScreenEffectComplete(object param = null)
 
-         {
 
-             _onScreenEffectComplete = null;
 
-             if (_nextStepId == "0")
 
-             {
 
-                 Over();
 
-             }
 
-             else
 
-             {
 
-                 ShowNextStep(_nextStepId);
 
-             }
 
-         }
 
-         private IEnumerator InitStepContent(StoryDialogCfg storyDialogCfg)
 
-         {
 
-             _canClickBtnNext = false;
 
-             StoryDialogDataManager.Instance.waitPicFade = false;
 
-             _ui.m_hide.Play();  // 隐藏遮罩
 
-             HideAllDialogUI();
 
-             // Init resource
 
-             _currentStepCfg = storyDialogCfg;
 
-             UpdateMusic(storyDialogCfg.musicRes);
 
-             UpdateBg(storyDialogCfg.bgRes);
 
-             UpdatePic(storyDialogCfg.picRes);
 
-             UpdateAnim(storyDialogCfg.aniRes);
 
-             UpdateRoleObj(storyDialogCfg.name);
 
-             PlayEffect(storyDialogCfg.effectInfoArr);
 
-             PlayShake(storyDialogCfg.shakeInfoArr);
 
-             string content = storyDialogCfg.content;
 
-             content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);
 
-             while (StoryDialogDataManager.Instance.waitBgChange)
 
-             {
 
-                 //Debug.Log("等待背景转换");
 
-                 yield return new WaitForEndOfFrame();
 
-             }
 
-             if(StoryDialogDataManager.Instance.dialogShowDelay > 0)
 
-             {
 
-                 yield return new WaitForSeconds(StoryDialogDataManager.Instance.dialogShowDelay);
 
-                 StoryDialogDataManager.Instance.dialogShowDelay = 0f;
 
-             }
 
-             _canClickBtnNext = true;
 
-             if (content.IndexOf("//") >= 0)
 
-             {
 
-                 ShowList(content);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.StartCoroutine(ShowDialog(storyDialogCfg));
 
-             }
 
-         }
 
-         private void ShowList(string content)
 
-         {
 
-             StopAutoPlay();
 
-             _ui.m_btnAutoPlay.enabled = false;
 
-             _wordTextField = null;
 
-             _ui.m_list.visible = true;
 
-             _ui.m_list.RemoveChildrenToPool();
 
-             string[] list = Regex.Split(content, "//");
 
-             _ui.m_list.itemRenderer = (int index, GObject item) =>
 
-             {
 
-                 string itemInfo = list[index];
 
-                 string[] itemInfoList = Regex.Split(itemInfo, "=");
 
-                 UI_ListDialogItem dialogItem = UI_ListDialogItem.Proxy(item);
 
-                 dialogItem.m_txtContent.text = itemInfoList[0];
 
-                 dialogItem.target.data = itemInfoList.Length > 1 ? itemInfoList[1] : null;
 
-                 UI_ListDialogItem.ProxyEnd();
 
-             };
 
-             _ui.m_list.numItems = list.Length;
 
-         }
 
-         private void HideAllDialogUI()
 
-         {
 
-             _ui.m_dialogText.target.visible = false;
 
-             _ui.m_dialogName.target.visible = false;
 
-             _ui.m_dialogHead.target.visible = false;
 
-             _ui.m_list.visible = false;
 
-         }
 
-         /// <summary>
 
-         /// 初始化对话框/语音/CG等
 
-         /// </summary>
 
-         /// <param name="storyDialogCfg"></param>
 
-         /// <returns></returns>
 
-         private IEnumerator ShowDialog(StoryDialogCfg storyDialogCfg)
 
-         {
 
-             if (storyDialogCfg.showChangeName == 1 && StorageDataManager.Instance.GetStorageValue(ConstStorageId.CHANGE_NAME) == 0)
 
-             {
 
-                 GameController.ShowCreateRole();
 
-                 StoryDialogDataManager.Instance.waiting = true;
 
-                 while (StoryDialogDataManager.Instance.waiting)
 
-                 {
 
-                     yield return new WaitForEndOfFrame();
 
-                 }
 
-                 //if (_autoPlay)
 
-                 //{
 
-                 //    _ui.m_btnAutoPlay.selected = false;
 
-                 //    OnClickBtnAutoPlay();
 
-                 //}
 
-             }
 
-             _ui.m_loaMask.url = ResPathUtil.GetBgImgPath(storyDialogCfg.maskRes);
 
-             _ui.m_btnAutoPlay.enabled = true;
 
-             _ui.m_list.visible = false;
 
-             var content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);
 
-             string words = content;
 
-             string roleName = storyDialogCfg.name;
 
-             string headRes = storyDialogCfg.head;
 
-             string headAniRes = storyDialogCfg.headAni;
 
-             string[] effectInfo = storyDialogCfg.effectInfoArr;
 
-             VoiceManager.Instance.StopVoice();
 
-             // 如果没开倍速才加载语音
 
-             if(_speedAutoPlay == 1 || !_autoPlay)
 
-             {
 
-                 // 如果配置了语音,读取语音
 
-                 VoiceManager.Instance.LoadRes(ResPathUtil.GetVoicePath(storyDialogCfg.voiceRes));
 
-             }
 
-             _wordList = Regex.Split(words, "&&");
 
-             // 有对话
 
-             if (_wordList.Length > 0 && !_wordList[0].Equals(""))
 
-             {
 
-                 if (roleName == "self")
 
-                 {
 
-                     roleName = RoleDataManager.roleName;
 
-                 }
 
-                 //回顾
 
-                 if (roleName != null)
 
-                 {
 
-                     _dialogListLookBack.Add("[color=#FDA2B1]" + roleName + "[/color]");
 
-                 }
 
-                 if (!string.IsNullOrEmpty(headAniRes) || storyDialogCfg.suitId > 0)
 
-                 {
 
-                     //显示对话框半身像
 
-                     _ui.m_dialogHead.target.visible = true;
 
-                     _ui.m_dialogHead.m_txtName.text = roleName;
 
-                     _ui.m_dialogHead.m_comphead.m_head.visible = false;
 
-                     _ui.m_dialogHead.m_comphead.m_holder.visible = true;
 
-                     var headAniCfg = HeadAniCfgArray.Instance.GetCfg(headAniRes);
 
-                     if (headAniCfg != null && !string.IsNullOrEmpty(headAniCfg.headAni))
 
-                     {
 
-                         //独立动画
 
-                         _ui.m_dialogHead.m_compDressUp.target.visible = false;
 
-                         _ui.m_dialogHead.m_comphead.target.visible = true;
 
-                         _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_dialogHead.m_comphead.m_holder, "ui_nzbq", headAniCfg.headAni);
 
-                     }
 
-                     else
 
-                     {
 
-                         //换装
 
-                         _ui.m_dialogHead.m_compDressUp.target.visible = true;
 
-                         _ui.m_dialogHead.m_comphead.target.visible = false;
 
-                         
 
-                         //_dressUpObjUI.ResetSceneObj(80, true, false, sceneObject.transform.Find("Scene").gameObject, false);
 
-                         _dressUpObj.setSceneObj(_dressUpSceneObj, false, false, null, false, ChangeHeadImgLayer);
 
-                         
 
-                         if (storyDialogCfg.suitId > 0)
 
-                         {
 
-                             _dressUpObj.PutOnSuitCfg(storyDialogCfg.suitId, false, new int[] { ConstDressUpItemType.SHOU_CHI_WU }, false, false);
 
-                         }
 
-                         else
 
-                         {
 
-                             _dressUpObj.PutOnDressUpData(CustomSuitDataManager.GetCurrentSuitData().dressUpData, new int[] { ConstDressUpItemType.SHOU_CHI_WU });
 
-                             if (_dressUpObj.actionId > 0)
 
-                             {
 
-                                 _dressUpObj.CancelAction(true, new int[] { ConstDressUpItemType.SHOU_CHI_WU });
 
-                             }
 
-                         }
 
-                         if (headAniCfg != null && headAniCfg.faceId > 0)
 
-                         {
 
-                             //表情
 
-                             _dressUpObj.AddOrRemove(headAniCfg.faceId, true);
 
-                             //_dressUpObjUI.UpdateWrapper(_ui.m_dialogHead.m_compDressUp.m_holder);
 
-                         }
 
-                     }
 
-                     _wordTextField = _ui.m_dialogHead.m_txtContent;
 
-                     _arrow = _ui.m_dialogHead.m_iconNext;
 
-                     lastTextFieldType = "head";
 
-                 }
 
-                 else if (!string.IsNullOrEmpty(headRes))
 
-                 {
 
-                     _ui.m_dialogHead.target.visible = true;
 
-                     _ui.m_dialogHead.m_txtName.text = roleName;
 
-                     _ui.m_dialogHead.m_comphead.m_head.visible = true;
 
-                     _ui.m_dialogHead.m_comphead.m_holder.visible = false;
 
-                     _ui.m_dialogHead.m_comphead.m_head.url = ResPathUtil.GetNpcHeadPath(headRes);
 
-                     _wordTextField = _ui.m_dialogHead.m_txtContent;
 
-                     _arrow = _ui.m_dialogHead.m_iconNext;
 
-                     lastTextFieldType = "head";
 
-                 }
 
-                 else if (!string.IsNullOrEmpty(roleName))
 
-                 {
 
-                     _ui.m_dialogName.target.visible = true;
 
-                     if (IsTeaParty)
 
-                     {
 
-                         var roleContainerList = LeagueDataManager.Instance.RoleContainerList;
 
-                         var teapartyRoleCfg = TeapartyRoleCfgArray.Instance.GetCfgsByid(LeagueDataManager.Instance.TeaPartyId);
 
-                         int roleIndex = Convert.ToInt32(roleName);
 
-                         _ui.m_dialogName.m_txtName.text = teapartyRoleCfg[roleIndex - 1].name;
 
-                         _ui.m_dialogName.m_bgType.selectedIndex = 1;
 
-                         _ui.m_dialogName.m_showArrow.selectedIndex = 1;
 
-                         if (roleIndex <= roleContainerList.Count && roleContainerList[roleIndex - 1].MaxScoreRoleName != null && roleContainerList[roleIndex - 1].MaxScoreRoleName != "" && _ui.m_dialogName.m_txtName.text != "")
 
-                         {
 
-                             _ui.m_comPlayName.visible = true;
 
-                             _ui.m_txtPlayName.text = roleContainerList[roleIndex - 1].MaxScoreRoleName;
 
-                             if (_ui.m_txtPlayName.text == RoleDataManager.roleName)
 
-                                 _ui.m_dialogName.m_bgType.selectedIndex = 0;
 
-                         }
 
-                         else
 
-                             _ui.m_comPlayName.visible = false;
 
-                     }
 
-                     else
 
-                     {
 
-                         _ui.m_dialogName.m_bgType.selectedIndex = 0;
 
-                         _ui.m_dialogName.m_showArrow.selectedIndex = 0;
 
-                         _ui.m_dialogName.m_txtName.text = roleName;
 
-                     }
 
-                     _wordTextField = _ui.m_dialogName.m_txtContent;
 
-                     _arrow = _ui.m_dialogName.m_iconNext;
 
-                     if (!lastTextFieldType.Equals("name"))
 
-                     {
 
-                         lastTextFieldType = "name";
 
-                         StoryDialogDataManager.Instance.waiting = true;
 
-                         _ui.m_t0.Play(() =>
 
-                         {
 
-                             StoryDialogDataManager.Instance.waiting = false;
 
-                         });
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (IsTeaParty)
 
-                         _ui.m_dialogText.m_showArrow.selectedIndex = 1;
 
-                     else
 
-                         _ui.m_dialogText.m_showArrow.selectedIndex = 0;
 
-                     _ui.m_dialogText.target.visible = true;
 
-                     _wordTextField = _ui.m_dialogText.m_txtContent;
 
-                     _arrow = _ui.m_dialogText.m_iconNext;
 
-                     lastTextFieldType = "text";
 
-                     _ui.m_comPlayName.visible = false;
 
-                 }
 
-                 _wordIndex = 0;
 
-                 _typingEffect = new TypingFadeEffectPro(_wordTextField);
 
-                 _typingEffect.typeFinishedAction = ShowCurrentWords;
 
-                 ShowNextDialog();
 
-             }
 
-             else
 
-             {
 
-                 OnStepComplete();
 
-                 //if (effectInfo.Length > 0)
 
-                 //{
 
-                 //    // 等待CG播放完毕直接进入下一段
 
-                 //    Timers.inst.StartCoroutine(WaitCGAnimFinish(effectInfo[0], int.Parse(effectInfo[1])));
 
-                 //}
 
-                 //// 播放效果等
 
-                 //else
 
-                 //{
 
-                 //    OnStepComplete();
 
-                 //}
 
-             }
 
-         }
 
-         private void ShowNextDialog()
 
-         {
 
-             if (_wordList != null && _wordList.Length > _wordIndex)
 
-             {
 
-                 string itemInfo = _wordList[_wordIndex];
 
-                 string[] itemInfoList = Regex.Split(itemInfo, "=");
 
-                 _currentWords = itemInfoList[0];
 
-                 if (itemInfoList.Length > 1)
 
-                 {
 
-                     _wordTextField.data = itemInfoList[1];
 
-                 }
 
-                 else
 
-                 {
 
-                     _wordTextField.data = null;
 
-                 }
 
-                 Timers.inst.StartCoroutine(StartShowLetters());
 
-             }
 
-             else
 
-             {
 
-                 OnStepComplete();
 
-             }
 
-         }
 
-         private void ShowCurrentWords()
 
-         {
 
-             //_arrow.target.visible = true;
 
-             //Timers.inst.Remove(UpdateLetters);
 
-             StopTyping();
 
-             _typingEffect?.Cancel();
 
-             _wordTextField.text = _currentWords;
 
-             _dialogListLookBack.Add(_currentWords);
 
-             _isShowLetters = false;
 
-             _wordIndex++;
 
-             if (_autoPlay)
 
-             {
 
-                 float interval = Mathf.Max(VoiceManager.Instance.GetClipRemainingLength(), GameConst.NEXT_WORDS_INTERVAL_MAX / _speedAutoPlay);
 
-                 Timers.inst.Add(interval, 1, ShowNextWords);
 
-             }
 
-         }
 
-         private void ShowNextWords(object param = null)
 
-         {
 
-             if (_wordTextField != null)
 
-             {
 
-                 if (_isShowLetters)
 
-                 {
 
-                     ShowCurrentWords();
 
-                 }
 
-                 else
 
-                 {
 
-                     string stepID = (string)_wordTextField.data;
 
-                     if (stepID != null)
 
-                     {
 
-                         OnStepComplete(stepID);
 
-                     }
 
-                     else
 
-                     {
 
-                         ShowNextDialog();
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private IEnumerator StartShowLetters()
 
-         {
 
-             _isShowLetters = true;
 
-             _arrow.target.visible = false;
 
-             _wordTextField.verticalAlign = VertAlignType.Top;
 
-             _wordTextField.text = "";
 
-             _canClickBtnNext = false;
 
-             while (StoryDialogDataManager.Instance.waitPicFade || StoryDialogDataManager.Instance.waiting)
 
-             {
 
-                 //Debug.Log("等待立绘/动画结束");
 
-                 yield return new WaitForEndOfFrame();
 
-             }
 
-             _canClickBtnNext = true;
 
-             _wordTextField.text = _currentWords;
 
-             StartTyping();
 
-         }
 
-         /// <summary>
 
-         /// 开启打字机显示
 
-         /// </summary>
 
-         private void StartTyping()
 
-         {
 
-             _typingEffect.SetSpeed(_speedAutoPlay);
 
-             _typingEffect.Start();
 
-             // 如果配置了语音,则播放语音
 
-             VoiceManager.Instance.PlayVoice();
 
-         }
 
-         private void StopTyping()
 
-         {
 
-             _typingEffect.Cancel();
 
-         }
 
-         private void UpdateBg(string value)
 
-         {
 
-             if (value.Length > 0)
 
-             {
 
-                 SceneController.UpdateDialogBg(value, _sceneObject);
 
-             }
 
-         }
 
-         private void UpdatePic(string value)
 
-         {
 
-             if(value.Length > 0 && !IsTeaParty)
 
-             {
 
-                 SceneController.UpdateDialogPic(value, _sceneObject);
 
-             }
 
-         }
 
-         private void UpdateAnim(string value)
 
-         {
 
-             if (value.Length > 0 && !IsTeaParty)
 
-             {
 
-                 if (value == "0")
 
-                 {
 
-                     //SceneController.ControlBgVisible(_sceneObject, true);
 
-                     _ui.m_hideAnimMask.Play();
 
-                     SceneController.UpdateDialogAnim(value, ref _animObject);
 
-                 }
 
-                 // 播放动画
 
-                 else
 
-                 {
 
-                     StoryDialogDataManager.Instance.waiting = true;
 
-                     _ui.m_showMask.Play(() =>
 
-                     {
 
-                         _ui.m_hideMask.Play();
 
-                         _ui.m_showAnimMask.Play();
 
-                         //SceneController.ControlBgVisible(_sceneObject, false);
 
-                         SceneController.UpdateDialogAnim(value, ref _animObject);
 
-                     });
 
-                     
 
-                 }
 
-                 
 
-             }
 
-         }
 
-         private void UpdateRoleObj(string value)
 
-         {
 
-             if (IsTeaParty)
 
-             {
 
-                 var roleContainerList = LeagueDataManager.Instance.RoleContainerList;
 
-                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
 
-                 for (int i = 0; i < roleContainerList.Count; i++)
 
-                 {
 
-                     if (value == (i + 1).ToString() && roleContainerList[i].EquipIds.Count > 0)
 
-                     {
 
-                         MyDressUpHelper.dressUpObj.PutOnItemList(roleContainerList[i].EquipIds);
 
-                         return;
 
-                     }
 
-                 }
 
-                 MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData(IsTeaParty);
 
-             }
 
-         }
 
-         private void UpdateMusic(string value)
 
-         {
 
-             if (value.Length > 0)
 
-             {
 
-                 if (value == "0")
 
-                 {
 
-                     MusicManager.Instance.Stop();
 
-                 }
 
-                 else
 
-                 {
 
-                     MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(value, "mp3"), false, 0.1f);
 
-                 }
 
-             }
 
-         }
 
-         private void PlayEffect(string[] infos)
 
-         {
 
-         }
 
-         private void PlayShake(int[] shakeInfoArr)
 
-         {
 
-             if (shakeInfoArr != null && shakeInfoArr.Length > 0)
 
-             {
 
-                 Vector3 position = _sceneObject.transform.position;
 
-                 position.x = (float)shakeInfoArr[0] / GameConst.PIXELS_PER_UNITY_UNIT;
 
-                 position.y = (float)shakeInfoArr[1] / GameConst.PIXELS_PER_UNITY_UNIT;
 
-                 _sceneObject.transform.position = position;
 
-                 float attenuationX = (float)shakeInfoArr[2] / GameConst.PIXELS_PER_UNITY_UNIT;
 
-                 float attenuationY = (float)shakeInfoArr[3] / GameConst.PIXELS_PER_UNITY_UNIT;
 
-                 float interval = (float)shakeInfoArr[4] / 1000;
 
-                 float duration = (float)shakeInfoArr[5] / 1000;
 
-                 int repeat = Mathf.RoundToInt(duration / interval);
 
-                 Timers.inst.Add(interval, 0, UpdateShake, new float[] { attenuationX, attenuationY });
 
-             }
 
-         }
 
-         private void UpdateShake(object param)
 
-         {
 
-             float[] attenuations = param as float[];
 
-             float attenuationX = attenuations[0];
 
-             float attenuationY = attenuations[1];
 
-             Vector3 position = _sceneObject.transform.position;
 
-             bool done = false;
 
-             bool doneX = false;
 
-             float absX = Mathf.Abs(position.x);
 
-             if (absX > attenuationX)
 
-             {
 
-                 int dir = (int)(position.x / absX);
 
-                 position.x = Mathf.Abs(position.x) - attenuationX;
 
-                 position.x *= -1 * dir;
 
-             }
 
-             else
 
-             {
 
-                 doneX = true;
 
-                 position.x = 0;
 
-             }
 
-             bool doneY = false;
 
-             float absY = Mathf.Abs(position.y);
 
-             if (absY > attenuationY)
 
-             {
 
-                 int dir = (int)(position.y / absY);
 
-                 position.y = Mathf.Abs(position.y) - attenuationY;
 
-                 position.y *= -1 * dir;
 
-             }
 
-             else
 
-             {
 
-                 doneY = true;
 
-                 position.y = 0;
 
-             }
 
-             done = doneX && doneY;
 
-             _sceneObject.transform.position = position;
 
-             if (done)
 
-             {
 
-                 Timers.inst.Remove(UpdateShake);
 
-             }
 
-         }
 
-         private void Over(bool isSkip = true)
 
-         {
 
-             if (_onCompleteStoryDialogCall != null)
 
-             {
 
-                 _onCompleteStoryDialogCall(isSkip, _onCompleteStoryDialogCallParam);
 
-             }
 
-             this.Hide();
 
-         }
 
-         private void UpdateSpeedUpBtn()
 
-         {
 
-             if (_speedAutoPlay > 1)
 
-             {
 
-                 _ui.m_btnSpeedUp.text = "x" + _speedAutoPlay;
 
-             }
 
-             else
 
-             {
 
-                 _ui.m_btnSpeedUp.text = "";
 
-             }
 
-             _typingEffect?.SetSpeed(_speedAutoPlay);
 
-         }
 
-         private void StopAutoPlay()
 
-         {
 
-             _autoPlay = false;
 
-             _ui.m_btnAutoPlay.selected = false;
 
-             Timers.inst.Remove(ShowNextWords);
 
-         }
 
-         private IEnumerator WaitCGAnimFinish(string resName, int times = 1)
 
-         {
 
-             GameObject cg = PrefabManager.Instance.InstantiateSync("test");
 
-             Animator animator = cg.GetComponentInChildren<Animator>();
 
-             AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
 
-             yield return new WaitForSeconds(info.length * times);
 
-             //while (info.normalizedTime < 0.95)
 
-             //{
 
-             //    info = animator.GetCurrentAnimatorStateInfo(0);
 
-             //    yield return new WaitForSeconds(0.1f);
 
-             //}
 
-             PrefabManager.Instance.Restore(cg);
 
-             OnStepComplete();
 
-         }
 
-         /// <summary>
 
-         /// 检查资源加载是否完成
 
-         /// </summary>
 
-         private IEnumerator CheckResLoad()
 
-         {
 
-             List<string> resList = new List<string>();
 
-             for (int i = 0; i < _stepListToRead.Count; i++)
 
-             {
 
-                 StoryDialogCfg cfg = _stepListToRead[i];
 
-                 if (cfg.bgRes.Length > 0 && cfg.bgRes != "0")
 
-                 {
 
-                     string bgRes = ResPathUtil.GetSceneBgPath(cfg.bgRes);
 
-                     if (!resList.Contains(bgRes))
 
-                     {
 
-                         resList.Add(bgRes);
 
-                     }
 
-                 }
 
-                 if (cfg.aniRes.Length > 0 && cfg.aniRes != "0")
 
-                 {
 
-                     string res = cfg.aniRes.Split('/')[1];
 
-                     string aniRes = ResPathUtil.GetStoryDialogCGPath(cfg.aniRes, res);
 
-                     if (!resList.Contains(aniRes))
 
-                     {
 
-                         resList.Add(aniRes);
 
-                     }
 
-                 }
 
-             }
 
-             ResourceDownloaderOperation downloaderOperation = YooAssets.CreateBundleDownloader(resList.ToArray(), 3, 3);
 
-             if (downloaderOperation.TotalDownloadCount == 0)
 
-             {
 
-                 ShowNextStep(_storyStartID);
 
-                 yield break;
 
-             }
 
-             // 开始加载资源
 
-             ViewManager.Show<LoadingView>();
 
-             LoadingView.Instance.SetDesc("正在加载剧情资源...");
 
-             downloaderOperation.OnDownloadErrorCallback =
 
-             (fileName, error) =>
 
-             {
 
-                 Debug.LogError($"加载{fileName}失败 {error}");
 
-             };
 
-             downloaderOperation.OnDownloadProgressCallback =
 
-             (totalDownloadCount, currentDownloadCount, totalDownloadSizeBytes, currentDownloadSizeBytes) =>
 
-             {
 
-                 string currentSizeMB = (currentDownloadSizeBytes / 1048576f).ToString("f1");
 
-                 string totalSizeMB = (totalDownloadSizeBytes / 1048576f).ToString("f1");
 
-                 var progress = (float)currentDownloadSizeBytes / totalDownloadSizeBytes;
 
-                 //LauncherView.Instance.SetDesc($"正在下载资源,{currentDownloadCount}/{totalDownloadCount}", $"{currentSizeMB}MB/{totalSizeMB}MB", true);
 
-                 LoadingView.Instance.SetProgress((int)(progress * 100));
 
-             };
 
-             downloaderOperation.BeginDownload();
 
-             yield return downloaderOperation;
 
-             // 检测下载结果
 
-             if (downloaderOperation.Status != EOperationStatus.Succeed)
 
-             {
 
-                 Alert.Show("下载失败!请检查网络状态后重试。")
 
-                     .SetLeftButton(true, "返回", (data) =>
 
-                     {
 
-                         ViewManager.Hide<LoadingView>();
 
-                         Hide();
 
-                     });
 
-                 yield break;
 
-             }
 
-             // 加载完成
 
-             LoadingView.Instance.SetProgress(100, () =>
 
-                 {
 
-                     ViewManager.Hide<LoadingView>();
 
-                     ShowNextStep(_storyStartID);
 
-                 }
 
-             );
 
-         }
 
-         private RenderTexture renderTexure;
 
-         private void CreateHeadImg()
 
-         {
 
-             // 创建render texture
 
-             renderTexure = new RenderTexture(550, 760, 24);
 
-             // 换装父节点 + 相机
 
-             _dressUpSceneObj = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("StoryDialogSelfImg/StoryDialogDressUpObj"));
 
-             Camera camera = _dressUpSceneObj.transform.Find("Camera").GetComponent<Camera>();
 
-             camera.targetTexture = renderTexure;
 
-             // 创建RawImg
 
-             _selfHeadImgObj = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("StoryDialogSelfImg/Canvas"));
 
-             RawImage rawImage = _selfHeadImgObj.transform.Find("mask/RawImage").GetComponent<RawImage>();
 
-             rawImage.texture = renderTexure;
 
-             // 将RawImg放在FGUI上
 
-             GoWrapper goWrapper = new GoWrapper(_selfHeadImgObj);
 
-             _ui.m_dialogHead.m_compDressUp.m_holder.SetNativeObject(goWrapper);
 
-             // FGUI会自动修改Canvas的参数,需要调整一下位置
 
-             RectTransform canvas = _selfHeadImgObj.transform.GetComponent<RectTransform>();
 
-             canvas.pivot = Vector2.one * 0.5f;
 
-             canvas.anchoredPosition = Vector2.zero;
 
-         }
 
-         private void DestroyHeadImg()
 
-         {
 
-             // 清空render Texture
 
-             Camera camera = _dressUpSceneObj.transform.Find("Camera").GetComponent<Camera>();
 
-             camera.targetTexture = null;
 
-             RawImage rawImage = _selfHeadImgObj.transform.Find("mask/RawImage").GetComponent<RawImage>();
 
-             rawImage.texture = null;
 
-             renderTexure.Release();
 
-             renderTexure = null;
 
-             // 回收人物
 
-             _dressUpObj?.Dispose();
 
-             _dressUpObj = null;
 
-             // 回收RawImage
 
-             if (_selfHeadImgObj != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_selfHeadImgObj);
 
-                 _selfHeadImgObj = null;
 
-             }
 
-             // 回收相机预制
 
-             if (_dressUpSceneObj != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_dressUpSceneObj);
 
-                 _dressUpSceneObj = null;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 修改主角头像组件层级
 
-         /// </summary>
 
-         private void ChangeHeadImgLayer()
 
-         {
 
-             Transform parent = _dressUpSceneObj.transform.Find("Role");
 
-             ChangeLayer(parent, parent.gameObject.layer);
 
-         }
 
-         private void ChangeLayer(Transform transform, int layer)
 
-         {
 
-             if (transform.childCount > 0)
 
-             {
 
-                 for (int i = 0; i < transform.childCount; i++)
 
-                 {
 
-                     ChangeLayer(transform.GetChild(i), layer);
 
-                 }
 
-                 transform.gameObject.layer = layer;
 
-             }
 
-             else
 
-             {
 
-                 transform.gameObject.layer = layer;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |