StoryE17.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class StoryE17 : BaseBehaviour
  5. {
  6. private bool E17P1
  7. {
  8. get
  9. {
  10. return RoundStorage.Get("E17P1", true);
  11. }
  12. set
  13. {
  14. RoundStorage.Set("E17P1", value);
  15. }
  16. }
  17. private bool E17T6
  18. {
  19. get
  20. {
  21. return RoundStorage.Get("E17T6", true);
  22. }
  23. set
  24. {
  25. RoundStorage.Set("E17T6", value);
  26. }
  27. }
  28. private int E17Process
  29. {
  30. get
  31. {
  32. return RoundStorage.Get("E17Process", 0);
  33. }
  34. set
  35. {
  36. RoundStorage.Set("E17Process", value);
  37. }
  38. }
  39. private int E17MoveIn
  40. {
  41. get
  42. {
  43. return RoundStorage.Get("E17_MoveIn", 0);
  44. }
  45. set
  46. {
  47. RoundStorage.Set("E17_MoveIn", value);
  48. }
  49. }
  50. private void Start()
  51. {
  52. this._gate.openType = SceneGate.OpenType.None;
  53. this.canOpenDoor = ((this.E17MoveIn != 2 && !this.E17T6) || this.E17P1);
  54. this.moveRight = (R.Player.Transform.position.x < base.transform.position.x);
  55. if (this.canOpenDoor)
  56. {
  57. this.OuterDoor.state.SetAnimation(0, "CloseToOpen", false);
  58. this.Door.state.SetAnimation(0, "CloseToOpen", false);
  59. }
  60. else if (this.E17MoveIn != 1)
  61. {
  62. this.DoorCollider.SetActive(true);
  63. }
  64. }
  65. private void Update()
  66. {
  67. if (this.moveRight && R.Player != null)
  68. {
  69. this.E17P1 = false;
  70. this.moveRight = false;
  71. base.StartCoroutine(this.SceneStart());
  72. }
  73. else if (this._isInCollision && !this._isPlayingVoiceOver && this.E17Process < 5)
  74. {
  75. this._stayTime += Time.deltaTime;
  76. if (this._stayTime > (float)this._waitTimes[this.E17Process])
  77. {
  78. this._stayTime = 0f;
  79. this.E17Process++;
  80. this._isPlayingVoiceOver = true;
  81. R.Audio.PlayVoiceOver("e17t" + this.E17Process, delegate
  82. {
  83. this._isPlayingVoiceOver = false;
  84. if (this.E17Process == 5)
  85. {
  86. base.StartCoroutine(this.WaitForDoor());
  87. }
  88. }, false);
  89. }
  90. }
  91. }
  92. public void OnTriggerExit2D(Collider2D other)
  93. {
  94. if (other.CompareTag("Player"))
  95. {
  96. this._isInCollision = false;
  97. }
  98. }
  99. public void OnTriggerEnter2D(Collider2D other)
  100. {
  101. if (other.CompareTag("Player"))
  102. {
  103. this._isInCollision = true;
  104. }
  105. }
  106. public IEnumerator WaitForDoor()
  107. {
  108. R.Audio.PlayEffect(353, null);
  109. this._stayTime = Time.time;
  110. yield return new WaitForSeconds(5f);
  111. InputSetting.Stop(false);
  112. this.OuterDoor.state.SetAnimation(0, "CloseToOpen", false);
  113. this.Door.state.SetAnimation(0, "CloseToOpen", false);
  114. yield return new WaitForSeconds(4f);
  115. this.E17T6 = false;
  116. R.Audio.PlayVoiceOver("e17t6", null, false);
  117. this.DoorCollider.SetActive(false);
  118. this._gate.openType = SceneGate.OpenType.Right;
  119. if (!InputSetting.IsWorking())
  120. {
  121. InputSetting.Resume(false);
  122. }
  123. yield break;
  124. }
  125. public IEnumerator SceneStart()
  126. {
  127. R.Player.ActionController.ChangeState(PlayerAction.StateEnum.Idle);
  128. R.Player.ActionController.TurnRound(1);
  129. R.Player.ActionController.StartMove();
  130. InputSetting.Stop(false);
  131. yield return new WaitForSeconds(1.2f);
  132. R.Player.ActionController.StopMove();
  133. yield return new WaitForSeconds(0.3f);
  134. this.DoorCollider.SetActive(true);
  135. this.OuterDoor.state.SetAnimation(0, "OpenToClose", false);
  136. this.Door.state.SetAnimation(0, "OpenToClose", false);
  137. yield return new WaitForSeconds(1f);
  138. if (!InputSetting.IsWorking())
  139. {
  140. InputSetting.Resume(false);
  141. }
  142. if (this.E17MoveIn == 1)
  143. {
  144. this.E17MoveIn = 2;
  145. }
  146. yield break;
  147. }
  148. public SkeletonAnimation Door;
  149. public SkeletonAnimation OuterDoor;
  150. public GameObject DoorCollider;
  151. [SerializeField]
  152. private SceneGate _gate;
  153. private bool _isInCollision;
  154. private bool _isPlayingVoiceOver;
  155. private int[] _waitTimes = new int[]
  156. {
  157. 10,
  158. 10,
  159. 15,
  160. 15,
  161. 10
  162. };
  163. private float _stayTime;
  164. private bool canOpenDoor;
  165. private bool moveRight;
  166. }