UIStartController.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using System.Collections;
  3. using Core;
  4. using DG.Tweening;
  5. using ExtensionMethods;
  6. using I2.Loc;
  7. using UnityEngine;
  8. public class UIStartController : MonoBehaviour
  9. {
  10. private void Awake()
  11. {
  12. this._startLocalize = this._startLabel.GetComponent<Localize>();
  13. }
  14. private void Start()
  15. {
  16. this._widget.SetAnchor(R.Ui.RootWidget.gameObject, 0, 0, 0, 0);
  17. this._black.color = Color.black;
  18. R.Camera.Controller.IsFollowPivot = false;
  19. R.Camera.Controller.MovableCamera.position = Vector3.zero.SetZ(-10f);
  20. R.Mode.Reset();
  21. R.Mode.EnterMode(Mode.AllMode.UI);
  22. R.Ui.Pause.Enabled = false;
  23. R.Ui.HideUI(true);
  24. UIKeyInput.SaveAndSetHoveredObject(this.circle.gameObject);
  25. base.StartCoroutine(this.FadeInCoroutine());
  26. for (int i = 0; i < this._useOnStandalone.Length; i++)
  27. {
  28. this._useOnStandalone[i].SetActive(false);
  29. }
  30. if (!SaveManager.IsAutoSaveDataExists)
  31. {
  32. this._mainContainerGameObject.SetActive(false);
  33. this._userNameGameObject.SetActive(true);
  34. this._sensitiveWordsFilter = new SensitiveWordsFilter();
  35. }
  36. }
  37. private IEnumerator FadeInCoroutine()
  38. {
  39. yield return DOTween.To(() => this._black.color, delegate(Color c)
  40. {
  41. this._black.color = c;
  42. }, Color.clear, 1f).WaitForCompletion();
  43. this._startBtn.SetActive(true);
  44. this._optionsBtn.SetActive(true);
  45. yield break;
  46. }
  47. private void OnEnable()
  48. {
  49. this._startLocalize.Term = ((!SaveManager.IsAutoSaveDataExists) ? "ui/start/start" : "ui/start/_continue");
  50. }
  51. private void Update()
  52. {
  53. if (Core.Input.UI.Cancel.OnClick && this._mainContainerGameObject.activeSelf)
  54. {
  55. this.OnExitClick();
  56. }
  57. }
  58. public void OnStartClick()
  59. {
  60. if (!Core.Input.JoystickIsOpen)
  61. {
  62. return;
  63. }
  64. if (UIStartController.IsEnterWithVoice)
  65. {
  66. base.StartCoroutine(this.OnStartWithVoiceOverClick());
  67. }
  68. else
  69. {
  70. base.StartCoroutine(this.OnStartClickCoroutine());
  71. }
  72. }
  73. private IEnumerator ProgressAnimCoroutine()
  74. {
  75. float nowprocess = 0f;
  76. float currentVelocity = 0f;
  77. float smoothTime = 0.1f;
  78. while (nowprocess < 99.5f)
  79. {
  80. float toProcess;
  81. if (R.SceneGate.Progress < 0.9f)
  82. {
  83. toProcess = R.SceneGate.Progress * 100f;
  84. }
  85. else
  86. {
  87. toProcess = 100f;
  88. }
  89. if (nowprocess < toProcess)
  90. {
  91. nowprocess = Mathf.SmoothDamp(nowprocess, toProcess, ref currentVelocity, smoothTime);
  92. }
  93. this._loading.value = nowprocess / 100f;
  94. yield return null;
  95. }
  96. DOTween.To(() => this._black.color, delegate(Color c)
  97. {
  98. this._black.color = c;
  99. }, Color.black, 2f).WaitForCompletion();
  100. InputSetting.Resume(false);
  101. R.Mode.ExitMode(Mode.AllMode.UI);
  102. UIKeyInput.LoadHoveredObject();
  103. R.SceneGate.AllowSceneActivation = true;
  104. R.Ui.ShowUI(false);
  105. yield return new WaitForSeconds(3f);
  106. yield break;
  107. }
  108. private IEnumerator OnStartClickCoroutine()
  109. {
  110. this._mainLayer.Disappear();
  111. InputSetting.Stop(false);
  112. UIKeyInput.LoadHoveredObject();
  113. this._loading.alpha = 1f;
  114. R.SceneGate.AllowSceneActivation = false;
  115. R.Ui.Pause.Enabled = true;
  116. if (SaveManager.IsAutoSaveDataExists)
  117. {
  118. yield return R.GameData.Load();
  119. SingletonMono<MobileInputPlayer>.Instance.VisiableBladeStorm();
  120. LevelManager.LoadLevelByPosition(R.GameData.SceneName, R.GameData.PlayerPosition, true);
  121. yield return base.StartCoroutine(this.ProgressAnimCoroutine());
  122. R.Player.Transform.position = R.GameData.PlayerPosition;
  123. R.Player.Action.TurnRound(R.GameData.PlayerAttributeGameData.faceDir);
  124. R.Camera.Controller.CameraResetPostionAfterSwitchScene();
  125. }
  126. else
  127. {
  128. this._tutorialGate.Enter(true);
  129. SingletonMono<MobileInputPlayer>.Instance.VisiableBladeStorm();
  130. base.StartCoroutine(this.ProgressAnimCoroutine());
  131. }
  132. yield break;
  133. }
  134. private IEnumerator OnStartWithVoiceOverClick()
  135. {
  136. yield return base.StartCoroutine(this.MakeNoise(0.1f, null));
  137. this._pressCount++;
  138. if (this._pressCount > 4)
  139. {
  140. if (this._pressCount == 5)
  141. {
  142. this._startLocalize.Term = "ui/start/start_with_voiceover";
  143. this._startLabel.color = Color.red;
  144. }
  145. else
  146. {
  147. R.Audio.PlayEffect(376, null);
  148. InputSetting.Stop(false);
  149. base.StartCoroutine(this.MakeNoise(2f, null));
  150. R.Trophy.AwardTrophy(23);
  151. yield return R.Ui.BlackScene.FadeBlack(2f, false);
  152. InputSetting.Resume(false);
  153. R.Mode.ExitMode(Mode.AllMode.UI);
  154. UIKeyInput.LoadHoveredObject();
  155. UIStartController.IsEnterWithVoice = false;
  156. this._tutorialGate.data.ToLevelId = "ui_story_start";
  157. this._tutorialGate.data.ToId = 1;
  158. R.Ui.Pause.Enabled = true;
  159. this._tutorialGate.Enter(false);
  160. SingletonMono<MobileInputPlayer>.Instance.VisiableBladeStorm();
  161. }
  162. }
  163. yield break;
  164. }
  165. private IEnumerator MakeNoise(float seconds, Action callback = null)
  166. {
  167. InputSetting.Stop(false);
  168. CameraFilterUtils.Create<CameraFilterPack_TV_Old>(R.Ui.CameraGO);
  169. yield return new WaitForSeconds(seconds);
  170. InputSetting.Resume(false);
  171. CameraFilterUtils.Remove<CameraFilterPack_TV_Old>(R.Ui.CameraGO);
  172. if (callback != null)
  173. {
  174. callback();
  175. }
  176. yield break;
  177. }
  178. public void OnExitClick()
  179. {
  180. Application.Quit();
  181. }
  182. public void ChangeUserName()
  183. {
  184. if (string.IsNullOrEmpty(this._userNameInput.value))
  185. {
  186. return;
  187. }
  188. string value;
  189. if (this._sensitiveWordsFilter.Filter(this._userNameInput.value, out value))
  190. {
  191. this._userNameInput.value = value;
  192. }
  193. }
  194. public void ConfirmUserName()
  195. {
  196. if (string.IsNullOrEmpty(this._userNameInput.value))
  197. {
  198. return;
  199. }
  200. R.GameData.UserName = this._userNameInput.value;
  201. this._userNameGameObject.SetActive(false);
  202. this._mainContainerGameObject.SetActive(true);
  203. Analytics.SetUser(SystemInfo.deviceUniqueIdentifier, TGTUserType.TGTTypeAnonymous, TGTUserSex.TGTSexUnknown, 0, R.GameData.UserName);
  204. }
  205. public static bool IsEnterWithVoice;
  206. private int _pressCount;
  207. [SerializeField]
  208. private UIWidget _widget;
  209. [SerializeField]
  210. private SceneGate _tutorialGate;
  211. [SerializeField]
  212. private UISprite _black;
  213. [SerializeField]
  214. private UIProgressBar _loading;
  215. [SerializeField]
  216. private UITexture circle;
  217. [SerializeField]
  218. private UILayerController _mainLayer;
  219. [SerializeField]
  220. private UILabel _startLabel;
  221. private Localize _startLocalize;
  222. [SerializeField]
  223. private GameObject[] _useOnStandalone;
  224. [SerializeField]
  225. private UIInput _userNameInput;
  226. [SerializeField]
  227. private GameObject _mainContainerGameObject;
  228. [SerializeField]
  229. private GameObject _userNameGameObject;
  230. [SerializeField]
  231. private GameObject _startBtn;
  232. [SerializeField]
  233. private GameObject _optionsBtn;
  234. private SensitiveWordsFilter _sensitiveWordsFilter;
  235. }