using UI.Main; using System.Text.RegularExpressions; using System.Collections.Generic; namespace GFGGame { public class StoryLookBackView : BaseWindow { private UI_StoryLookBackUI _ui; private List _stepListToRead; private List _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(); ShowNextStep(stroyStartID); } else { _dialogListLookBack = (List)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(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.PlayCroutine(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) { } } }