| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 | using UI.Main;using System.Text.RegularExpressions;using System.Collections.Generic;namespace GFGGame{    public class StoryLookBackView : BaseWindow    {        private UI_StoryLookBackUI _ui;        private List<StoryDialogCfg> _stepListToRead;        private List<string> _dialogListLookBack;        private StoryDialogCfg _currentStepCfg;        private string _nextStepId;        private string[] _wordList;        private int _wordIndex = 0;        private bool _isShowLetters;        private string _currentWords;        private string _currentData;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            _ui = UI_StoryLookBackUI.Create();            this.viewCom = _ui.target;            this.isfullScreen = true;            this.modal = true;            this.clickBlankToClose = false;            _ui.m_btnBack.onClick.Add(this.Hide);        }        protected override void OnShown()        {            base.OnShown();            _ui.m_content.m_txtContent.text = "";            if (this.viewData is string)            {                string stroyStartID = (string)this.viewData;                _dialogListLookBack = new List<string>();                ShowNextStep(stroyStartID);            }            else            {                _dialogListLookBack = (List<string>)this.viewData;            }            if (_dialogListLookBack != null)            {                string content = "";                foreach (string words in _dialogListLookBack)                {                    content += words + "\n";                }                _ui.m_content.m_txtContent.text = content;                _ui.m_content.m_txtContent.height = _ui.m_content.m_txtContent.textHeight;            }        }        protected override void OnHide()        {            base.OnHide();        }        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);                InitStepContent(storyDialogCfg);            }            else            {            }        }        private void InitStepContent(StoryDialogCfg storyDialogCfg)        {            string content = storyDialogCfg.content;            content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);            if (content.IndexOf("//") >= 0)            {                showList(content);            }            else            {                ShowDialog(storyDialogCfg);            }        }        private void showList(string content)        {            _currentData = null;            string[] list = Regex.Split(content, "//");            string itemInfo = list[0];            string[] itemInfoList = Regex.Split(itemInfo, "=");            _dialogListLookBack.Add(itemInfoList[0]);            string stepID = itemInfoList.Length > 1 ? itemInfoList[1] : null;            if (stepID == null)            {                stepID = "0";            }            OnStepComplete(stepID);        }        private void OnStepComplete(string nextStepId = null)        {            _nextStepId = nextStepId;            OnScreenEffectComplete();        }        private void OnScreenEffectComplete(object param = null)        {            if (_nextStepId == "0")            {                Over();            }            else            {                ShowNextStep(_nextStepId);            }        }        private void ShowDialog(StoryDialogCfg storyDialogCfg)        {            var content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);            string words = content;            string roleName = storyDialogCfg.name;            if (roleName == "self")            {                roleName = RoleDataManager.roleName;            }            //»Ø¹Ë            if (!string.IsNullOrEmpty(roleName))            {                _dialogListLookBack.Add("[color=#FDA2B1]" + roleName + "[/color]");            }            _wordList = Regex.Split(words, "&&");            _wordIndex = 0;            ShowNextDialog();        }        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)                {                    _currentData = itemInfoList[1];                }                else                {                    _currentData = null;                }                ShowCurrentWords();            }            else            {                OnStepComplete();            }        }        private void ShowCurrentWords()        {            _dialogListLookBack.Add(_currentWords);            _wordIndex++;            ShowNextWords(null);        }        private void ShowNextWords(object param = null)        {            string stepID = _currentData;            if (stepID != null)            {                OnStepComplete(stepID);            }            else            {                ShowNextDialog();            }        }        private void UpdateBg(string value)        {            if (value.Length > 0)            {            }        }        private void UpdatePic(string value)        {            if (value.Length > 0)            {            }        }        private void UpdateMusic(string value)        {            if (value.Length > 0)            {                if (value == "0")                {                    MusicManager.Instance.Stop();                }                else                {                    MusicManager.Instance.Play(ResPathUtil.GetMusicPath(value, "mp3"));                }            }        }        private void PlayEffect(string[] infos)        {        }        private void PlayShake(int[] shakeInfoArr)        {            if (shakeInfoArr != null && shakeInfoArr.Length > 0)            {            }        }        private void Over(bool isSkip = false)        {        }    }}
 |