UIPlayerDeadMsgboxController.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Colorful;
  6. using Core;
  7. using DG.Tweening;
  8. using DG.Tweening.Core;
  9. using DG.Tweening.Plugins.Options;
  10. using UnityEngine;
  11. public class UIPlayerDeadMsgboxController : MonoBehaviour
  12. {
  13. private int DeathCount
  14. {
  15. get
  16. {
  17. return RoundStorage.Get("DeathCount", 0);
  18. }
  19. set
  20. {
  21. RoundStorage.Set("DeathCount", value);
  22. }
  23. }
  24. private bool HasEnteredLevelSelectSystem
  25. {
  26. get
  27. {
  28. return SaveStorage.Get("HasEnteredLevelSelectSystem", false);
  29. }
  30. set
  31. {
  32. SaveStorage.Set("HasEnteredLevelSelectSystem", value);
  33. }
  34. }
  35. private void Start()
  36. {
  37. this.listener = R.Player.GetComponent<PlayerAnimEventListener>();
  38. this.listener.OnPlayerDead += this.OnPlayerDead;
  39. }
  40. private void OnDestroy()
  41. {
  42. if (this.listener)
  43. {
  44. this.listener.OnPlayerDead -= this.OnPlayerDead;
  45. }
  46. }
  47. private void OnPlayerDead(object sender, EventArgs e)
  48. {
  49. if (R.SceneData.BloodPalaceMode)
  50. {
  51. return;
  52. }
  53. if (UILanguage.IsChinese)
  54. {
  55. List<List<int>> list = new List<List<int>>
  56. {
  57. new List<int>
  58. {
  59. 1,
  60. 5,
  61. 8,
  62. 10
  63. },
  64. new List<int>
  65. {
  66. 2,
  67. 6,
  68. 9,
  69. 10
  70. },
  71. new List<int>
  72. {
  73. 3,
  74. 7,
  75. 8,
  76. 9,
  77. 10
  78. },
  79. new List<int>
  80. {
  81. 4,
  82. 5,
  83. 6,
  84. 7,
  85. 8,
  86. 9,
  87. 10
  88. }
  89. };
  90. string text = "又㕛叒叕";
  91. if (this.DeathCount <= 10)
  92. {
  93. StringBuilder stringBuilder = new StringBuilder("你");
  94. for (int i = 0; i < 4; i++)
  95. {
  96. if (list[i].Contains(this.DeathCount))
  97. {
  98. stringBuilder.Append(text[i]);
  99. }
  100. }
  101. stringBuilder.Append("死了");
  102. this._youAreDie.text = stringBuilder.ToString();
  103. }
  104. else
  105. {
  106. this._youAreDie.text = "我已经记不清了";
  107. }
  108. }
  109. else if (this.DeathCount == 0)
  110. {
  111. this._youAreDie.text = "YOU DIED";
  112. }
  113. else if (this.DeathCount <= 10)
  114. {
  115. StringBuilder stringBuilder2 = new StringBuilder("YOU DIE AGAIN");
  116. for (int j = 0; j < this.DeathCount - 1; j++)
  117. {
  118. stringBuilder2.Append('N');
  119. }
  120. this._youAreDie.text = stringBuilder2.ToString();
  121. }
  122. else
  123. {
  124. this._youAreDie.text = "I CAN NEVER REMEMBER";
  125. }
  126. this.OpenWithAnim();
  127. }
  128. private void Open()
  129. {
  130. this._backBtn.transform.parent.gameObject.SetActive(this.HasEnteredLevelSelectSystem);
  131. R.Mode.EnterMode(Mode.AllMode.UI);
  132. R.Ui.Pause.Enabled = false;
  133. UIKeyInput.SaveAndSetHoveredObject(this._resumeBtn);
  134. this.playerDeadWindow.gameObject.SetActive(true);
  135. CameraFilterUtils.Create<CameraFilterPack_TV_80>(R.Ui.CameraGO);
  136. AnalogTV analogTV = R.Ui.CameraGO.AddComponent<AnalogTV>();
  137. analogTV.Shader = Shader.Find("Hidden/Colorful/Analog TV");
  138. analogTV.NoiseIntensity = 1f;
  139. analogTV.ScanlinesIntensity = 0f;
  140. analogTV.ScanlinesCount = 696;
  141. analogTV.Distortion = 0.18f;
  142. analogTV.CubicDistortion = 0f;
  143. analogTV.Scale = 1.02f;
  144. }
  145. private YieldInstruction OpenWithAnim()
  146. {
  147. return base.StartCoroutine(this.OpenWithAnimCoroutine());
  148. }
  149. private IEnumerator OpenWithAnimCoroutine()
  150. {
  151. R.Audio.StopBGM(true);
  152. yield return LevelManager.LoadLevelByGateId("empty", SceneGate.OpenType.None);
  153. this.Open();
  154. AnalogTV analogTV = R.Ui.CameraGO.GetComponent<AnalogTV>();
  155. analogTV.Scale = 0f;
  156. yield return DOTween.To(() => analogTV.Scale, delegate(float scale)
  157. {
  158. analogTV.Scale = scale;
  159. }, 1.02f, 0.5f).SetUpdate(true).WaitForCompletion();
  160. yield break;
  161. }
  162. private void Close()
  163. {
  164. CameraFilterUtils.Remove<CameraFilterPack_TV_80>(R.Ui.CameraGO);
  165. UnityEngine.Object.Destroy(R.Ui.CameraGO.GetComponent<AnalogTV>());
  166. this.playerDeadWindow.gameObject.SetActive(false);
  167. UIKeyInput.LoadHoveredObject();
  168. R.Ui.Pause.Enabled = true;
  169. R.Mode.ExitMode(Mode.AllMode.UI);
  170. }
  171. private YieldInstruction CloseWithAnim()
  172. {
  173. AnalogTV analogTV = R.Ui.CameraGO.GetComponent<AnalogTV>();
  174. return DOTween.To(() => analogTV.Scale, delegate(float scale)
  175. {
  176. analogTV.Scale = scale;
  177. }, 0f, 0.5f).SetUpdate(true).OnComplete(delegate
  178. {
  179. this.Close();
  180. }).WaitForCompletion();
  181. }
  182. public void Go2StartScene()
  183. {
  184. if (!Core.Input.JoystickIsOpen)
  185. {
  186. return;
  187. }
  188. base.StartCoroutine(this.OnRoundOverCoroutine());
  189. }
  190. private IEnumerator OnRoundOverCoroutine()
  191. {
  192. InputSetting.Stop(false);
  193. R.Ui.BlackScene.FadeBlack(0.3f, false);
  194. yield return this.CloseWithAnim();
  195. R.Ui.BlackScene.FadeTransparent(0.3f, false);
  196. yield return LevelManager.OnRoundOver();
  197. InputSetting.Resume(false);
  198. SingletonMono<MobileInputPlayer>.Instance.Visible = false;
  199. yield break;
  200. }
  201. public void Resurrect()
  202. {
  203. if (!Core.Input.JoystickIsOpen)
  204. {
  205. return;
  206. }
  207. base.StartCoroutine(this.OnPlayerDieCoroutine());
  208. }
  209. private IEnumerator OnPlayerDieCoroutine()
  210. {
  211. InputSetting.Stop(false);
  212. R.Ui.BlackScene.FadeBlack(0.3f, false);
  213. yield return this.CloseWithAnim();
  214. yield return LevelManager.OnPlayerDie(true);
  215. R.Ui.BlackScene.FadeTransparent(0.3f, false);
  216. InputSetting.Resume(false);
  217. yield break;
  218. }
  219. [SerializeField]
  220. private GameObject playerDeadWindow;
  221. [SerializeField]
  222. private GameObject _resumeBtn;
  223. [SerializeField]
  224. private GameObject _backBtn;
  225. [SerializeField]
  226. private UILabel _youAreDie;
  227. private PlayerAnimEventListener listener;
  228. }