SceneEdgeOfCloudNine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneEdgeOfCloudNine : 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. Announcer = CharactersCommon.StartSceneSpecific,
  26. }
  27. //================================================================================
  28. //
  29. //================================================================================
  30. private enum Items
  31. {
  32. Bell = 0,
  33. Cloud,
  34. }
  35. //================================================================================
  36. //
  37. //================================================================================
  38. private int m_IdleHelpIndex;
  39. private const int MAX_IDLE_INDEX = 2;
  40. private bool m_IsShipVideoOpening;
  41. //================================================================================
  42. //
  43. //================================================================================
  44. protected override void Start()
  45. {
  46. base.Start();
  47. //============================================================================
  48. //
  49. //============================================================================
  50. int lang = PlayerPrefs.GetInt("language");
  51. if (lang == 0)
  52. m_SpeechFolder = "Resources_DA/Audio/EdgeOfCloudNine_Speech";
  53. else if (lang == 1)
  54. m_SpeechFolder = "Resources_EN/Audio/EdgeOfCloudNine_Speech";
  55. else if (lang == 2)
  56. m_SpeechFolder = "Resources_NO/Audio/EdgeOfCloudNine_Speech";
  57. else if (lang == 3)
  58. m_SpeechFolder = "Resources_SP/Audio/EdgeOfCloudNine_Speech";
  59. else if (lang == 4)
  60. m_SpeechFolder = "Resources_SW/Audio/EdgeOfCloudNine_Speech";
  61. //============================================================================
  62. //
  63. //============================================================================
  64. PlayerData.Instance().SetVisitedEdgeOfCloudNine(true);
  65. PlayerData.Instance().SetCurrentLocation(Location.EdgeOfCloudNine);
  66. UpdateIsVideoOpening();
  67. if (!m_IsShipVideoOpening)
  68. AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine");
  69. UpdateOnce();
  70. m_IdleHelpIndex = 0;
  71. }
  72. //================================================================================
  73. //
  74. //================================================================================
  75. private void UpdateIsVideoOpening()
  76. {
  77. m_IsShipVideoOpening = PlayerData.Instance().GetPreviousLocation() == Location.RaingearIsland;
  78. }
  79. //================================================================================
  80. //
  81. //================================================================================
  82. private void VideoPlayed()
  83. {
  84. m_IsShipVideoOpening = false;
  85. if (!AudioManager.Instance().IsPlayingBGM("BGM_EdgeOfCloudNine"))
  86. AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine");
  87. }
  88. //================================================================================
  89. //
  90. //================================================================================
  91. protected override void DoneFirstTime()
  92. {
  93. base.DoneFirstTime();
  94. if (!AudioManager.Instance().IsPlayingBGM("BGM_EdgeOfCloudNine"))
  95. AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine");
  96. }
  97. //================================================================================
  98. //
  99. //================================================================================
  100. protected override void PlayFirstEvent()
  101. {
  102. if (m_IsFirstTime)
  103. {
  104. PlayerData.Instance().EOCN_IsSecondTime = true;
  105. NewSequence();
  106. SetSequence(0, EventSequenceItem.EventSequenceType.Video, VideoType.CloudNine);
  107. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  108. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14200");
  109. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14201");
  110. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14202");
  111. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14160");
  112. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14161");
  113. SetSequence(7, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  114. SetSequence(8, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  115. StartSequence(9);
  116. // This is the first time the player is playing, so we need to unlock the Introduction video as well.
  117. PlayerData.Instance().UnlockVideo(VideoType.Introduction);
  118. PlayerData.Instance().UnlockVideo(VideoType.CloudNine);
  119. }
  120. else if (PlayerData.Instance().EOCN_IsSecondTime)
  121. {
  122. PlayerData.Instance().EOCN_IsSecondTime = false;
  123. int sequence = 0;
  124. NewSequence();
  125. if (m_IsShipVideoOpening)
  126. {
  127. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.GotoEdgeOfCloudNine);
  128. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  129. }
  130. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14250");
  131. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, VideoPlayed);
  132. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  133. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  134. StartSequence(sequence);
  135. }
  136. else if (m_IsShipVideoOpening)
  137. {
  138. NewSequence();
  139. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  140. SetSequence(1, EventSequenceItem.EventSequenceType.Video, VideoType.GotoEdgeOfCloudNine);
  141. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, VideoPlayed);
  142. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  143. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  144. StartSequence(5);
  145. }
  146. }
  147. //================================================================================
  148. //
  149. //================================================================================
  150. public override void UpdateOnce()
  151. {
  152. if (PlayerData.Instance().IsLocationBlocked(Location.EdgeOfCloudNine))
  153. {
  154. PlayerData.Instance().EOCN_IsCloudVisible = true;
  155. DisableNavigation("RaingearIsland");
  156. }
  157. else
  158. {
  159. PlayerData.Instance().EOCN_IsCloudVisible = false;
  160. EnableNavigationAll();
  161. }
  162. }
  163. //================================================================================
  164. //
  165. //================================================================================
  166. protected override void OnIdle()
  167. {
  168. ++m_IdleHelpIndex;
  169. if (m_IdleHelpIndex > (MAX_IDLE_INDEX * 3))
  170. m_IdleHelpIndex = 0;
  171. if (!IsSomebodySpeaking())
  172. {
  173. if (m_IdleHelpIndex % 3 == 2)
  174. {
  175. NewSequence();
  176. int randomValue = Random.Range(0, 100);
  177. if (randomValue < 50)
  178. {
  179. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14300");
  180. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  181. StartSequence(2);
  182. }
  183. else
  184. {
  185. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14301");
  186. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14302");
  187. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  188. StartSequence(3);
  189. }
  190. }
  191. else
  192. {
  193. AnnouncerRandomSpeech(false);
  194. }
  195. }
  196. }
  197. //================================================================================
  198. //
  199. //================================================================================
  200. protected override void OnOtherCharacterInteraction()
  201. {
  202. AnnouncerRandomSpeech(true);
  203. }
  204. //================================================================================
  205. //
  206. //================================================================================
  207. public void AnnouncerRandomSpeech(bool ignoreSomebodySpeaking)
  208. {
  209. if ((ignoreSomebodySpeaking || !IsSomebodySpeaking()) && !m_IsPlayingSequence)
  210. {
  211. NewSequence();
  212. int randomValue = Random.Range(0, m_CharacterAnimations[(int)Characters.Announcer].MaxRandomSpeech - 1);
  213. switch (randomValue)
  214. {
  215. case 0:
  216. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14160");
  217. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14161");
  218. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  219. StartSequence(3);
  220. break;
  221. case 1:
  222. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14162");
  223. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14163");
  224. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  225. StartSequence(3);
  226. break;
  227. case 2:
  228. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14164");
  229. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14165");
  230. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  231. StartSequence(3);
  232. break;
  233. case 3:
  234. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14166");
  235. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14167");
  236. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  237. StartSequence(3);
  238. break;
  239. case 4:
  240. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14168");
  241. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14169");
  242. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  243. StartSequence(3);
  244. break;
  245. }
  246. }
  247. }
  248. //================================================================================
  249. //
  250. //================================================================================
  251. public override void SpeechReader()
  252. {
  253. if (PlayerData.Instance().GetBell() == ItemState.None)
  254. {
  255. NewSequence();
  256. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14350");
  257. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14351");
  258. StartSequence(2);
  259. }
  260. else
  261. {
  262. ReaderRandomSpeech(true);
  263. }
  264. }
  265. //================================================================================
  266. //
  267. //================================================================================
  268. public override void ReaderRandomSpeech(bool ignoreSomebodySpeaking)
  269. {
  270. if (ignoreSomebodySpeaking || !IsSomebodySpeaking())
  271. {
  272. NewSequence();
  273. int randomValue = Random.Range(0, 100);
  274. if (randomValue < 50)
  275. {
  276. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14400");
  277. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14401");
  278. StartSequence(2);
  279. }
  280. else
  281. {
  282. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14402");
  283. StartSequence(1);
  284. }
  285. }
  286. }
  287. //================================================================================
  288. //
  289. //================================================================================
  290. public override void SpeechPaige()
  291. {
  292. NewSequence();
  293. if (PlayerData.Instance().GetBell() == ItemState.None)
  294. {
  295. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14350");
  296. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14351");
  297. StartSequence(2);
  298. }
  299. else
  300. {
  301. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14352");
  302. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14353");
  303. StartSequence(2);
  304. }
  305. }
  306. //================================================================================
  307. //
  308. //================================================================================
  309. public void SpeechItemBell()
  310. {
  311. NewSequence();
  312. // Play Pickup SFX.
  313. AudioManager.Instance().PlaySFX("1802");
  314. // Sam and Reader talk in two different ways when player gets the bell.
  315. // One way is when the player gets it without going to CloudNineGateway and the other way is after going to CloudNineGateway and back.
  316. if (PlayerData.Instance().DidVisitCloudNineGateway())
  317. {
  318. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14453");
  319. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14454");
  320. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14452");
  321. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, m_Items[(int)Items.Bell].DoAction);
  322. StartSequence(4);
  323. }
  324. else
  325. {
  326. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14450");
  327. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14451");
  328. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14452");
  329. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, m_Items[(int)Items.Bell].DoAction);
  330. StartSequence(4);
  331. }
  332. }
  333. //================================================================================
  334. //
  335. //================================================================================
  336. public void SpeechItemCloud(bool isVisible)
  337. {
  338. NewSequence();
  339. if (isVisible)
  340. {
  341. // Sometimes Reader talks, sometimes Sam talks.
  342. int randomValue = Random.Range(0, 100);
  343. if (randomValue < 50)
  344. {
  345. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14120");
  346. StartSequence(1);
  347. }
  348. else
  349. {
  350. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14121");
  351. StartSequence(1);
  352. }
  353. }
  354. else
  355. {
  356. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14251");
  357. StartSequence(1);
  358. }
  359. }
  360. } // public class SceneEdgeOfCloudNine : SceneCommon
  361. } // namespace ReaderRabbit