SceneNewspaperCarrierScene.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneNewspaperCarrierScene : 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. Carrie = CharactersCommon.StartSceneSpecific,
  26. }
  27. //================================================================================
  28. //
  29. //================================================================================
  30. private enum Items
  31. {
  32. Rubberbands = 0,
  33. Wagon,
  34. }
  35. //================================================================================
  36. //
  37. //================================================================================
  38. private const int READER_RAINBOW_ANIMATION = (int)ReaderAnimation.AnimationCycles.Misc1 + 1;
  39. //================================================================================
  40. //
  41. //================================================================================
  42. protected override void Start()
  43. {
  44. base.Start();
  45. //============================================================================
  46. //
  47. //============================================================================
  48. int lang = PlayerPrefs.GetInt("language");
  49. if (lang == 0)
  50. m_SpeechFolder = "Resources_DA/Audio/NewspaperCarrierScene_Speech";
  51. else if (lang == 1)
  52. m_SpeechFolder = "Resources_EN/Audio/NewspaperCarrierScene_Speech";
  53. else if (lang == 2)
  54. m_SpeechFolder = "Resources_NO/Audio/NewspaperCarrierScene_Speech";
  55. else if (lang == 3)
  56. m_SpeechFolder = "Resources_SP/Audio/NewspaperCarrierScene_Speech";
  57. else if (lang == 4)
  58. m_SpeechFolder = "Resources_SW/Audio/NewspaperCarrierScene_Speech";
  59. //============================================================================
  60. //
  61. //============================================================================
  62. PlayerData.Instance().SetVisitedNewspaperCarrierScene(true);
  63. PlayerData.Instance().SetCurrentLocation(Location.NewspaperCarrierScene);
  64. AudioManager.Instance().PlayBGM("BGM_NewspaperCarrierScene");
  65. }
  66. //================================================================================
  67. //
  68. //================================================================================
  69. public override void UpdateOnce()
  70. {
  71. m_CharacterAnimations[(int)Characters.Carrie].gameObject.SetActive(PlayerData.Instance().NCS_IsCarryInScene);
  72. if (PlayerData.Instance().NCS_IsCarryInScene)
  73. {
  74. m_CharacterAnimations[(int)Characters.Carrie].EnableOnlyAnimationCycle(2);
  75. m_CharacterAnimations[(int)Characters.Carrie].EnableAnimator();
  76. }
  77. }
  78. //================================================================================
  79. //
  80. //================================================================================
  81. protected override void OnNavigation()
  82. {
  83. if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "RaingearIslandRainbow")
  84. {
  85. int sequence = 0;
  86. NewSequence();
  87. if (PlayerData.Instance().NCS_IsFirstClickRainbow)
  88. {
  89. PlayerData.Instance().NCS_IsFirstClickRainbow = false;
  90. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17465");
  91. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17466");
  92. }
  93. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, HideSam);
  94. SetSequence(sequence++,
  95. EventSequenceItem.EventSequenceType.Animation,
  96. Characters.Reader,
  97. READER_RAINBOW_ANIMATION,
  98. m_CharacterAnimations[(int)Characters.Reader].AnimationCyclesString[READER_RAINBOW_ANIMATION]);
  99. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, GotoRockHeadViaRaingearIslandRainbow);
  100. StartSequence(sequence, false);
  101. }
  102. else
  103. {
  104. base.OnNavigation();
  105. }
  106. }
  107. //================================================================================
  108. //
  109. //================================================================================
  110. private void HideSam()
  111. {
  112. m_CharacterAnimations[(int)Characters.Sam].gameObject.SetActive(false);
  113. }
  114. //================================================================================
  115. //
  116. //================================================================================
  117. void GotoRockHeadViaRaingearIslandRainbow()
  118. {
  119. // Going down the rainbow.
  120. PlayerData.Instance().RGIR_Direction = 2;
  121. Map.Instance().ChangedLocationFromMap = false;
  122. KishiTechUnity.Loading.Loading.Instance().Show();
  123. SetCurrentToNavigation("RaingearIslandRainbow");
  124. base.OnNavigation();
  125. }
  126. //================================================================================
  127. //
  128. //================================================================================
  129. protected override void OnRightItemUsedInScene(ItemEnum item)
  130. {
  131. base.OnRightItemUsedInScene(item);
  132. foreach (ItemCommon sceneItems in m_Items)
  133. sceneItems.UpdateOnce();
  134. PlayerData.Instance().NCS_IsCarryInScene = false;
  135. NewSequence();
  136. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17455");
  137. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17456");
  138. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17457");
  139. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17458");
  140. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17459");
  141. StartSequence(5);
  142. }
  143. //================================================================================
  144. //
  145. //================================================================================
  146. protected override void OnWrongItemUsedInScene(ItemEnum item)
  147. {
  148. if (PlayerData.Instance().NCS_IsCarryInScene)
  149. {
  150. NewSequence();
  151. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17460");
  152. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17461");
  153. StartSequence(2);
  154. }
  155. else
  156. {
  157. base.OnWrongItemUsedInScene(item);
  158. }
  159. }
  160. //================================================================================
  161. //
  162. //================================================================================
  163. protected override void PlayFirstEvent()
  164. {
  165. if (m_IsFirstTime)
  166. {
  167. PlayerData.Instance().NCS_IsSecondTime = true;
  168. NewSequence();
  169. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17150");
  170. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17151");
  171. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17152");
  172. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17153");
  173. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17154");
  174. SetSequence(5, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  175. StartSequence(6);
  176. }
  177. else if (!PlayerData.Instance().NCS_IsCarryInScene && PlayerData.Instance().GetRubberBand() == ItemState.None)
  178. {
  179. NewSequence();
  180. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17210");
  181. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  182. StartSequence(2);
  183. }
  184. else if (PlayerData.Instance().NCS_IsSecondTime)
  185. {
  186. PlayerData.Instance().NCS_IsSecondTime = false;
  187. NewSequence();
  188. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17200");
  189. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17201");
  190. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17202");
  191. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  192. StartSequence(4);
  193. }
  194. else
  195. {
  196. if (PlayerData.Instance().GetWagon() == ItemState.Inventory && PlayerData.Instance().NCS_IsFirstTimeWithWagon)
  197. {
  198. PlayerData.Instance().NCS_IsFirstTimeWithWagon = false;
  199. NewSequence();
  200. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17205");
  201. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17206");
  202. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17207");
  203. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17208");
  204. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  205. StartSequence(5);
  206. }
  207. else if (!PlayerData.Instance().NCS_IsCarryInScene && PlayerData.Instance().GetRubberBand() == ItemState.None)
  208. {
  209. NewSequence();
  210. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17210");
  211. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  212. StartSequence(2);
  213. }
  214. }
  215. }
  216. //================================================================================
  217. //
  218. //================================================================================
  219. protected override void OnIdle()
  220. {
  221. if (!IsSomebodySpeaking() && !IsPlayingSequence())
  222. {
  223. NewSequence();
  224. int randomValue = Random.Range(0, 150);
  225. if (randomValue < 50)
  226. {
  227. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17250");
  228. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17251");
  229. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  230. StartSequence(3);
  231. }
  232. else if (randomValue < 100)
  233. {
  234. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17252");
  235. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17253");
  236. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  237. StartSequence(3);
  238. }
  239. else
  240. {
  241. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17254");
  242. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17255");
  243. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17256");
  244. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
  245. StartSequence(4);
  246. }
  247. }
  248. }
  249. //================================================================================
  250. //
  251. //================================================================================
  252. public void SpeechItemRubberbands()
  253. {
  254. if (PlayerData.Instance().NCS_IsFirstClickCarry)
  255. {
  256. PlayerData.Instance().NCS_IsFirstClickCarry = false;
  257. NewSequence();
  258. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17300");
  259. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17301");
  260. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17302");
  261. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17303");
  262. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17304");
  263. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17305");
  264. if (PlayerData.Instance().GetWagon() == ItemState.Inventory)
  265. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17307");
  266. else
  267. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17306");
  268. StartSequence(7);
  269. }
  270. else
  271. {
  272. if (PlayerData.Instance().GetWagon() == ItemState.Inventory)
  273. {
  274. PlayNewspaperGirlClickWithWagon();
  275. }
  276. else if (PlayerData.Instance().GetWagon() == ItemState.Used)
  277. {
  278. int sequence = 0;
  279. NewSequence();
  280. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17450");
  281. if (PlayerData.Instance().NCS_IsCarryInScene)
  282. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17451");
  283. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, m_Items[(int)Items.Rubberbands].DoAction);
  284. StartSequence(sequence);
  285. }
  286. else
  287. {
  288. PlayNewspaperGirlClickWithoutWagon();
  289. }
  290. }
  291. }
  292. //================================================================================
  293. //
  294. //================================================================================
  295. public override void SpeechReader()
  296. {
  297. if (!PlayerData.Instance().NCS_IsFirstClickCarry)
  298. {
  299. if (PlayerData.Instance().GetWagon() == ItemState.None)
  300. {
  301. int randomValue = Random.Range(0, 100);
  302. if (randomValue < 50)
  303. {
  304. PlayNewspaperGirlClickWithoutWagon();
  305. }
  306. else
  307. {
  308. ReaderRandomSpeech(true);
  309. }
  310. }
  311. else if (PlayerData.Instance().GetWagon() == ItemState.Used)
  312. {
  313. NewSequence();
  314. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17409");
  315. StartSequence(1);
  316. }
  317. else
  318. {
  319. ReaderRandomSpeech(true);
  320. }
  321. }
  322. else
  323. {
  324. ReaderRandomSpeech(true);
  325. }
  326. }
  327. //================================================================================
  328. //
  329. //================================================================================
  330. public override void ReaderRandomSpeech(bool ignoreSomebodySpeaking)
  331. {
  332. if (ignoreSomebodySpeaking || !IsSomebodySpeaking())
  333. {
  334. NewSequence();
  335. int maxRandom = (PlayerData.Instance().GetWagon() == ItemState.Used) ? 200 : 150;
  336. int randomIndex = Random.Range(0, maxRandom);
  337. if (randomIndex < 50)
  338. {
  339. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17250");
  340. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17251");
  341. StartSequence(2);
  342. }
  343. else if (randomIndex < 100)
  344. {
  345. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17254");
  346. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17255");
  347. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17256");
  348. StartSequence(3);
  349. }
  350. else if (randomIndex < 150)
  351. {
  352. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17404");
  353. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17405");
  354. StartSequence(2);
  355. }
  356. else
  357. {
  358. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17406");
  359. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17407");
  360. StartSequence(2);
  361. }
  362. }
  363. }
  364. //================================================================================
  365. //
  366. //================================================================================
  367. public override void SpeechPaige()
  368. {
  369. if (PlayerData.Instance().GetWagon() == ItemState.Used)
  370. {
  371. if (PlayerData.Instance().GetRubberBand() == ItemState.None)
  372. {
  373. NewSequence();
  374. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "17356");
  375. StartSequence(1);
  376. }
  377. else
  378. {
  379. NewSequence();
  380. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "17357");
  381. StartSequence(1);
  382. }
  383. }
  384. else if (PlayerData.Instance().GetWagon() == ItemState.Inventory)
  385. {
  386. NewSequence();
  387. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "17355");
  388. StartSequence(1);
  389. }
  390. else
  391. {
  392. PaigeRandomSpeech(true);
  393. }
  394. }
  395. //================================================================================
  396. //
  397. //================================================================================
  398. public override void PaigeRandomSpeech(bool ignoreSomebodySpeaking)
  399. {
  400. if (ignoreSomebodySpeaking || !IsSomebodySpeaking())
  401. {
  402. NewSequence();
  403. int randomIndex = Random.Range(0, 100);
  404. if (randomIndex < 50)
  405. {
  406. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "17350");
  407. StartSequence(1);
  408. }
  409. else
  410. {
  411. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "17351");
  412. StartSequence(1);
  413. }
  414. }
  415. }
  416. //================================================================================
  417. //
  418. //================================================================================
  419. protected override void OnOtherCharacterInteraction()
  420. {
  421. if (!PlayerData.Instance().NCS_IsCarryInScene)
  422. return;
  423. if (PlayerData.Instance().GetWagon() == ItemState.Inventory)
  424. {
  425. PlayNewspaperGirlClickWithWagon();
  426. }
  427. else if (PlayerData.Instance().GetWagon() == ItemState.Used)
  428. {
  429. NewSequence();
  430. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17320");
  431. StartSequence(1);
  432. }
  433. else
  434. {
  435. PlayNewspaperGirlClickWithoutWagon();
  436. }
  437. }
  438. //================================================================================
  439. //
  440. //================================================================================
  441. void PlayNewspaperGirlClickWithWagon()
  442. {
  443. NewSequence();
  444. int randomValue = Random.Range(0, 100);
  445. if (randomValue < 50)
  446. {
  447. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17316");
  448. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Carrie, "17317");
  449. StartSequence(2);
  450. }
  451. else
  452. {
  453. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17318");
  454. StartSequence(1);
  455. }
  456. }
  457. //================================================================================
  458. //
  459. //================================================================================
  460. void PlayNewspaperGirlClickWithoutWagon()
  461. {
  462. int sequence = 0;
  463. NewSequence();
  464. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17400");
  465. if (PlayerData.Instance().DidVisitFlowerpotPhonics())
  466. {
  467. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17402");
  468. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "17403");
  469. }
  470. else
  471. {
  472. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "17401");
  473. }
  474. StartSequence(sequence);
  475. }
  476. } // public class SceneNewspaperCarrierScene : SceneCommon
  477. } // namespace ReaderRabbit