StoryDialogView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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 GameObject _npcHead;
  18. private DressUpObjUI _dressUpObjUI;
  19. private GoWrapper _npcWrapper;
  20. private GTextField _wordTextField;
  21. //剧情完成回调
  22. private OnCompleteStoryDialogCall _onCompleteStoryDialogCall;
  23. private object _onCompleteStoryDialogCallParam;
  24. //回顾
  25. private List<string> _dialogListLookBack;
  26. //自动播放
  27. private int _speedAutoPlay = 1;
  28. private bool _autoPlay = false;
  29. //剧情状态
  30. private List<StoryDialogCfg> _stepListToRead;
  31. private StoryDialogCfg _currentStepCfg;
  32. private string _nextStepId;
  33. private string[] _wordList;
  34. private int _wordIndex = 0;
  35. private bool _isShowLetters;
  36. private string _currentWords;
  37. private string _stroyStartID;
  38. //屏幕效果中
  39. private Action<object> _onScreenEffectComplete;
  40. public override void Dispose()
  41. {
  42. base.Dispose();
  43. if (_sceneObject != null)
  44. {
  45. GameObject.Destroy(_sceneObject);
  46. _sceneObject = null;
  47. }
  48. _dressUpObjUI?.Dispose();
  49. _dressUpObjUI = null;
  50. _wordTextField = null;
  51. _arrow = null;
  52. _isShowLetters = false;
  53. SceneController.DestroyObjectFromView(_npcHead, _npcWrapper);
  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(ViewName.STORY_LOOK_BACK_VIEW, _stroyStartID);
  177. }
  178. else
  179. {
  180. ViewManager.Show(ViewName.STORY_LOOK_BACK_VIEW, _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. string resPath = ResPathUtil.GetViewEffectPath("ui_nzbq", headAniCfg.headAni);
  375. SceneController.AddObjectToView(null, _npcWrapper, _ui.m_dialogHead.m_comphead.m_holder, resPath, out _npcHead, out _npcWrapper);
  376. }
  377. else
  378. {
  379. //换装
  380. _ui.m_dialogHead.m_compDressUp.target.visible = true;
  381. _ui.m_dialogHead.m_comphead.target.visible = false;
  382. _dressUpObjUI.ResetSceneObj(80, true, false, null, false);
  383. if (storyDialogCfg.suitId > 0)
  384. {
  385. _dressUpObjUI.dressUpObj.PutOnSuitCfg(storyDialogCfg.suitId, false, new int[] { ConstDressUpItemType.SHOU_CHI_WU }, false, false);
  386. }
  387. else
  388. {
  389. _dressUpObjUI.dressUpObj.PutOnDressUpData(CustomSuitDataManager.GetCurrentSuitData().dressUpData);
  390. if (_dressUpObjUI.dressUpObj.actionId > 0)
  391. {
  392. _dressUpObjUI.dressUpObj.CancelAction(true);
  393. _dressUpObjUI.dressUpObj.PutOnDressUpData(_dressUpObjUI.dressUpObj.DressUpDataClone(), new int[] { ConstDressUpItemType.SHOU_CHI_WU });
  394. }
  395. }
  396. if (headAniCfg != null && headAniCfg.faceId > 0)
  397. {
  398. //表情
  399. _dressUpObjUI.dressUpObj.AddOrRemove(headAniCfg.faceId, false);
  400. _dressUpObjUI.UpdateWrapper(_ui.m_dialogHead.m_compDressUp.m_holder);
  401. }
  402. }
  403. _wordTextField = _ui.m_dialogHead.m_txtContent;
  404. _arrow = _ui.m_dialogHead.m_iconNext;
  405. }
  406. else if (!string.IsNullOrEmpty(headRes))
  407. {
  408. _ui.m_dialogText.target.visible = false;
  409. _ui.m_dialogName.target.visible = false;
  410. _ui.m_dialogHead.target.visible = true;
  411. _ui.m_dialogHead.m_txtName.text = roleName;
  412. _ui.m_dialogHead.m_comphead.m_head.visible = true;
  413. _ui.m_dialogHead.m_comphead.m_holder.visible = false;
  414. _ui.m_dialogHead.m_comphead.m_head.url = ResPathUtil.GetNpcHeadPath(headRes);
  415. _wordTextField = _ui.m_dialogHead.m_txtContent;
  416. _arrow = _ui.m_dialogHead.m_iconNext;
  417. }
  418. else if (!string.IsNullOrEmpty(roleName))
  419. {
  420. _ui.m_dialogText.target.visible = false;
  421. _ui.m_dialogName.target.visible = true;
  422. _ui.m_dialogHead.target.visible = false;
  423. _ui.m_dialogName.m_txtName.text = roleName;
  424. _wordTextField = _ui.m_dialogName.m_txtContent;
  425. _arrow = _ui.m_dialogName.m_iconNext;
  426. }
  427. else
  428. {
  429. _ui.m_dialogText.target.visible = true;
  430. _ui.m_dialogName.target.visible = false;
  431. _ui.m_dialogHead.target.visible = false;
  432. _wordTextField = _ui.m_dialogText.m_txtContent;
  433. _arrow = _ui.m_dialogText.m_iconNext;
  434. }
  435. _wordList = Regex.Split(words, "&&");
  436. _wordIndex = 0;
  437. ShowNextDialog();
  438. }
  439. private void ShowNextDialog()
  440. {
  441. if (_wordList != null && _wordList.Length > _wordIndex)
  442. {
  443. string itemInfo = _wordList[_wordIndex];
  444. string[] itemInfoList = Regex.Split(itemInfo, "=");
  445. _currentWords = itemInfoList[0];
  446. if (itemInfoList.Length > 1)
  447. {
  448. _wordTextField.data = itemInfoList[1];
  449. }
  450. else
  451. {
  452. _wordTextField.data = null;
  453. }
  454. StartShowLetters();
  455. }
  456. else
  457. {
  458. OnStepComplete();
  459. }
  460. }
  461. private void ShowCurrentWords()
  462. {
  463. _arrow.target.visible = true;
  464. Timers.inst.Remove(UpdateLetters);
  465. _wordTextField.text = _currentWords;
  466. _dialogListLookBack.Add(_currentWords);
  467. _isShowLetters = false;
  468. _wordIndex++;
  469. if (_autoPlay)
  470. {
  471. Timers.inst.Add(GameConst.NEXT_WORDS_INTERVAL_MAX / _speedAutoPlay, 1, ShowNextWords);
  472. }
  473. }
  474. private void ShowNextWords(object param = null)
  475. {
  476. if (_wordTextField != null)
  477. {
  478. if (_isShowLetters)
  479. {
  480. ShowCurrentWords();
  481. }
  482. else
  483. {
  484. string stepID = (string)_wordTextField.data;
  485. if (stepID != null)
  486. {
  487. OnStepComplete(stepID);
  488. }
  489. else
  490. {
  491. ShowNextDialog();
  492. }
  493. }
  494. }
  495. }
  496. private void StartShowLetters()
  497. {
  498. _isShowLetters = true;
  499. _arrow.target.visible = false;
  500. _wordTextField.verticalAlign = VertAlignType.Top;
  501. _wordTextField.text = "";
  502. ArrayList letters = StoryUtil.GetLettersList(_currentWords);
  503. Timers.inst.Add(GameConst.LETTERS_INTERVAL_MAX / _speedAutoPlay, 0, UpdateLetters, letters);
  504. }
  505. private void UpdateLetters(object param)
  506. {
  507. ArrayList letters = (ArrayList)param;
  508. if (letters == null || letters.Count <= 0)
  509. {
  510. ShowCurrentWords();
  511. }
  512. else
  513. {
  514. string letter = (string)letters[0];
  515. letters.RemoveAt(0);
  516. _wordTextField.text = _wordTextField.text + letter;
  517. }
  518. }
  519. private void UpdateBg(string value)
  520. {
  521. if (value.Length > 0)
  522. {
  523. SceneController.UpdateDialogBg(value, _sceneObject);
  524. }
  525. }
  526. private void UpdatePic(string value)
  527. {
  528. if (value.Length > 0)
  529. {
  530. SceneController.UpdateDialogPic(value, _sceneObject);
  531. }
  532. }
  533. private void UpdateMusic(string value)
  534. {
  535. if (value.Length > 0)
  536. {
  537. if (value == "0")
  538. {
  539. MusicManager.Instance.Stop();
  540. }
  541. else
  542. {
  543. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(value, "mp3"));
  544. }
  545. }
  546. }
  547. private void PlayEffect(string[] infos)
  548. {
  549. }
  550. private void PlayShake(int[] shakeInfoArr)
  551. {
  552. if (shakeInfoArr != null && shakeInfoArr.Length > 0)
  553. {
  554. Vector3 position = _sceneObject.transform.position;
  555. position.x = (float)shakeInfoArr[0] / GameConst.PIXELS_PER_UNITY_UNIT;
  556. position.y = (float)shakeInfoArr[1] / GameConst.PIXELS_PER_UNITY_UNIT;
  557. _sceneObject.transform.position = position;
  558. float attenuationX = (float)shakeInfoArr[2] / GameConst.PIXELS_PER_UNITY_UNIT;
  559. float attenuationY = (float)shakeInfoArr[3] / GameConst.PIXELS_PER_UNITY_UNIT;
  560. float interval = (float)shakeInfoArr[4] / 1000;
  561. float duration = (float)shakeInfoArr[5] / 1000;
  562. int repeat = Mathf.RoundToInt(duration / interval);
  563. Timers.inst.Add(interval, 0, UpdateShake, new float[] { attenuationX, attenuationY });
  564. }
  565. }
  566. private void UpdateShake(object param)
  567. {
  568. float[] attenuations = param as float[];
  569. float attenuationX = attenuations[0];
  570. float attenuationY = attenuations[1];
  571. Vector3 position = _sceneObject.transform.position;
  572. bool done = false;
  573. bool doneX = false;
  574. float absX = Mathf.Abs(position.x);
  575. if (absX > attenuationX)
  576. {
  577. int dir = (int)(position.x / absX);
  578. position.x = Mathf.Abs(position.x) - attenuationX;
  579. position.x *= -1 * dir;
  580. }
  581. else
  582. {
  583. doneX = true;
  584. position.x = 0;
  585. }
  586. bool doneY = false;
  587. float absY = Mathf.Abs(position.y);
  588. if (absY > attenuationY)
  589. {
  590. int dir = (int)(position.y / absY);
  591. position.y = Mathf.Abs(position.y) - attenuationY;
  592. position.y *= -1 * dir;
  593. }
  594. else
  595. {
  596. doneY = true;
  597. position.y = 0;
  598. }
  599. done = doneX && doneY;
  600. _sceneObject.transform.position = position;
  601. if (done)
  602. {
  603. Timers.inst.Remove(UpdateShake);
  604. }
  605. }
  606. private void Over(bool isSkip = false)
  607. {
  608. if (_onCompleteStoryDialogCall != null)
  609. {
  610. _onCompleteStoryDialogCall(isSkip, _onCompleteStoryDialogCallParam);
  611. }
  612. }
  613. private void UpdateSpeedUpBtn()
  614. {
  615. if (_speedAutoPlay > 1)
  616. {
  617. _ui.m_btnSpeedUp.text = "x" + _speedAutoPlay;
  618. }
  619. else
  620. {
  621. _ui.m_btnSpeedUp.text = "";
  622. }
  623. }
  624. private void StopAutoPlay()
  625. {
  626. _autoPlay = false;
  627. _ui.m_btnAutoPlay.selected = false;
  628. Timers.inst.Remove(ShowNextWords);
  629. }
  630. }
  631. }