StoryE18P1.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. using System;
  2. using System.Collections;
  3. using DG.Tweening;
  4. using GameWorld;
  5. using I2.Loc;
  6. using UnityEngine;
  7. public class StoryE18P1 : BaseBehaviour
  8. {
  9. private bool e18Start
  10. {
  11. get
  12. {
  13. return RoundStorage.Get("E18_Start", false);
  14. }
  15. set
  16. {
  17. RoundStorage.Set("E18_Start", value);
  18. }
  19. }
  20. private bool p1
  21. {
  22. get
  23. {
  24. return RoundStorage.Get("E18_P1", false);
  25. }
  26. set
  27. {
  28. RoundStorage.Set("E18_P1", value);
  29. }
  30. }
  31. private bool p2
  32. {
  33. get
  34. {
  35. return RoundStorage.Get("E18_P2", false);
  36. }
  37. set
  38. {
  39. RoundStorage.Set("E18_P2", value);
  40. }
  41. }
  42. private bool p3
  43. {
  44. get
  45. {
  46. return RoundStorage.Get("E18_P3", false);
  47. }
  48. set
  49. {
  50. RoundStorage.Set("E18_P3", value);
  51. }
  52. }
  53. private bool p4
  54. {
  55. get
  56. {
  57. return RoundStorage.Get("E18_P4", false);
  58. }
  59. set
  60. {
  61. RoundStorage.Set("E18_P4", value);
  62. }
  63. }
  64. private bool p5
  65. {
  66. get
  67. {
  68. return RoundStorage.Get("E18_P5", false);
  69. }
  70. set
  71. {
  72. RoundStorage.Set("E18_P5", value);
  73. }
  74. }
  75. private bool p6
  76. {
  77. get
  78. {
  79. return RoundStorage.Get("E18_P6", false);
  80. }
  81. set
  82. {
  83. RoundStorage.Set("E18_P6", value);
  84. }
  85. }
  86. private bool p7
  87. {
  88. get
  89. {
  90. return RoundStorage.Get("E18_P7", false);
  91. }
  92. set
  93. {
  94. RoundStorage.Set("E18_P7", value);
  95. }
  96. }
  97. private bool killTrinity
  98. {
  99. set
  100. {
  101. RoundStorage.Set("E18_KillTrinity", value);
  102. }
  103. }
  104. private bool trinityDie
  105. {
  106. get
  107. {
  108. return this.Trinity == null || this.Trinity.GetComponent<EnemyAttribute>().isDead;
  109. }
  110. }
  111. private void Start()
  112. {
  113. if (!this.e18Start)
  114. {
  115. base.StartCoroutine(this.P1Coroutine());
  116. }
  117. }
  118. public void OnEnable()
  119. {
  120. EventManager.RegisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.EnemyDie), EventManager.ListenerQueue.Game);
  121. }
  122. private void OnDisable()
  123. {
  124. EventManager.UnregisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.EnemyDie), EventManager.ListenerQueue.Game);
  125. }
  126. private IEnumerator P1Coroutine()
  127. {
  128. InputSetting.Stop(false);
  129. while (!R.Player.Attribute.isOnGround)
  130. {
  131. yield return null;
  132. }
  133. yield return new WaitForSeconds(1f);
  134. R.Player.ActionController.TurnRound(-1);
  135. R.Player.ActionController.StartMove();
  136. yield return new WaitForSeconds(2f);
  137. R.Player.ActionController.StopMove();
  138. float startTime = Time.unscaledTime;
  139. this.e18Start = true;
  140. this.gate1.openType = SceneGate.OpenType.None;
  141. this.gate2.openType = SceneGate.OpenType.None;
  142. this._lGate.enabled = false;
  143. this._rGate.enabled = false;
  144. this.Trinity = Singleton<EnemyGenerator>.Instance.GenerateEnemy(EnemyType.崔妮蒂, new Vector2?(this.spwanPoint.position), false, false);
  145. this.Trinity.GetComponent<TrinityAction>().FaceToPlayer();
  146. R.Camera.Controller.IsFollowPivot = false;
  147. R.Camera.Controller.CameraMoveTo(new Vector2(this.spwanPoint.position.x, R.Camera.Controller.MovableCamera.position.y), 1.5f, Ease.Linear);
  148. yield return new WaitForSeconds(5f);
  149. R.Camera.Controller.IsFollowPivot = true;
  150. InputSetting.Resume(false);
  151. this.p1 = true;
  152. yield return R.Audio.PlayVoiceOver("e18t1", null, false);
  153. while (Time.unscaledTime - startTime < 20f)
  154. {
  155. yield return null;
  156. }
  157. if (!this.trinityDie)
  158. {
  159. this.p2 = true;
  160. R.Audio.PlayVoiceOver("e18t2", null, false);
  161. }
  162. while (Time.unscaledTime - startTime < 30f)
  163. {
  164. yield return null;
  165. }
  166. if (!this.trinityDie)
  167. {
  168. this.p3 = true;
  169. R.Audio.PlayVoiceOver("e18t3", null, false);
  170. }
  171. while (Time.unscaledTime - startTime < 45f)
  172. {
  173. yield return null;
  174. }
  175. if (!this.trinityDie)
  176. {
  177. this.p4 = true;
  178. CameraFilterUtils.Create<CameraFilterPack_TV_Old>(null);
  179. yield return R.Audio.PlayVoiceOver("e18t5", null, false);
  180. CameraFilterUtils.Remove<CameraFilterPack_TV_Old>(null);
  181. }
  182. while (Time.unscaledTime - startTime < 60f)
  183. {
  184. yield return null;
  185. }
  186. if (!this.trinityDie)
  187. {
  188. this.p5 = true;
  189. CameraFilterUtils.Create<CameraFilterPack_TV_PlanetMars>(null);
  190. yield return R.Audio.PlayVoiceOver("e18t6", null, false);
  191. R.Ui.Toast.Show(ScriptLocalization.Story.e18s1, 2f, true);
  192. yield return R.Audio.PlayVoiceOver("e18t7", null, false);
  193. CameraFilterUtils.Remove<CameraFilterPack_TV_PlanetMars>(null);
  194. }
  195. while (Time.unscaledTime - startTime < 75f)
  196. {
  197. yield return null;
  198. }
  199. if (!this.trinityDie)
  200. {
  201. this.p6 = true;
  202. yield return R.Audio.PlayVoiceOver("e18t8", null, false);
  203. CameraFilterUtils.Create<CameraFilterPack_TV_PlanetMars>(null);
  204. R.Ui.Toast.Show(ScriptLocalization.Story.e18s2, 2f, true);
  205. yield return R.Audio.PlayVoiceOver("e18t9", null, false);
  206. CameraFilterUtils.Remove<CameraFilterPack_TV_PlanetMars>(null);
  207. yield return R.Audio.PlayVoiceOver("e18t10", null, false);
  208. }
  209. while (Time.unscaledTime - startTime < 135f)
  210. {
  211. yield return null;
  212. }
  213. if (!this.trinityDie)
  214. {
  215. this.p7 = true;
  216. UnityEngine.Object.Destroy(this.Trinity.transform.Find("HurtBox").gameObject);
  217. yield return R.Audio.PlayVoiceOver("e18t11", null, false);
  218. this.gate1.openType = SceneGate.OpenType.Left;
  219. this.gate2.openType = SceneGate.OpenType.Right;
  220. this._lGate.enabled = true;
  221. this._rGate.enabled = true;
  222. }
  223. yield break;
  224. }
  225. private bool EnemyDie(string eventDefine, object sender, EventArgs msg)
  226. {
  227. this.killTrinity = true;
  228. this.DestroyCameraEffect();
  229. if ((this.p1 || this.p2 || this.p3) && !this.p4 && !this.p5 && !this.p6)
  230. {
  231. base.StartCoroutine(this.KillTrinityInP123());
  232. return true;
  233. }
  234. if (this.p1 && this.p2 && this.p3 && (this.p4 || this.p5 || this.p6))
  235. {
  236. base.StartCoroutine(this.KillTinityInP6());
  237. return true;
  238. }
  239. return true;
  240. }
  241. private IEnumerator KillTrinityInP123()
  242. {
  243. yield return R.Audio.PlayVoiceOver("e18t12", null, false);
  244. R.Mode.EnterMode(Mode.AllMode.Normal);
  245. this.gate2.openType = SceneGate.OpenType.Right;
  246. this._lGate.enabled = true;
  247. yield break;
  248. }
  249. private IEnumerator KillTinityInP6()
  250. {
  251. yield return R.Audio.PlayVoiceOver("e18t13", null, false);
  252. R.Mode.EnterMode(Mode.AllMode.Normal);
  253. this.gate2.openType = SceneGate.OpenType.Right;
  254. this._lGate.enabled = true;
  255. yield break;
  256. }
  257. private void DestroyCameraEffect()
  258. {
  259. if (!SingletonMono<CameraController>.ApplicationIsQuitting)
  260. {
  261. CameraFilterUtils.Remove<CameraFilterPack_TV_Old>(null);
  262. CameraFilterUtils.Remove<CameraFilterPack_TV_PlanetMars>(null);
  263. CameraFilterUtils.Remove<CameraFilterPack_TV_PlanetMars>(null);
  264. }
  265. }
  266. private void OnDestroy()
  267. {
  268. this.DestroyCameraEffect();
  269. }
  270. private GameObject Trinity;
  271. [SerializeField]
  272. private SceneGate gate1;
  273. [SerializeField]
  274. private SceneGate gate2;
  275. [SerializeField]
  276. private Collider2D _lGate;
  277. [SerializeField]
  278. private Collider2D _rGate;
  279. [SerializeField]
  280. private Transform spwanPoint;
  281. }