StoryE23P16.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections;
  3. using System.Text;
  4. using Core;
  5. using DG.Tweening;
  6. using ExtensionMethods;
  7. using I2.Loc;
  8. using UnityEngine;
  9. public class StoryE23P16 : BaseBehaviour
  10. {
  11. private void OnDestroy()
  12. {
  13. this._gateL.DisAppear();
  14. this._gateR.DisAppear();
  15. this._airWall1.SetActive(false);
  16. this._airWall2.SetActive(false);
  17. SingletonMono<MobileInputPlayer>.Instance.HideL2R2(true);
  18. }
  19. private void Update()
  20. {
  21. if (Core.Input.Game.L2.OnPressed)
  22. {
  23. StoryE23P16.choice = 2;
  24. }
  25. if (Core.Input.Game.R2.OnPressed)
  26. {
  27. StoryE23P16.choice = 3;
  28. }
  29. }
  30. private void OnTriggerEnter2D(Collider2D collision)
  31. {
  32. if (collision.CompareTag("Player"))
  33. {
  34. base.StartCoroutine(this.Sequence0());
  35. UnityEngine.Object.Destroy(base.GetComponent<Collider2D>());
  36. }
  37. }
  38. private IEnumerator Sequence0()
  39. {
  40. this._gateL.Appear();
  41. this._gateR.Appear();
  42. this._airWall1.SetActive(true);
  43. this._airWall2.SetActive(true);
  44. string userName = R.Player.UserName;
  45. if (string.IsNullOrEmpty(userName))
  46. {
  47. userName = ScriptLocalization.ui.anonymous;
  48. }
  49. this._question.text = ScriptLocalization.Story.e23s8 + "\n" + userName;
  50. this._yes.text = ScriptLocalization.Story.e23s14;
  51. this._no.text = ScriptLocalization.Story.e23s15;
  52. this._question.fontSize = Mathf.Clamp(-4 * Encoding.Default.GetBytes(userName).Length / 2 + 100, 16, 40);
  53. yield return this.Fade(0f, 1f, true);
  54. SingletonMono<MobileInputPlayer>.Instance.ShowL2R2(this._yes.text, this._no.text);
  55. StoryE23P16.choice = 1;
  56. while (StoryE23P16.choice < 2)
  57. {
  58. yield return new WaitForFixedUpdate();
  59. }
  60. yield return this.Fade(1f, 0f, true);
  61. SingletonMono<MobileInputPlayer>.Instance.HideL2R2(false);
  62. int num = StoryE23P16.choice;
  63. if (num != 2)
  64. {
  65. if (num == 3)
  66. {
  67. R.Audio.PlayEffect(380, null);
  68. this._question.text = ScriptLocalization.Story.e23s9;
  69. this._yes.text = string.Empty;
  70. this._no.text = string.Empty;
  71. this._question.fontSize = 40;
  72. yield return this.Fade(0f, 1f, false);
  73. yield return this._question.transform.DOShakePosition(2f, 0.1f, 10, 90f, false, true).WaitForCompletion();
  74. yield return this.Fade(1f, 0f, false);
  75. }
  76. }
  77. else
  78. {
  79. R.Audio.PlayEffect(381, null);
  80. }
  81. StoryE23P16.choice = 0;
  82. this._question.text = ScriptLocalization.Story.e23s10;
  83. this._yes.text = ScriptLocalization.Story.e23s14;
  84. this._no.text = ScriptLocalization.Story.e23s15;
  85. this._question.fontSize = 40;
  86. yield return this.Fade(0f, 1f, true);
  87. SingletonMono<MobileInputPlayer>.Instance.ShowL2R2(this._yes.text, this._no.text);
  88. StoryE23P16.choice = 1;
  89. while (StoryE23P16.choice < 2)
  90. {
  91. yield return new WaitForFixedUpdate();
  92. }
  93. SingletonMono<MobileInputPlayer>.Instance.HideL2R2(false);
  94. yield return this.Fade(1f, 0f, true);
  95. int num2 = StoryE23P16.choice;
  96. if (num2 != 2)
  97. {
  98. if (num2 == 3)
  99. {
  100. R.Audio.PlayEffect(380, null);
  101. }
  102. }
  103. else
  104. {
  105. R.Audio.PlayEffect(381, null);
  106. }
  107. StoryE23P16.choice = 0;
  108. this._question.text = ScriptLocalization.Story.e23s11;
  109. this._yes.text = ScriptLocalization.Story.e23s14;
  110. this._no.text = ScriptLocalization.Story.e23s15;
  111. yield return this.Fade(0f, 1f, true);
  112. SingletonMono<MobileInputPlayer>.Instance.ShowL2R2(this._yes.text, this._no.text);
  113. StoryE23P16.choice = 1;
  114. while (StoryE23P16.choice < 2)
  115. {
  116. yield return new WaitForFixedUpdate();
  117. }
  118. SingletonMono<MobileInputPlayer>.Instance.HideL2R2(false);
  119. yield return this.Fade(1f, 0f, true);
  120. this._yes.text = string.Empty;
  121. this._no.text = string.Empty;
  122. if (StoryE23P16.choice == 2)
  123. {
  124. R.GameData.Difficulty = 1;
  125. R.GameData.Save(true);
  126. this._question.text = ScriptLocalization.Story.e23s12;
  127. yield return this.Fade(0f, 1f, true);
  128. StoryE23P16.choice = 0;
  129. }
  130. else if (StoryE23P16.choice == 3)
  131. {
  132. this._question.text = ScriptLocalization.Story.e23s16;
  133. this._yes.text = ScriptLocalization.Story.e23s14;
  134. this._no.text = ScriptLocalization.Story.e23s15;
  135. yield return this.Fade(0f, 1f, true);
  136. SingletonMono<MobileInputPlayer>.Instance.ShowL2R2(this._yes.text, this._no.text);
  137. StoryE23P16.choice = 1;
  138. while (StoryE23P16.choice < 2)
  139. {
  140. yield return new WaitForFixedUpdate();
  141. }
  142. SingletonMono<MobileInputPlayer>.Instance.HideL2R2(false);
  143. yield return this.Fade(1f, 0f, true);
  144. this._yes.text = string.Empty;
  145. this._no.text = string.Empty;
  146. int num3 = StoryE23P16.choice;
  147. if (num3 != 2)
  148. {
  149. if (num3 == 3)
  150. {
  151. R.GameData.Difficulty = 0;
  152. R.GameData.Save(true);
  153. this._question.text = this.DifficultyStr();
  154. yield return this.Fade(0f, 1f, true);
  155. }
  156. }
  157. else
  158. {
  159. R.GameData.Difficulty = 1;
  160. R.GameData.Save(true);
  161. this._question.text = this.DifficultyStr();
  162. yield return this.Fade(0f, 1f, true);
  163. }
  164. StoryE23P16.choice = 0;
  165. }
  166. this._gateL.DisAppear();
  167. this._gateR.DisAppear();
  168. this._airWall1.SetActive(false);
  169. this._airWall2.SetActive(false);
  170. R.Ui.Pause.Enabled = false;
  171. yield return R.Ui.BlackScene.FadeBlack(3f, false);
  172. R.Audio.PlayEffect(347, null);
  173. UIStartController.IsEnterWithVoice = true;
  174. yield return R.Ui.ShowUI(false);
  175. this._gate.Enter(false);
  176. R.Ui.Pause.Enabled = true;
  177. yield break;
  178. }
  179. private string DifficultyStr()
  180. {
  181. switch (R.GameData.Difficulty)
  182. {
  183. case 0:
  184. return ScriptLocalization.Story.e23s13;
  185. case 1:
  186. return ScriptLocalization.Story.e23s17;
  187. case 2:
  188. return ScriptLocalization.Story.e23s12;
  189. case 3:
  190. return ScriptLocalization.Story.e23s18;
  191. default:
  192. return string.Empty;
  193. }
  194. }
  195. private YieldInstruction Fade(float startValue, float endValue, bool withAudio = true)
  196. {
  197. if (withAudio)
  198. {
  199. R.Audio.PlayEffect((startValue >= endValue) ? 139 : 2, new Vector3?(base.transform.position));
  200. }
  201. int num = 1;
  202. DOTween.To(delegate(float a)
  203. {
  204. this._question.color = this._question.color.SetAlpha(a);
  205. }, startValue, endValue, (float)num);
  206. DOTween.To(delegate(float a)
  207. {
  208. this._yes.color = this._yes.color.SetAlpha(a);
  209. }, startValue, endValue, (float)num);
  210. return DOTween.To(delegate(float a)
  211. {
  212. this._no.color = this._no.color.SetAlpha(a);
  213. }, startValue, endValue, (float)num).WaitForCompletion();
  214. }
  215. public static int choice;
  216. [SerializeField]
  217. private TextMesh _question;
  218. [SerializeField]
  219. private TextMesh _yes;
  220. [SerializeField]
  221. private TextMesh _no;
  222. [SerializeField]
  223. private SceneGate _gate;
  224. [SerializeField]
  225. private BattleZoneGate _gateL;
  226. [SerializeField]
  227. private BattleZoneGate _gateR;
  228. [SerializeField]
  229. private GameObject _airWall1;
  230. [SerializeField]
  231. private GameObject _airWall2;
  232. }