SceneRaingearIsland.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneRaingearIsland : SceneCommon
  15. {
  16. //================================================================================
  17. //
  18. //================================================================================
  19. private enum Characters
  20. {
  21. Reader = CharactersCommon.Reader,
  22. Sam = CharactersCommon.Sam,
  23. Paige = CharactersCommon.Paige,
  24. Chester = CharactersCommon.Chester,
  25. RaingearThrowingMachine = CharactersCommon.StartSceneSpecific,
  26. }
  27. //================================================================================
  28. //
  29. //================================================================================
  30. private bool m_IsShipVideoOpening;
  31. private int m_ReaderClickCount;
  32. private const int MAX_PAIGE_INDEX = 2;
  33. private int m_PaigeClickCount;
  34. //================================================================================
  35. //
  36. //================================================================================
  37. protected override void Start()
  38. {
  39. base.Start();
  40. //============================================================================
  41. //
  42. //============================================================================
  43. int lang = PlayerPrefs.GetInt("language");
  44. if (lang == 0)
  45. m_SpeechFolder = "Resources_DA/Audio/RaingearIsland_Speech";
  46. else if (lang == 1)
  47. m_SpeechFolder = "Resources_EN/Audio/RaingearIsland_Speech";
  48. else if (lang == 2)
  49. m_SpeechFolder = "Resources_NO/Audio/RaingearIsland_Speech";
  50. else if (lang == 3)
  51. m_SpeechFolder = "Resources_SP/Audio/RaingearIsland_Speech";
  52. else if (lang == 4)
  53. m_SpeechFolder = "Resources_SW/Audio/RaingearIsland_Speech";
  54. //============================================================================
  55. //
  56. //============================================================================
  57. PlayerData.Instance().SetVisitedRaingearIsland(true);
  58. PlayerData.Instance().SetCurrentLocation(Location.RaingearIsland);
  59. UpdateIsVideoOpening();
  60. if (!m_IsShipVideoOpening)
  61. AudioManager.Instance().PlayBGM("BGM_RaingearIsland");
  62. PlayerData.Instance().DCN_VisitedRaingearIsland();
  63. m_ReaderClickCount = 0;
  64. m_PaigeClickCount = 0;
  65. }
  66. //================================================================================
  67. //
  68. //================================================================================
  69. private void UpdateIsVideoOpening()
  70. {
  71. m_IsShipVideoOpening = PlayerData.Instance().GetPreviousLocation() == Location.EdgeOfCloudNine;
  72. }
  73. //================================================================================
  74. //
  75. //================================================================================
  76. private void VideoPlayed()
  77. {
  78. m_IsShipVideoOpening = false;
  79. if (!AudioManager.Instance().IsPlayingBGM("BGM_RaingearIsland"))
  80. AudioManager.Instance().PlayBGM("BGM_RaingearIsland");
  81. }
  82. //================================================================================
  83. //
  84. //================================================================================
  85. protected override void DoneFirstTime()
  86. {
  87. base.DoneFirstTime();
  88. if (!AudioManager.Instance().IsPlayingBGM("BGM_RaingearIsland"))
  89. AudioManager.Instance().PlayBGM("BGM_RaingearIsland");
  90. }
  91. //================================================================================
  92. //
  93. //================================================================================
  94. protected override void PlayFirstEvent()
  95. {
  96. if (m_IsFirstTime)
  97. {
  98. int sequence = 0;
  99. NewSequence();
  100. if (m_IsShipVideoOpening)
  101. {
  102. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.GotoRaingearIsland);
  103. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, VideoPlayed);
  104. }
  105. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24150");
  106. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24151");
  107. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24152");
  108. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  109. StartSequence(sequence);
  110. }
  111. else if (!PlayerData.Instance().DidVisitIrvinsHouse())
  112. {
  113. int sequence = 0;
  114. NewSequence();
  115. if (m_IsShipVideoOpening)
  116. {
  117. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.GotoRaingearIsland);
  118. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, VideoPlayed);
  119. }
  120. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24200");
  121. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24201");
  122. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  123. StartSequence(sequence);
  124. }
  125. else
  126. {
  127. int sequence = 0;
  128. NewSequence();
  129. if (m_IsShipVideoOpening)
  130. {
  131. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.GotoRaingearIsland);
  132. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, VideoPlayed);
  133. }
  134. int randomValue = Random.Range(0, 100);
  135. if (randomValue < 50)
  136. {
  137. randomValue = Random.Range(0, 200);
  138. if (randomValue < 50)
  139. {
  140. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24205");
  141. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24206");
  142. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24207");
  143. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  144. }
  145. else if (randomValue < 100)
  146. {
  147. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24210");
  148. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  149. }
  150. else if (randomValue < 150)
  151. {
  152. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24200");
  153. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  154. }
  155. else
  156. {
  157. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24212");
  158. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  159. }
  160. }
  161. StartSequence(sequence);
  162. }
  163. }
  164. //================================================================================
  165. //
  166. //================================================================================
  167. protected override void OnCharacterAnimationCustomTimelineEvent1(CharacterAnimation character)
  168. {
  169. if (PlayVideo.Instance().IsOpened() || m_IsShipVideoOpening)
  170. return;
  171. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterAnimationCustomTimelineEvent1(" + character + ")...");
  172. if (character == m_CharacterAnimations[(int)Characters.RaingearThrowingMachine])
  173. {
  174. int randomValue = Random.Range(0, 150);
  175. if (randomValue < 50)
  176. AudioManager.Instance().PlaySFX("24002");
  177. else if (randomValue < 100)
  178. AudioManager.Instance().PlaySFX("24003");
  179. else
  180. AudioManager.Instance().PlaySFX("24004");
  181. }
  182. }
  183. //================================================================================
  184. //
  185. //================================================================================
  186. protected override void OnIdle()
  187. {
  188. }
  189. //================================================================================
  190. //
  191. //================================================================================
  192. public override void SpeechReader()
  193. {
  194. ++m_ReaderClickCount;
  195. NewSequence();
  196. if (m_ReaderClickCount == 1)
  197. {
  198. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24350");
  199. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24351");
  200. StartSequence(2);
  201. }
  202. else if (m_ReaderClickCount == 2)
  203. {
  204. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24355");
  205. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24356");
  206. StartSequence(2);
  207. }
  208. else if (m_ReaderClickCount == 3)
  209. {
  210. m_ReaderClickCount = 0;
  211. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24205");
  212. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "24206");
  213. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "24207");
  214. StartSequence(3);
  215. }
  216. }
  217. //================================================================================
  218. //
  219. //================================================================================
  220. public override void SpeechPaige()
  221. {
  222. if (PlayerData.Instance().DidVisitIrvinsHouse())
  223. {
  224. NewSequence();
  225. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "2430" + (5 + m_PaigeClickCount).ToString());
  226. StartSequence(1);
  227. }
  228. else
  229. {
  230. NewSequence();
  231. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "24300");
  232. StartSequence(1);
  233. }
  234. ++m_PaigeClickCount;
  235. if (m_PaigeClickCount > MAX_PAIGE_INDEX)
  236. m_PaigeClickCount = 0;
  237. }
  238. } // public class SceneRaingearIsland : SceneCommon
  239. } // namespace ReaderRabbit