SceneCloudNineGateway.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneCloudNineGateway : 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. Gate = CharactersCommon.StartSceneSpecific,
  26. }
  27. //================================================================================
  28. //
  29. //================================================================================
  30. private enum Items
  31. {
  32. Bell = 0,
  33. }
  34. //================================================================================
  35. //
  36. //================================================================================
  37. private const int READER_BELL = (int)ReaderAnimation.AnimationCycles.Misc1 + 1;
  38. //================================================================================
  39. //
  40. //================================================================================
  41. protected override void Start()
  42. {
  43. base.Start();
  44. //============================================================================
  45. //
  46. //============================================================================
  47. int lang = PlayerPrefs.GetInt("language");
  48. if (lang == 0)
  49. m_SpeechFolder = "Resources_DA/Audio/CloudNineGateway_Speech";
  50. else if (lang == 1)
  51. m_SpeechFolder = "Resources_EN/Audio/CloudNineGateway_Speech";
  52. else if (lang == 2)
  53. m_SpeechFolder = "Resources_NO/Audio/CloudNineGateway_Speech";
  54. else if (lang == 3)
  55. m_SpeechFolder = "Resources_SP/Audio/CloudNineGateway_Speech";
  56. else if (lang == 4)
  57. m_SpeechFolder = "Resources_SW/Audio/CloudNineGateway_Speech";
  58. //============================================================================
  59. //
  60. //============================================================================
  61. PlayerData.Instance().SetVisitedCloudNineGateway(true);
  62. PlayerData.Instance().SetCurrentLocation(Location.CloudNineGateway);
  63. AudioManager.Instance().PlayBGM("BGM_CloudNineGateway");
  64. UpdateOnce();
  65. }
  66. //================================================================================
  67. //
  68. //================================================================================
  69. public override void UpdateOnce()
  70. {
  71. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudNineGateway.UpdateOnce()...");
  72. if (PlayerData.Instance().IsLocationBlocked(Location.CloudNineGateway))
  73. {
  74. DisableNavigationAll();
  75. EnableNavigation("EdgeOfCloudNine");
  76. }
  77. else
  78. {
  79. if (PlayerData.Instance().GetBell() != ItemState.Used)
  80. m_Items[(int)Items.Bell].UsedInScene();
  81. EnableNavigationAll();
  82. }
  83. }
  84. //================================================================================
  85. //
  86. //================================================================================
  87. protected override void DoneFirstTime()
  88. {
  89. base.DoneFirstTime();
  90. UpdateIdleDelay();
  91. }
  92. //================================================================================
  93. //
  94. //================================================================================
  95. protected override void PlayFirstEvent()
  96. {
  97. if (m_IsFirstTime)
  98. {
  99. PlayFirstDialogueFlow();
  100. }
  101. else
  102. {
  103. PlayReturnDialogueFlow();
  104. }
  105. }
  106. //================================================================================
  107. //
  108. //================================================================================
  109. void PlayFirstDialogueFlow()
  110. {
  111. NewSequence();
  112. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12200");
  113. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12206");
  114. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12207");
  115. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12201");
  116. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12202");
  117. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12203");
  118. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12204");
  119. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12205");
  120. SetSequence(8, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  121. StartSequence(9);
  122. }
  123. //================================================================================
  124. //
  125. //================================================================================
  126. void PlayReturnDialogueFlow()
  127. {
  128. NewSequence();
  129. if (PlayerData.Instance().IsLocationBlocked(Location.CloudNineGateway))
  130. {
  131. if (PlayerData.Instance().GetBell() == ItemState.None)
  132. {
  133. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12250");
  134. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12251");
  135. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12252");
  136. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12253");
  137. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  138. StartSequence(5);
  139. }
  140. else if (PlayerData.Instance().GetBell() == ItemState.Inventory)
  141. {
  142. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12255");
  143. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12256");
  144. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  145. StartSequence(3);
  146. }
  147. }
  148. else
  149. {
  150. // Yep, use 0-150 range and discard values above 100.
  151. int randomValue = Random.Range(0, 150);
  152. if (randomValue < 50)
  153. {
  154. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12260");
  155. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  156. StartSequence(2);
  157. }
  158. else if (randomValue < 100)
  159. {
  160. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12261");
  161. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  162. StartSequence(2);
  163. }
  164. }
  165. }
  166. //================================================================================
  167. //
  168. //================================================================================
  169. public override void OnChesterOpened()
  170. {
  171. if (PlayerData.Instance().GetBell() == ItemState.Inventory)
  172. {
  173. NewSequence();
  174. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12460");
  175. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12461");
  176. StartSequence(2);
  177. }
  178. }
  179. //================================================================================
  180. //
  181. //================================================================================
  182. protected override void OnRightItemUsedInScene(ItemEnum item)
  183. {
  184. base.OnRightItemUsedInScene(item);
  185. NewSequence();
  186. SetSequence(0, EventSequenceItem.EventSequenceType.Animation,
  187. Characters.Reader,
  188. READER_BELL,
  189. m_CharacterAnimations[(int)Characters.Reader].AnimationCyclesString[READER_BELL]);
  190. SetSequence(1, EventSequenceItem.EventSequenceType.AnimationWithSfx, Characters.Gate,
  191. CNG_GateAnimation.AnimationCycles.Opening,
  192. m_CharacterAnimations[(int)Characters.Gate].AnimationCyclesString[(int)CNG_GateAnimation.AnimationCycles.Opening],
  193. "12151");
  194. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, OpenGate);
  195. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12470");
  196. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12471");
  197. StartSequence(5);
  198. }
  199. //================================================================================
  200. //
  201. //================================================================================
  202. protected override void OnIdle()
  203. {
  204. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudNineGateway.OnIdle()...");
  205. NewSequence();
  206. int randomValue = Random.Range(0, 100);
  207. if (randomValue < 50)
  208. {
  209. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12300");
  210. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12301");
  211. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12302");
  212. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  213. StartSequence(4);
  214. }
  215. else
  216. {
  217. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12303");
  218. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12304");
  219. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  220. StartSequence(3);
  221. }
  222. }
  223. //================================================================================
  224. //
  225. //================================================================================
  226. protected override void OnBlockedNavigation()
  227. {
  228. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudNineGateway.OnBlockedNavigation()...");
  229. NewSequence();
  230. int randomValue = Random.Range(0, 100);
  231. if (randomValue < 50)
  232. {
  233. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12140");
  234. StartSequence(1);
  235. }
  236. else
  237. {
  238. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12141");
  239. StartSequence(1);
  240. }
  241. }
  242. //================================================================================
  243. //
  244. //================================================================================
  245. protected override void OnOtherCharacterInteraction()
  246. {
  247. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudNineGateway.OnOtherCharacterInteraction()...");
  248. if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "PleaseRingBellSign")
  249. {
  250. PlaySpeechPleaseRingBellSign();
  251. }
  252. else if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "WelcomeSign")
  253. {
  254. PlaySpeechWelcomeSign();
  255. }
  256. }
  257. //================================================================================
  258. //
  259. //================================================================================
  260. void PlaySpeechPleaseRingBellSign()
  261. {
  262. // Play SoftClick SFX.
  263. AudioManager.Instance().PlaySFX("1805");
  264. int sequence = 0;
  265. NewSequence();
  266. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12202");
  267. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12203");
  268. if (PlayerData.Instance().GetBell() == ItemState.None)
  269. {
  270. int randomValue = Random.Range(0, 100);
  271. if (randomValue < 50)
  272. {
  273. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12457");
  274. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12458");
  275. }
  276. else
  277. {
  278. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12455");
  279. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12456");
  280. }
  281. }
  282. else if (PlayerData.Instance().GetBell() == ItemState.Inventory)
  283. {
  284. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12405");
  285. }
  286. else if (PlayerData.Instance().GetBell() == ItemState.Used)
  287. {
  288. // Do nothing.
  289. }
  290. StartSequence(sequence);
  291. }
  292. //================================================================================
  293. //
  294. //================================================================================
  295. void PlaySpeechWelcomeSign()
  296. {
  297. // Play SoftClick SFX.
  298. AudioManager.Instance().PlaySFX("1805");
  299. int sequence = 0;
  300. NewSequence();
  301. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12450");
  302. if (PlayerData.Instance().CNG_IsFirstClickWelcomeSign)
  303. {
  304. PlayerData.Instance().CNG_IsFirstClickWelcomeSign = false;
  305. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12451");
  306. }
  307. StartSequence(sequence);
  308. }
  309. //================================================================================
  310. //
  311. //================================================================================
  312. public override void SpeechReader()
  313. {
  314. if (PlayerData.Instance().GetBell() == ItemState.None)
  315. {
  316. if (PlayerData.Instance().CNG_IsFirstClickReaderWithoutBell)
  317. {
  318. PlayerData.Instance().CNG_IsFirstClickReaderWithoutBell = false;
  319. NewSequence();
  320. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12400");
  321. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12401");
  322. StartSequence(2);
  323. }
  324. else
  325. {
  326. ReaderRandomSpeech(true);
  327. }
  328. }
  329. else if (PlayerData.Instance().GetBell() == ItemState.Inventory)
  330. {
  331. if (PlayerData.Instance().CNG_IsFirstClickReaderWithBell)
  332. {
  333. PlayerData.Instance().CNG_IsFirstClickReaderWithBell = false;
  334. NewSequence();
  335. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12405");
  336. StartSequence(1);
  337. }
  338. else
  339. {
  340. ReaderRandomSpeech(true);
  341. }
  342. }
  343. else if (PlayerData.Instance().GetBell() == ItemState.Used)
  344. {
  345. if (PlayerData.Instance().CNG_IsFirstClickReaderAfterOpeningGate)
  346. {
  347. PlayerData.Instance().CNG_IsFirstClickReaderAfterOpeningGate = false;
  348. NewSequence();
  349. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12410");
  350. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12411");
  351. StartSequence(2);
  352. }
  353. else
  354. {
  355. NewSequence();
  356. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12422");
  357. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12423");
  358. StartSequence(2);
  359. }
  360. }
  361. }
  362. //================================================================================
  363. //
  364. //================================================================================
  365. public override void SpeechPaige()
  366. {
  367. if (PlayerData.Instance().GetBell() == ItemState.None)
  368. {
  369. if (PlayerData.Instance().CNG_IsFirstClickPaigeWithoutBell)
  370. {
  371. PlayerData.Instance().CNG_IsFirstClickPaigeWithoutBell = false;
  372. NewSequence();
  373. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "12350");
  374. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12351");
  375. StartSequence(2);
  376. }
  377. else
  378. {
  379. PaigeRandomSpeech(true);
  380. }
  381. }
  382. else if (PlayerData.Instance().GetBell() == ItemState.Inventory)
  383. {
  384. if (PlayerData.Instance().CNG_IsFirstClickPaigeWithBell)
  385. {
  386. PlayerData.Instance().CNG_IsFirstClickPaigeWithBell = false;
  387. NewSequence();
  388. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "12355");
  389. StartSequence(1);
  390. }
  391. else
  392. {
  393. PaigeRandomSpeech(true);
  394. }
  395. }
  396. else if (PlayerData.Instance().GetBell() == ItemState.Used)
  397. {
  398. if (PlayerData.Instance().CNG_IsFirstClickPaigeAfterOpeningGate)
  399. {
  400. PlayerData.Instance().CNG_IsFirstClickPaigeAfterOpeningGate = false;
  401. NewSequence();
  402. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "12360");
  403. StartSequence(1);
  404. }
  405. else
  406. {
  407. PaigeRandomSpeech(true);
  408. }
  409. }
  410. }
  411. //================================================================================
  412. //
  413. //================================================================================
  414. public override void PaigeRandomSpeech(bool ignoreSomebodySpeaking)
  415. {
  416. if (ignoreSomebodySpeaking || !IsSomebodySpeaking())
  417. {
  418. NewSequence();
  419. int randomValue = Random.Range(0, 100);
  420. if (randomValue < 50)
  421. {
  422. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "12365");
  423. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12366");
  424. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "12367");
  425. StartSequence(3);
  426. }
  427. else
  428. {
  429. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "12368");
  430. StartSequence(1);
  431. }
  432. }
  433. }
  434. //================================================================================
  435. //
  436. //================================================================================
  437. void OpenGate()
  438. {
  439. m_Items[(int)Items.Bell].UsedInScene();
  440. PlayerData.Instance().UnblockLocation(Location.CloudNineGateway);
  441. UpdateOnce();
  442. m_CharacterAnimations[(int)Characters.Gate].ChangeToIdle();
  443. }
  444. //================================================================================
  445. //
  446. //================================================================================
  447. public void SpeechItemBell()
  448. {
  449. // Play SoftClick SFX.
  450. AudioManager.Instance().PlaySFX("1805");
  451. NewSequence();
  452. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "12490");
  453. StartSequence(1);
  454. }
  455. } // public class SceneCloudNineGateway : SceneCommon
  456. } // namespace ReaderRabbit