StoryDialogView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.Main;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Text.RegularExpressions;
  7. using System;
  8. namespace GFGGame
  9. {
  10. public delegate void OnCompleteStoryDialogCall(bool isSkip, object param);
  11. public class StoryDialogView : BaseView
  12. {
  13. private UI_StoryDialogUI _ui;
  14. private UI_CompArrow _arrow;
  15. private GameObject _sceneObject;
  16. private GameObject _scenePrefab;
  17. private EffectUI _effectUI1;
  18. private DressUpObjUI _dressUpObjUI;
  19. private GTextField _wordTextField;
  20. //剧情完成回调
  21. private OnCompleteStoryDialogCall _onCompleteStoryDialogCall;
  22. private object _onCompleteStoryDialogCallParam;
  23. //回顾
  24. private List<string> _dialogListLookBack;
  25. //自动播放
  26. private int _speedAutoPlay = 1;
  27. private bool _autoPlay = false;
  28. //剧情状态
  29. private List<StoryDialogCfg> _stepListToRead;
  30. private StoryDialogCfg _currentStepCfg;
  31. private string _nextStepId;
  32. private string[] _wordList;
  33. private int _wordIndex = 0;
  34. private bool _isShowLetters;
  35. private string _currentWords;
  36. private string _stroyStartID;
  37. //屏幕效果中
  38. private Action<object> _onScreenEffectComplete;
  39. public override void Dispose()
  40. {
  41. base.Dispose();
  42. if (_sceneObject != null)
  43. {
  44. GameObject.Destroy(_sceneObject);
  45. _sceneObject = null;
  46. }
  47. _dressUpObjUI?.Dispose();
  48. _dressUpObjUI = null;
  49. _wordTextField = null;
  50. _arrow = null;
  51. _isShowLetters = false;
  52. EffectUIPool.Recycle(_effectUI1);
  53. _effectUI1 = null;
  54. _onScreenEffectComplete = null;
  55. Timers.inst.Remove(UpdateLetters);
  56. if (_ui != null)
  57. {
  58. _ui.Dispose();
  59. _ui = null;
  60. }
  61. }
  62. protected override void Init()
  63. {
  64. base.Init();
  65. packageName = UI_StoryDialogUI.PACKAGE_NAME;
  66. _ui = UI_StoryDialogUI.Create();
  67. viewCom = _ui.target;
  68. isfullScreen = true;
  69. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneStoryDialog"));
  70. }
  71. protected override void OnInit()
  72. {
  73. base.OnInit();
  74. _ui.m_dialogText.target.visible = false;
  75. _ui.m_dialogName.target.visible = false;
  76. _ui.m_dialogHead.target.visible = false;
  77. _ui.m_list.visible = false;
  78. _ui.m_btnNext.width = GRoot.inst.width;
  79. _ui.m_btnNext.height = GRoot.inst.height;
  80. _ui.m_btnNext.AddRelation(GRoot.inst, RelationType.Size);
  81. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  82. _ui.m_btnNext.onClick.Add(OnClickBtnNext);
  83. _ui.m_btnLookBack.onClick.Add(OnClickBtnLookBack);
  84. _ui.m_btnSkip.onClick.Add(OnBtnSkip);
  85. _ui.m_list.onClickItem.Add(OnClickListItem);
  86. _ui.m_btnSpeedUp.onClick.Add(OnClickBtnSpeedUp);
  87. _ui.m_btnAutoPlay.onClick.Add(OnClickBtnAutoPlay);
  88. }
  89. protected override void OnShown()
  90. {
  91. base.OnShown();
  92. if (_sceneObject == null)
  93. {
  94. _sceneObject = GameObject.Instantiate(_scenePrefab);
  95. }
  96. if (_dressUpObjUI == null)
  97. {
  98. _dressUpObjUI = new DressUpObjUI();
  99. }
  100. _speedAutoPlay = FightDataManager.Instance.dialogSpeed;
  101. _autoPlay = false;
  102. UpdateSpeedUpBtn();
  103. _dialogListLookBack = new List<string>();
  104. object[] datas = viewData as object[];
  105. _stroyStartID = (string)datas[0];
  106. bool skipable = (bool)datas[1];
  107. _onCompleteStoryDialogCall = (OnCompleteStoryDialogCall)datas[2];
  108. if (datas.Length > 3)
  109. {
  110. _onCompleteStoryDialogCallParam = datas[3];
  111. }
  112. if (LauncherConfig.netType == LauncherConfig.EnumNetType.TEMP && !InstanceZonesDataManager.CheckLevelPass(MainStoryDataManager.currentLevelCfgId))
  113. {
  114. // 临时设置都可以跳过对话
  115. skipable = false;
  116. }
  117. else
  118. {
  119. skipable = true;
  120. }
  121. _ui.m_btnSkip.visible = skipable;
  122. ShowNextStep(_stroyStartID);
  123. _ui.m_c1.selectedIndex = 0;
  124. _ui.m_btnAutoPlay.selected = false;
  125. if (_stroyStartID == MainStoryDataManager.priorId)
  126. {
  127. _ui.m_c1.selectedIndex = 1;
  128. // _ui.m_btnAutoPlay.selected = true;
  129. OnClickBtnAutoPlay();
  130. _speedAutoPlay = 1;
  131. FightDataManager.Instance.dialogSpeed = _speedAutoPlay;
  132. }
  133. _ui.m_btnBack.visible = InstanceZonesDataManager.CheckLevelPass(100001001);
  134. }
  135. protected override void OnHide()
  136. {
  137. base.OnHide();
  138. Timers.inst.Remove(UpdateLetters);
  139. Timers.inst.Remove(UpdateShake);
  140. Timers.inst.Remove(OnScreenEffectComplete);
  141. Timers.inst.Remove(ShowNextWords);
  142. ScreenBlackController.Instance.HideBlack();
  143. StopAutoPlay();
  144. if (_sceneObject != null)
  145. {
  146. GameObject.Destroy(_sceneObject);
  147. _sceneObject = null;
  148. }
  149. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  150. _onCompleteStoryDialogCall = null;
  151. _onCompleteStoryDialogCallParam = null;
  152. }
  153. private void OnClickBtnBack()
  154. {
  155. // this.Hide();
  156. ViewManager.GoBackFrom(typeof(StoryDialogView).FullName);
  157. // Over(false);
  158. }
  159. private void OnClickBtnNext()
  160. {
  161. // StopAutoPlay();
  162. if (_onScreenEffectComplete != null)
  163. {
  164. Timers.inst.Remove(OnScreenEffectComplete);
  165. _onScreenEffectComplete.Invoke(null);
  166. }
  167. else
  168. {
  169. ShowNextWords();
  170. }
  171. }
  172. private void OnClickBtnLookBack()
  173. {
  174. if (_ui.m_btnSkip.enabled)
  175. {
  176. ViewManager.Show<StoryLookBackView>(_stroyStartID);
  177. }
  178. else
  179. {
  180. ViewManager.Show<StoryLookBackView>(_dialogListLookBack);
  181. }
  182. }
  183. private void OnBtnSkip()
  184. {
  185. Over(true);
  186. }
  187. private void OnClickListItem(EventContext context)
  188. {
  189. UI_ListDialogItem dialogItem = UI_ListDialogItem.Proxy(context.data as GObject);
  190. _dialogListLookBack.Add(dialogItem.m_txtContent.text);
  191. string stepID = (string)dialogItem.target.data;
  192. if (stepID == null)
  193. {
  194. stepID = "0";
  195. }
  196. UI_ListDialogItem.ProxyEnd();
  197. OnStepComplete(stepID);
  198. }
  199. private void OnClickBtnSpeedUp()
  200. {
  201. //如果没有自动播放先开始自动播放
  202. if (!_autoPlay)
  203. {
  204. _ui.m_btnAutoPlay.selected = true;
  205. OnClickBtnAutoPlay();
  206. }
  207. _speedAutoPlay = _speedAutoPlay * 2;
  208. if (_speedAutoPlay > GameConst.MAX_SPEED_AUTO_PLAY)
  209. {
  210. _speedAutoPlay = 1;
  211. }
  212. FightDataManager.Instance.dialogSpeed = _speedAutoPlay;
  213. UpdateSpeedUpBtn();
  214. }
  215. private void OnClickBtnAutoPlay()
  216. {
  217. _autoPlay = _ui.m_btnAutoPlay.selected;
  218. if (_autoPlay)
  219. {
  220. ShowNextWords();
  221. }
  222. }
  223. private void InitStepListById(string dialogID)
  224. {
  225. var temp = StoryDialogCfgArray.Instance.GetCfgsByid(dialogID);
  226. _stepListToRead = new List<StoryDialogCfg>(temp);
  227. }
  228. private void ShowNextStep(string nextStepId)
  229. {
  230. if (nextStepId != null)
  231. {
  232. InitStepListById(nextStepId);
  233. }
  234. if (_stepListToRead != null && _stepListToRead.Count > 0)
  235. {
  236. StoryDialogCfg storyDialogCfg = (StoryDialogCfg)_stepListToRead[0];
  237. _stepListToRead.RemoveAt(0);
  238. InitStepContent(storyDialogCfg);
  239. }
  240. else
  241. {
  242. Over();
  243. }
  244. }
  245. private void OnStepComplete(string nextStepId = null)
  246. {
  247. _nextStepId = nextStepId;
  248. _ui.m_dialogText.target.visible = false;
  249. _ui.m_dialogName.target.visible = false;
  250. _ui.m_dialogHead.target.visible = false;
  251. float delay = 0;
  252. //屏幕效果
  253. if (_currentStepCfg != null)
  254. {
  255. if (_currentStepCfg.blackScreenDur > 0)
  256. {
  257. delay = _currentStepCfg.blackScreenDur;
  258. ScreenBlackController.Instance.ShowBlack(delay, this.viewCom, 0);
  259. }
  260. else if (_currentStepCfg.blankScreenDur > 0)
  261. {
  262. delay = _currentStepCfg.blankScreenDur;
  263. UpdatePic("0");
  264. }
  265. }
  266. if (delay > 0)
  267. {
  268. //转换成秒
  269. delay = delay / 1000f;
  270. _onScreenEffectComplete = OnScreenEffectComplete;
  271. Timers.inst.Add(delay, 1, OnScreenEffectComplete);
  272. }
  273. else
  274. {
  275. OnScreenEffectComplete();
  276. }
  277. }
  278. private void OnScreenEffectComplete(object param = null)
  279. {
  280. _onScreenEffectComplete = null;
  281. if (_nextStepId == "0")
  282. {
  283. Over();
  284. }
  285. else
  286. {
  287. ShowNextStep(_nextStepId);
  288. }
  289. }
  290. private void InitStepContent(StoryDialogCfg storyDialogCfg)
  291. {
  292. _currentStepCfg = storyDialogCfg;
  293. UpdateMusic(storyDialogCfg.musicRes);
  294. UpdateBg(storyDialogCfg.bgRes);
  295. UpdatePic(storyDialogCfg.picRes);
  296. PlayEffect(storyDialogCfg.effectInfoArr);
  297. PlayShake(storyDialogCfg.shakeInfoArr);
  298. string content = storyDialogCfg.content;
  299. content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);
  300. if (content.IndexOf("//") >= 0)
  301. {
  302. showList(content);
  303. }
  304. else
  305. {
  306. ShowDialog(storyDialogCfg);
  307. }
  308. }
  309. private void showList(string content)
  310. {
  311. StopAutoPlay();
  312. _ui.m_btnAutoPlay.enabled = false;
  313. _wordTextField = null;
  314. _ui.m_dialogText.target.visible = false;
  315. _ui.m_dialogName.target.visible = false;
  316. _ui.m_dialogHead.target.visible = false;
  317. _ui.m_list.visible = true;
  318. _ui.m_list.RemoveChildrenToPool();
  319. string[] list = Regex.Split(content, "//");
  320. _ui.m_list.itemRenderer = (int index, GObject item) =>
  321. {
  322. string itemInfo = list[index];
  323. string[] itemInfoList = Regex.Split(itemInfo, "=");
  324. UI_ListDialogItem dialogItem = UI_ListDialogItem.Proxy(item);
  325. dialogItem.m_txtContent.text = itemInfoList[0];
  326. dialogItem.target.data = itemInfoList.Length > 1 ? itemInfoList[1] : null;
  327. UI_ListDialogItem.ProxyEnd();
  328. };
  329. _ui.m_list.numItems = list.Length;
  330. }
  331. private void ShowDialog(StoryDialogCfg storyDialogCfg)
  332. {
  333. if (storyDialogCfg.showChangeName == 1 && StorageDataManager.Instance.GetStorageValue(ConstStorageId.CHANGE_NAME) == 0)
  334. {
  335. if (_autoPlay)
  336. {
  337. _ui.m_btnAutoPlay.selected = false;
  338. OnClickBtnAutoPlay();
  339. }
  340. GameController.ShowCreateRole();
  341. }
  342. _ui.m_loaMask.url = ResPathUtil.GetBgImgPath(storyDialogCfg.maskRes);
  343. _ui.m_btnAutoPlay.enabled = true;
  344. _ui.m_list.visible = false;
  345. var content = storyDialogCfg.content.Replace("self", RoleDataManager.roleName);
  346. string words = content;
  347. string roleName = storyDialogCfg.name;
  348. string headRes = storyDialogCfg.head;
  349. string headAniRes = storyDialogCfg.headAni;
  350. if (roleName == "self")
  351. {
  352. roleName = RoleDataManager.roleName;
  353. }
  354. //回顾
  355. if (roleName != null)
  356. {
  357. _dialogListLookBack.Add("[color=#FDA2B1]" + roleName + "[/color]");
  358. }
  359. if (!string.IsNullOrEmpty(headAniRes) || storyDialogCfg.suitId > 0)
  360. {
  361. //显示对话框半身像
  362. _ui.m_dialogText.target.visible = false;
  363. _ui.m_dialogName.target.visible = false;
  364. _ui.m_dialogHead.target.visible = true;
  365. _ui.m_dialogHead.m_txtName.text = roleName;
  366. _ui.m_dialogHead.m_comphead.m_head.visible = false;
  367. _ui.m_dialogHead.m_comphead.m_holder.visible = true;
  368. var headAniCfg = HeadAniCfgArray.Instance.GetCfg(headAniRes);
  369. if (headAniCfg != null && !string.IsNullOrEmpty(headAniCfg.headAni))
  370. {
  371. //独立动画
  372. _ui.m_dialogHead.m_compDressUp.target.visible = false;
  373. _ui.m_dialogHead.m_comphead.target.visible = true;
  374. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_dialogHead.m_comphead.m_holder, "ui_nzbq", headAniCfg.headAni);
  375. }
  376. else
  377. {
  378. //换装
  379. _ui.m_dialogHead.m_compDressUp.target.visible = true;
  380. _ui.m_dialogHead.m_comphead.target.visible = false;
  381. _dressUpObjUI.ResetSceneObj(80, true, false, null, false);
  382. if (storyDialogCfg.suitId > 0)
  383. {
  384. _dressUpObjUI.dressUpObj.PutOnSuitCfg(storyDialogCfg.suitId, false, new int[] { ConstDressUpItemType.SHOU_CHI_WU }, false, false);
  385. }
  386. else
  387. {
  388. _dressUpObjUI.dressUpObj.PutOnDressUpData(CustomSuitDataManager.GetCurrentSuitData().dressUpData);
  389. if (_dressUpObjUI.dressUpObj.actionId > 0)
  390. {
  391. _dressUpObjUI.dressUpObj.CancelAction(true);
  392. }
  393. _dressUpObjUI.dressUpObj.PutOnDressUpData(_dressUpObjUI.dressUpObj.DressUpDataClone(), new int[] { ConstDressUpItemType.SHOU_CHI_WU });
  394. }
  395. if (headAniCfg != null && headAniCfg.faceId > 0)
  396. {
  397. //表情
  398. _dressUpObjUI.dressUpObj.AddOrRemove(headAniCfg.faceId, false);
  399. _dressUpObjUI.UpdateWrapper(_ui.m_dialogHead.m_compDressUp.m_holder);
  400. }
  401. }
  402. _wordTextField = _ui.m_dialogHead.m_txtContent;
  403. _arrow = _ui.m_dialogHead.m_iconNext;
  404. }
  405. else if (!string.IsNullOrEmpty(headRes))
  406. {
  407. _ui.m_dialogText.target.visible = false;
  408. _ui.m_dialogName.target.visible = false;
  409. _ui.m_dialogHead.target.visible = true;
  410. _ui.m_dialogHead.m_txtName.text = roleName;
  411. _ui.m_dialogHead.m_comphead.m_head.visible = true;
  412. _ui.m_dialogHead.m_comphead.m_holder.visible = false;
  413. _ui.m_dialogHead.m_comphead.m_head.url = ResPathUtil.GetNpcHeadPath(headRes);
  414. _wordTextField = _ui.m_dialogHead.m_txtContent;
  415. _arrow = _ui.m_dialogHead.m_iconNext;
  416. }
  417. else if (!string.IsNullOrEmpty(roleName))
  418. {
  419. _ui.m_dialogText.target.visible = false;
  420. _ui.m_dialogName.target.visible = true;
  421. _ui.m_dialogHead.target.visible = false;
  422. _ui.m_dialogName.m_txtName.text = roleName;
  423. _wordTextField = _ui.m_dialogName.m_txtContent;
  424. _arrow = _ui.m_dialogName.m_iconNext;
  425. }
  426. else
  427. {
  428. _ui.m_dialogText.target.visible = true;
  429. _ui.m_dialogName.target.visible = false;
  430. _ui.m_dialogHead.target.visible = false;
  431. _wordTextField = _ui.m_dialogText.m_txtContent;
  432. _arrow = _ui.m_dialogText.m_iconNext;
  433. }
  434. _wordList = Regex.Split(words, "&&");
  435. _wordIndex = 0;
  436. ShowNextDialog();
  437. }
  438. private void ShowNextDialog()
  439. {
  440. if (_wordList != null && _wordList.Length > _wordIndex)
  441. {
  442. string itemInfo = _wordList[_wordIndex];
  443. string[] itemInfoList = Regex.Split(itemInfo, "=");
  444. _currentWords = itemInfoList[0];
  445. if (itemInfoList.Length > 1)
  446. {
  447. _wordTextField.data = itemInfoList[1];
  448. }
  449. else
  450. {
  451. _wordTextField.data = null;
  452. }
  453. StartShowLetters();
  454. }
  455. else
  456. {
  457. OnStepComplete();
  458. }
  459. }
  460. private void ShowCurrentWords()
  461. {
  462. _arrow.target.visible = true;
  463. Timers.inst.Remove(UpdateLetters);
  464. _wordTextField.text = _currentWords;
  465. _dialogListLookBack.Add(_currentWords);
  466. _isShowLetters = false;
  467. _wordIndex++;
  468. if (_autoPlay)
  469. {
  470. Timers.inst.Add(GameConst.NEXT_WORDS_INTERVAL_MAX / _speedAutoPlay, 1, ShowNextWords);
  471. }
  472. }
  473. private void ShowNextWords(object param = null)
  474. {
  475. if (_wordTextField != null)
  476. {
  477. if (_isShowLetters)
  478. {
  479. ShowCurrentWords();
  480. }
  481. else
  482. {
  483. string stepID = (string)_wordTextField.data;
  484. if (stepID != null)
  485. {
  486. OnStepComplete(stepID);
  487. }
  488. else
  489. {
  490. ShowNextDialog();
  491. }
  492. }
  493. }
  494. }
  495. private void StartShowLetters()
  496. {
  497. _isShowLetters = true;
  498. _arrow.target.visible = false;
  499. _wordTextField.verticalAlign = VertAlignType.Top;
  500. _wordTextField.text = "";
  501. ArrayList letters = StoryUtil.GetLettersList(_currentWords);
  502. Timers.inst.Add(GameConst.LETTERS_INTERVAL_MAX / _speedAutoPlay, 0, UpdateLetters, letters);
  503. }
  504. private void UpdateLetters(object param)
  505. {
  506. ArrayList letters = (ArrayList)param;
  507. if (letters == null || letters.Count <= 0)
  508. {
  509. ShowCurrentWords();
  510. }
  511. else
  512. {
  513. string letter = (string)letters[0];
  514. letters.RemoveAt(0);
  515. _wordTextField.text = _wordTextField.text + letter;
  516. }
  517. }
  518. private void UpdateBg(string value)
  519. {
  520. if (value.Length > 0)
  521. {
  522. SceneController.UpdateDialogBg(value, _sceneObject);
  523. }
  524. }
  525. private void UpdatePic(string value)
  526. {
  527. if (value.Length > 0)
  528. {
  529. SceneController.UpdateDialogPic(value, _sceneObject);
  530. }
  531. }
  532. private void UpdateMusic(string value)
  533. {
  534. if (value.Length > 0)
  535. {
  536. if (value == "0")
  537. {
  538. MusicManager.Instance.Stop();
  539. }
  540. else
  541. {
  542. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(value, "mp3"));
  543. }
  544. }
  545. }
  546. private void PlayEffect(string[] infos)
  547. {
  548. }
  549. private void PlayShake(int[] shakeInfoArr)
  550. {
  551. if (shakeInfoArr != null && shakeInfoArr.Length > 0)
  552. {
  553. Vector3 position = _sceneObject.transform.position;
  554. position.x = (float)shakeInfoArr[0] / GameConst.PIXELS_PER_UNITY_UNIT;
  555. position.y = (float)shakeInfoArr[1] / GameConst.PIXELS_PER_UNITY_UNIT;
  556. _sceneObject.transform.position = position;
  557. float attenuationX = (float)shakeInfoArr[2] / GameConst.PIXELS_PER_UNITY_UNIT;
  558. float attenuationY = (float)shakeInfoArr[3] / GameConst.PIXELS_PER_UNITY_UNIT;
  559. float interval = (float)shakeInfoArr[4] / 1000;
  560. float duration = (float)shakeInfoArr[5] / 1000;
  561. int repeat = Mathf.RoundToInt(duration / interval);
  562. Timers.inst.Add(interval, 0, UpdateShake, new float[] { attenuationX, attenuationY });
  563. }
  564. }
  565. private void UpdateShake(object param)
  566. {
  567. float[] attenuations = param as float[];
  568. float attenuationX = attenuations[0];
  569. float attenuationY = attenuations[1];
  570. Vector3 position = _sceneObject.transform.position;
  571. bool done = false;
  572. bool doneX = false;
  573. float absX = Mathf.Abs(position.x);
  574. if (absX > attenuationX)
  575. {
  576. int dir = (int)(position.x / absX);
  577. position.x = Mathf.Abs(position.x) - attenuationX;
  578. position.x *= -1 * dir;
  579. }
  580. else
  581. {
  582. doneX = true;
  583. position.x = 0;
  584. }
  585. bool doneY = false;
  586. float absY = Mathf.Abs(position.y);
  587. if (absY > attenuationY)
  588. {
  589. int dir = (int)(position.y / absY);
  590. position.y = Mathf.Abs(position.y) - attenuationY;
  591. position.y *= -1 * dir;
  592. }
  593. else
  594. {
  595. doneY = true;
  596. position.y = 0;
  597. }
  598. done = doneX && doneY;
  599. _sceneObject.transform.position = position;
  600. if (done)
  601. {
  602. Timers.inst.Remove(UpdateShake);
  603. }
  604. }
  605. private void Over(bool isSkip = false)
  606. {
  607. if (_onCompleteStoryDialogCall != null)
  608. {
  609. _onCompleteStoryDialogCall(isSkip, _onCompleteStoryDialogCallParam);
  610. }
  611. }
  612. private void UpdateSpeedUpBtn()
  613. {
  614. if (_speedAutoPlay > 1)
  615. {
  616. _ui.m_btnSpeedUp.text = "x" + _speedAutoPlay;
  617. }
  618. else
  619. {
  620. _ui.m_btnSpeedUp.text = "";
  621. }
  622. }
  623. private void StopAutoPlay()
  624. {
  625. _autoPlay = false;
  626. _ui.m_btnAutoPlay.selected = false;
  627. Timers.inst.Remove(ShowNextWords);
  628. }
  629. }
  630. }