StoryE15P3.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections;
  3. using DG.Tweening;
  4. using GameWorld;
  5. using I2.Loc;
  6. using UnityEngine;
  7. public class StoryE15P3 : BaseBehaviour
  8. {
  9. private bool e15Finish
  10. {
  11. set
  12. {
  13. SaveStorage.Set("E15_Finish", value);
  14. }
  15. }
  16. private void Start()
  17. {
  18. R.Audio.PlayBGM(371, true);
  19. this.gate.openType = SceneGate.OpenType.None;
  20. R.Ui.HideUI(true);
  21. }
  22. private void Update()
  23. {
  24. if (this.spwanPoint.position.x - R.Player.Transform.position.x < 14f && !this.show)
  25. {
  26. this.show = true;
  27. base.StartCoroutine(this.P3Coroutine());
  28. }
  29. }
  30. private void OnEnable()
  31. {
  32. EventManager.RegisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.EnemyDie), EventManager.ListenerQueue.Game);
  33. }
  34. private void OnDisable()
  35. {
  36. EventManager.UnregisterEvent<EventArgs>("EnemyKilled", new EventManager.FBEventHandler<EventArgs>(this.EnemyDie), EventManager.ListenerQueue.Game);
  37. }
  38. private bool EnemyDie(string eventName, object sender, EventArgs msg)
  39. {
  40. this.enemyDie = true;
  41. return true;
  42. }
  43. private IEnumerator P3Coroutine()
  44. {
  45. InputSetting.Stop(false);
  46. R.Player.ActionController.StartMove();
  47. yield return new WaitForSeconds(1f);
  48. R.Player.ActionController.StopMove();
  49. yield return new WaitForSeconds(3f);
  50. R.Camera.Controller.IsFollowPivot = false;
  51. R.Camera.Controller.CameraMoveTo(new Vector2(this.spwanPoint.position.x, R.Camera.Controller.MovableCamera.position.y), 1.5f, Ease.Linear);
  52. yield return new WaitForSeconds(3f);
  53. this.effect.SetActive(true);
  54. this.effect.GetComponent<Animation>().Play("Appear", PlayMode.StopAll);
  55. yield return new WaitForSeconds(0.2f);
  56. Singleton<EnemyGenerator>.Instance.GenerateEnemy(EnemyType.黄衣老者, new Vector2?(this.spwanPoint.position), false, true);
  57. R.Audio.PlayEffect(370, new Vector3?(this.spwanPoint.position));
  58. yield return new WaitForSeconds(2f);
  59. R.Camera.Controller.IsFollowPivot = true;
  60. InputSetting.Resume(false);
  61. while (!this.enemyDie)
  62. {
  63. yield return null;
  64. }
  65. yield return R.Audio.PlayEffect(478, null).clip.length;
  66. yield return R.Ui.Terminal.OpenWithAnim(new Color?(Color.yellow));
  67. yield return R.Ui.Terminal.Println(ScriptLocalization.Story.e15s1, 0.1f);
  68. this.e15Finish = true;
  69. R.Trophy.AwardTrophy(18);
  70. yield return SaveManager.ModifySaveData(delegate(GameData gameData)
  71. {
  72. if (gameData.ThisSaveValidStorage.ContainsKey("E15_Finish"))
  73. {
  74. gameData.ThisSaveValidStorage["E15_Finish"] = 1;
  75. }
  76. else
  77. {
  78. gameData.ThisSaveValidStorage.Add("E15_Finish", 1);
  79. }
  80. });
  81. yield return new WaitForSeconds(3f);
  82. CameraFilterUtils.Remove<CameraFilterPack_EyesVision_2>(null);
  83. R.Ui.BlackScene.Alpha = 1f;
  84. yield return R.Ui.Terminal.CloseWithAnim();
  85. yield return new WaitForSeconds(1f);
  86. R.Ui.BlackScene.Alpha = 0f;
  87. R.Ui.ShowUI(true);
  88. yield return R.Ui.LevelSelect.OpenWithAnim(true, true);
  89. yield break;
  90. }
  91. private bool enemyDie;
  92. [SerializeField]
  93. private Transform spwanPoint;
  94. [SerializeField]
  95. private GameObject effect;
  96. [SerializeField]
  97. private SceneGate gate;
  98. private bool show;
  99. }