SceneRaingearThrowingMachine.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneRaingearThrowingMachine : 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. Fluffy = CharactersCommon.StartSceneSpecific,
  26. RaingearThrowingMachine,
  27. }
  28. //================================================================================
  29. //
  30. //================================================================================
  31. private enum Items
  32. {
  33. Sandwich = 0,
  34. Bowl,
  35. }
  36. //================================================================================
  37. //
  38. //================================================================================
  39. private const int READER_CATAPULT = (int)ReaderAnimation.AnimationCycles.Misc1 + 1;
  40. //================================================================================
  41. //
  42. //================================================================================
  43. protected override void Start()
  44. {
  45. base.Start();
  46. //============================================================================
  47. //
  48. //============================================================================
  49. int lang = PlayerPrefs.GetInt("language");
  50. if (lang == 0)
  51. m_SpeechFolder = "Resources_DA/Audio/RaingearThrowingMachine_Speech";
  52. else if (lang == 1)
  53. m_SpeechFolder = "Resources_EN/Audio/RaingearThrowingMachine_Speech";
  54. else if (lang == 2)
  55. m_SpeechFolder = "Resources_NO/Audio/RaingearThrowingMachine_Speech";
  56. else if (lang == 3)
  57. m_SpeechFolder = "Resources_SP/Audio/RaingearThrowingMachine_Speech";
  58. else if (lang == 4)
  59. m_SpeechFolder = "Resources_SW/Audio/RaingearThrowingMachine_Speech";
  60. //============================================================================
  61. //
  62. //============================================================================
  63. PlayerData.Instance().SetVisitedRaingearThrowingMachine(true);
  64. PlayerData.Instance().SetCurrentLocation(Location.RaingearThrowingMachine);
  65. AudioManager.Instance().PlayBGM("BGM_RaingearThrowingMachine");
  66. }
  67. //================================================================================
  68. //
  69. //================================================================================
  70. public override void UpdateOnce()
  71. {
  72. if (PlayerData.Instance().RTM_IsCatapultReady)
  73. EnableNavigation("RaingearIslandRainbow");
  74. else
  75. DisableNavigation("RaingearIslandRainbow");
  76. m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping);
  77. m_Items[(int)Items.Sandwich].gameObject.SetActive(false);
  78. m_CharacterAnimations[(int)Characters.Fluffy].ChangeToIdle();
  79. if (PlayerData.Instance().RTM_IsFluffySleeping)
  80. ((RTM_FluffyAnimation)m_CharacterAnimations[(int)Characters.Fluffy]).PlaySleepAnimation();
  81. }
  82. //================================================================================
  83. //
  84. //================================================================================
  85. protected override void PlayFirstEvent()
  86. {
  87. if (PlayerData.Instance().RTM_IsCatapultReady)
  88. EnableNavigation("RaingearIslandRainbow");
  89. else
  90. DisableNavigation("RaingearIslandRainbow");
  91. m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping);
  92. m_Items[(int)Items.Sandwich].gameObject.SetActive(false);
  93. m_CharacterAnimations[(int)Characters.Fluffy].ChangeToIdle();
  94. if (PlayerData.Instance().RTM_VisitCount < 4)
  95. ++PlayerData.Instance().RTM_VisitCount;
  96. if (m_IsFirstTime)
  97. {
  98. NewSequence();
  99. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28150");
  100. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28151");
  101. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28152");
  102. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28153");
  103. StartSequence(4);
  104. }
  105. else
  106. {
  107. if (PlayerData.Instance().RTM_IsFluffySleeping)
  108. {
  109. if (PlayerData.Instance().RTM_IsCatapultReady)
  110. {
  111. NewSequence();
  112. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28210");
  113. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28211");
  114. StartSequence(2);
  115. }
  116. }
  117. else
  118. {
  119. if (PlayerData.Instance().RTM_VisitCount < 4)
  120. {
  121. switch (PlayerData.Instance().RTM_VisitCount)
  122. {
  123. case 1:
  124. NewSequence();
  125. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28200");
  126. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28201");
  127. StartSequence(2);
  128. break;
  129. case 2:
  130. NewSequence();
  131. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28202");
  132. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28250");
  133. StartSequence(2);
  134. break;
  135. case 3:
  136. NewSequence();
  137. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28204");
  138. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205");
  139. StartSequence(2);
  140. break;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. //================================================================================
  147. //
  148. //================================================================================
  149. protected override void OnIdle()
  150. {
  151. if (PlayerData.Instance().RTM_IsFluffySleeping)
  152. {
  153. NewSequence();
  154. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "28253");
  155. StartSequence(1);
  156. }
  157. else
  158. {
  159. string[] possibleNumbers = { "0", "1", "2" };
  160. string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)];
  161. NewSequence();
  162. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "2825" + randomPhraseNumber);
  163. StartSequence(1);
  164. }
  165. }
  166. //================================================================================
  167. //
  168. //================================================================================
  169. public override void SpeechReader()
  170. {
  171. if (PlayerData.Instance().RTM_IsFluffySleeping)
  172. {
  173. NewSequence();
  174. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28363");
  175. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28364");
  176. StartSequence(2);
  177. }
  178. else
  179. {
  180. if (PlayerData.Instance().RTM_UsedCatapultCount == 0)
  181. {
  182. int randomValue = Random.Range(0, 100);
  183. if (randomValue < 50)
  184. {
  185. NewSequence();
  186. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28355");
  187. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28356");
  188. StartSequence(2);
  189. }
  190. else
  191. {
  192. if (PlayerData.Instance().GetSandwich() == ItemState.Inventory)
  193. {
  194. NewSequence();
  195. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28350");
  196. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28352");
  197. StartSequence(2);
  198. }
  199. else
  200. {
  201. NewSequence();
  202. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28350");
  203. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28351");
  204. StartSequence(2);
  205. }
  206. }
  207. }
  208. else
  209. {
  210. int randomValue = Random.Range(0, 150);
  211. if (randomValue < 50)
  212. {
  213. NewSequence();
  214. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28357");
  215. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28358");
  216. StartSequence(2);
  217. }
  218. else if (randomValue < 100)
  219. {
  220. NewSequence();
  221. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28359");
  222. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28360");
  223. StartSequence(2);
  224. }
  225. else
  226. {
  227. NewSequence();
  228. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28361");
  229. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28362");
  230. StartSequence(2);
  231. }
  232. }
  233. }
  234. }
  235. //================================================================================
  236. //
  237. //================================================================================
  238. public override void SpeechPaige()
  239. {
  240. if (PlayerData.Instance().RTM_IsFluffySleeping)
  241. {
  242. NewSequence();
  243. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "28253");
  244. StartSequence(1);
  245. }
  246. else
  247. {
  248. string[] possibleNumbers = { "0", "1", "2", "3" };
  249. string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)];
  250. NewSequence();
  251. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "2830" + randomPhraseNumber);
  252. StartSequence(1);
  253. }
  254. }
  255. //================================================================================
  256. //
  257. //================================================================================
  258. protected override void OnOtherCharacterInteraction()
  259. {
  260. if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Fluffy")
  261. {
  262. PlaySpeechFluffy();
  263. }
  264. }
  265. //================================================================================
  266. //
  267. //================================================================================
  268. private void PlaySpeechFluffy()
  269. {
  270. if (!PlayerData.Instance().RTM_IsFluffySleeping)
  271. {
  272. int randomValue = Random.Range(0, 150);
  273. if (randomValue < 50)
  274. {
  275. NewSequence();
  276. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28250");
  277. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28400");
  278. StartSequence(2);
  279. }
  280. else if (randomValue < 100)
  281. {
  282. NewSequence();
  283. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28251");
  284. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205");
  285. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28401");
  286. StartSequence(3);
  287. }
  288. else
  289. {
  290. NewSequence();
  291. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28252");
  292. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28402");
  293. StartSequence(2);
  294. }
  295. }
  296. }
  297. //================================================================================
  298. //
  299. //================================================================================
  300. public void PlaySpeechBowl()
  301. {
  302. int randomValue = Random.Range(0, 100);
  303. if (randomValue < 50)
  304. {
  305. NewSequence();
  306. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28405");
  307. StartSequence(1);
  308. }
  309. else
  310. {
  311. if (PlayerData.Instance().GetSandwich() == ItemState.Inventory)
  312. {
  313. NewSequence();
  314. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28406");
  315. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28352");
  316. StartSequence(2);
  317. }
  318. else
  319. {
  320. NewSequence();
  321. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28406");
  322. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28351");
  323. StartSequence(2);
  324. }
  325. }
  326. }
  327. //================================================================================
  328. //
  329. //================================================================================
  330. protected override void OnRightItemUsedInScene(ItemEnum item)
  331. {
  332. base.OnRightItemUsedInScene(item);
  333. if (PlayerData.Instance().RTM_IsFluffySleeping)
  334. {
  335. Characters[] characters = {
  336. Characters.Sam,
  337. Characters.Reader,
  338. Characters.Sam,
  339. Characters.Reader
  340. };
  341. string[] possibleNumbers = { "7010", "7011", "7012", "7013" };
  342. int randomValue = Random.Range(0, possibleNumbers.Length);
  343. NewSequence();
  344. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]);
  345. }
  346. else
  347. {
  348. FeedFluffy();
  349. }
  350. }
  351. //================================================================================
  352. //
  353. //================================================================================
  354. protected override void OnWrongItemUsedInScene(ItemEnum item)
  355. {
  356. int randomValue = Random.Range(0, 100);
  357. if (randomValue < 50)
  358. {
  359. NewSequence();
  360. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28421");
  361. StartSequence(1);
  362. }
  363. else
  364. {
  365. NewSequence();
  366. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28422");
  367. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28423");
  368. StartSequence(2);
  369. }
  370. }
  371. //================================================================================
  372. //
  373. //================================================================================
  374. private void FeedFluffy()
  375. {
  376. bool isFirstSandwich = PlayerData.Instance().RTM_IsFirstSandwich;
  377. PlayerData.Instance().RTM_IsCatapultReady = true;
  378. PlayerData.Instance().RTM_IsFluffySleeping = true;
  379. m_Items[(int)Items.Sandwich].gameObject.SetActive(PlayerData.Instance().GetSandwich() == ItemState.Used);
  380. int sequence = 0;
  381. NewSequence();
  382. if (PlayerData.Instance().RTM_IsFirstSandwich)
  383. {
  384. PlayerData.Instance().RTM_IsFirstSandwich = false;
  385. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28411");
  386. }
  387. else
  388. {
  389. Characters[] characters = {
  390. Characters.Reader,
  391. Characters.Sam,
  392. Characters.Reader
  393. };
  394. string[] possibleNumbers = { "28411", "28412", "28413" };
  395. int randomValue = Random.Range(0, possibleNumbers.Length);
  396. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]);
  397. }
  398. SetSequence(sequence++, EventSequenceItem.EventSequenceType.AnimationWithSfx,
  399. Characters.Fluffy,
  400. 4,
  401. m_CharacterAnimations[(int)Characters.Fluffy].AnimationCyclesString[4],
  402. "28410");
  403. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, FluffyAteSandwich);
  404. Characters[] characters2 = { Characters.Reader, Characters.Sam, Characters.Reader };
  405. string[] possibleNumbers2 = { "28416", "28417", "28419" };
  406. int randomValue2 = Random.Range(0, possibleNumbers2.Length);
  407. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, characters2[randomValue2], possibleNumbers2[randomValue2]);
  408. if (isFirstSandwich)
  409. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28420");
  410. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateOnce);
  411. StartSequence(sequence);
  412. }
  413. //================================================================================
  414. //
  415. //================================================================================
  416. private void FluffyAteSandwich()
  417. {
  418. //m_Items[(int)Items.Sandwich].gameObject.SetActive(false);
  419. if (PlayerData.Instance().RTM_IsFluffySleeping)
  420. ((RTM_FluffyAnimation)m_CharacterAnimations[(int)Characters.Fluffy]).PlaySleepAnimation();
  421. }
  422. //================================================================================
  423. //
  424. //================================================================================
  425. protected override void OnNavigation()
  426. {
  427. if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "RaingearIslandRainbow")
  428. {
  429. if (m_CurrentInteractiveRectangle.IsEnabled())
  430. UseCatapult();
  431. }
  432. else
  433. {
  434. base.OnNavigation();
  435. }
  436. }
  437. //================================================================================
  438. //
  439. //================================================================================
  440. protected override void OnBlockedNavigation()
  441. {
  442. int randomValue = Random.Range(0, 150);
  443. if (randomValue < 50)
  444. {
  445. NewSequence();
  446. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28430");
  447. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28431");
  448. StartSequence(2);
  449. }
  450. else if (randomValue < 100)
  451. {
  452. NewSequence();
  453. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28204");
  454. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205");
  455. StartSequence(2);
  456. }
  457. else
  458. {
  459. NewSequence();
  460. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28200");
  461. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28201");
  462. StartSequence(2);
  463. }
  464. }
  465. //================================================================================
  466. //
  467. //================================================================================
  468. private void UseCatapult()
  469. {
  470. if (PlayerData.Instance().RTM_UsedCatapultCount < 2)
  471. ++PlayerData.Instance().RTM_UsedCatapultCount;
  472. NewSequence();
  473. if (PlayerData.Instance().RTM_UsedCatapultCount == 1)
  474. {
  475. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28435");
  476. }
  477. else
  478. {
  479. string[] possibleNumbers = { "28436", "28437" };
  480. string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)];
  481. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, randomPhraseNumber);
  482. }
  483. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, HideSam);
  484. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, HideMachine);
  485. SetSequence(3, EventSequenceItem.EventSequenceType.Animation,
  486. Characters.Reader,
  487. READER_CATAPULT,
  488. m_CharacterAnimations[(int)Characters.Reader].AnimationCyclesString[READER_CATAPULT]);
  489. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, HideReader);
  490. SetSequence(5, EventSequenceItem.EventSequenceType.Callback, GotoDowntownCloudNineViaRaingearIslandRainbow);
  491. StartSequence(6, false);
  492. }
  493. //================================================================================
  494. //
  495. //================================================================================
  496. private void HideSam()
  497. {
  498. m_CharacterAnimations[(int)Characters.Sam].gameObject.SetActive(false);
  499. }
  500. //================================================================================
  501. //
  502. //================================================================================
  503. private void HideReader()
  504. {
  505. m_CharacterAnimations[(int)Characters.Reader].gameObject.SetActive(false);
  506. }
  507. //================================================================================
  508. //
  509. //================================================================================
  510. private void HideMachine()
  511. {
  512. m_CharacterAnimations[(int)Characters.RaingearThrowingMachine].gameObject.SetActive(false);
  513. }
  514. //================================================================================
  515. //
  516. //================================================================================
  517. void GotoDowntownCloudNineViaRaingearIslandRainbow()
  518. {
  519. // Going up the rainbow.
  520. PlayerData.Instance().RGIR_Direction = 1;
  521. KishiTechUnity.Loading.Loading.Instance().Show();
  522. SetCurrentToNavigation("RaingearIslandRainbow");
  523. base.OnNavigation();
  524. }
  525. //================================================================================
  526. //
  527. //================================================================================
  528. protected override void OnCharacterAnimationCustomTimelineEvent1(CharacterAnimation character)
  529. {
  530. if (character == m_CharacterAnimations[(int)Characters.Fluffy])
  531. {
  532. m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping);
  533. m_Items[(int)Items.Sandwich].gameObject.SetActive(false);
  534. }
  535. }
  536. } // public class SceneRaingearThrowingMachine : SceneCommon
  537. } // namespace ReaderRabbit