SceneRockHead.cs 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneRockHead : 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. RockHead = CharactersCommon.StartSceneSpecific,
  26. ReaderUp,
  27. SamUp,
  28. PaigeUp,
  29. ChesterUp,
  30. }
  31. //================================================================================
  32. //
  33. //================================================================================
  34. private enum Items
  35. {
  36. Ladder = 0,
  37. Hat,
  38. PurpleHoop,
  39. PurpleHoopAtRockHead,
  40. }
  41. //================================================================================
  42. //
  43. //================================================================================
  44. private const int READER_FROM_RAINBOW = (int)ReaderAnimation.AnimationCycles.Misc1 + 1;
  45. private const int READER_UP_LADDER = READER_FROM_RAINBOW + 1;
  46. private const int READER_DOWN_LADDER = (int)ReaderAnimation.AnimationCycles.Misc1 + 1;
  47. private const int SAM_FROM_RAINBOW = (int)SamAnimation.AnimationCycles.Misc1 + 1;
  48. private const int SAM_UP_LADDER = SAM_FROM_RAINBOW + 1;
  49. private const int SAM_DOWN_LADDER = (int)SamAnimation.AnimationCycles.Misc1 + 1;
  50. //================================================================================
  51. //
  52. //================================================================================
  53. [SerializeField] private ChesterInSceneAnimation m_ChesterUpInScene;
  54. [SerializeField] private RRInteractiveRectangle m_ChesterUpRectangle;
  55. private ChesterInSceneAnimation m_OriginalChesterInScene;
  56. private RRInteractiveRectangle m_OriginalChesterUpRectangle;
  57. private bool m_IsAtBottom;
  58. private int m_MoreRockClicks;
  59. private Characters m_CurrentReaderCharacter;
  60. private Characters m_CurrentSamCharacter;
  61. private Characters m_CurrentPaigeCharacter;
  62. private bool m_DidEnterFromRainbow;
  63. //================================================================================
  64. //
  65. //================================================================================
  66. protected override void Start()
  67. {
  68. base.Start();
  69. //============================================================================
  70. //
  71. //============================================================================
  72. int lang = PlayerPrefs.GetInt("language");
  73. if (lang == 0)
  74. m_SpeechFolder = "Resources_DA/Audio/RockHead_Speech";
  75. else if (lang == 1)
  76. m_SpeechFolder = "Resources_EN/Audio/RockHead_Speech";
  77. else if (lang == 2)
  78. m_SpeechFolder = "Resources_NO/Audio/RockHead_Speech";
  79. else if (lang == 3)
  80. m_SpeechFolder = "Resources_SP/Audio/RockHead_Speech";
  81. else if (lang == 4)
  82. m_SpeechFolder = "Resources_SW/Audio/RockHead_Speech";
  83. //============================================================================
  84. //
  85. //============================================================================
  86. PlayerData.Instance().SetVisitedRockHead(true);
  87. PlayerData.Instance().SetCurrentLocation(Location.RockHead);
  88. AudioManager.Instance().PlayBGM("BGM_RockHead");
  89. // Always start at the bottom section.
  90. m_IsAtBottom = true;
  91. m_OriginalChesterInScene = m_ChesterInScene;
  92. m_OriginalChesterUpRectangle = m_ChesterRectangle;
  93. if (m_ChesterUpRectangle != null)
  94. m_ChesterUpRectangle.SetCallback(ProcessAction);
  95. int gameState = m_IsFirstTime ? 1 : PlayerData.Instance().RH_GameState;
  96. if (gameState == 1 && PlayerData.Instance().GetLadder() == ItemState.Inventory)
  97. gameState = 2;
  98. if (gameState < 3 && PlayerData.Instance().GetLadder() == ItemState.Used)
  99. gameState = 3;
  100. if (gameState == 3 && PlayerData.Instance().GetHoop() != ItemState.None)
  101. gameState = 4;
  102. m_MoreRockClicks = 0;
  103. PlayerData.Instance().RH_GameState = gameState;
  104. m_DidEnterFromRainbow = (PlayerData.Instance().GetPreviousLocation() == Location.NewspaperCarrierScene || PlayerData.Instance().GetPreviousLocation() == Location.RaingearIsland) && !Map.Instance().ChangedLocationFromMap;
  105. Map.Instance().ChangedLocationFromMap = false;
  106. }
  107. //================================================================================
  108. //
  109. //================================================================================
  110. private void UpdateCharacters(bool isAtBottom)
  111. {
  112. m_IsAtBottom = isAtBottom;
  113. for (int i = (int)Characters.Reader; i < (int)Characters.Chester; ++i)
  114. {
  115. m_CharacterAnimations[i].gameObject.SetActive(isAtBottom);
  116. m_CharacterRectangles[i].SetEnabled(isAtBottom);
  117. }
  118. for (int i = (int)Characters.ReaderUp; i < (int)Characters.ChesterUp; ++i)
  119. {
  120. m_CharacterAnimations[i].gameObject.SetActive(!isAtBottom);
  121. // We don't have Chester and RockHead in m_CharacterRectangles so subtract 2.
  122. m_CharacterRectangles[i - 2].SetEnabled(!isAtBottom);
  123. }
  124. m_CharacterAnimations[(int)Characters.Chester].gameObject.SetActive(isAtBottom);
  125. m_OriginalChesterUpRectangle.SetEnabled(isAtBottom);
  126. m_CharacterAnimations[(int)Characters.ChesterUp].gameObject.SetActive(!isAtBottom);
  127. m_ChesterUpRectangle.SetEnabled(!isAtBottom);
  128. if (m_IsAtBottom)
  129. {
  130. m_ChesterInScene = m_OriginalChesterInScene;
  131. m_ChesterRectangle = m_OriginalChesterUpRectangle;
  132. m_CurrentReaderCharacter = Characters.Reader;
  133. m_CurrentSamCharacter = Characters.Sam;
  134. m_CurrentPaigeCharacter = Characters.Paige;
  135. }
  136. else
  137. {
  138. m_ChesterInScene = m_ChesterUpInScene;
  139. m_ChesterRectangle = m_ChesterUpRectangle;
  140. m_CurrentReaderCharacter = Characters.ReaderUp;
  141. m_CurrentSamCharacter = Characters.SamUp;
  142. m_CurrentPaigeCharacter = Characters.PaigeUp;
  143. }
  144. Chester.Instance().SetChesterInSceneAnimation(m_ChesterInScene);
  145. }
  146. //================================================================================
  147. //
  148. //================================================================================
  149. private void UpdateReaderOnly()//params System.Object[] values)
  150. {
  151. //bool isAtBottom = (bool)values[0];
  152. m_CharacterAnimations[(int)Characters.Reader].gameObject.SetActive(m_IsAtBottom);
  153. m_CharacterAnimations[(int)Characters.ReaderUp].gameObject.SetActive(!m_IsAtBottom);
  154. }
  155. //================================================================================
  156. //
  157. //================================================================================
  158. private void UpdateHatOnly()
  159. {
  160. m_Items[(int)Items.Hat].UpdateOnce();
  161. }
  162. //================================================================================
  163. //
  164. //================================================================================
  165. private void UpdateItems()
  166. {
  167. for (int i = 0; i < m_Items.Length; ++i)
  168. m_Items[i].UpdateOnce();
  169. }
  170. //================================================================================
  171. //
  172. //================================================================================
  173. public override void UpdateOnce()
  174. {
  175. UpdateItems();
  176. UpdateCharacters(m_IsAtBottom);
  177. }
  178. //================================================================================
  179. //
  180. //================================================================================
  181. protected override void PlayFirstEvent()
  182. {
  183. UpdateOnce();
  184. //UpdateCharacters(m_IsAtBottom);
  185. if (m_DidEnterFromRainbow)
  186. EnterFromRainbow();
  187. else
  188. PlayFirstSpeech();
  189. }
  190. //================================================================================
  191. //
  192. //================================================================================
  193. private void EnterFromRainbow()
  194. {
  195. NewSequence();
  196. SetSequence(0, EventSequenceItem.EventSequenceType.AnimationNoWait,
  197. m_CurrentReaderCharacter,
  198. READER_FROM_RAINBOW,
  199. m_CharacterAnimations[(int)m_CurrentReaderCharacter].AnimationCyclesString[READER_FROM_RAINBOW]);
  200. SetSequence(1, EventSequenceItem.EventSequenceType.Animation,
  201. m_CurrentSamCharacter,
  202. SAM_FROM_RAINBOW,
  203. m_CharacterAnimations[(int)m_CurrentSamCharacter].AnimationCyclesString[SAM_FROM_RAINBOW]);
  204. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, PlayFirstSpeech);
  205. StartSequence(3, false);
  206. }
  207. //================================================================================
  208. //
  209. //================================================================================
  210. private void PlayFirstSpeech()
  211. {
  212. if (m_IsFirstTime)
  213. {
  214. NewSequence();
  215. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21200");
  216. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21201");
  217. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21202");
  218. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  219. StartSequence(4);
  220. }
  221. else
  222. {
  223. if (m_DidEnterFromRainbow)
  224. {
  225. if (PlayerData.Instance().RH_IsFirstTimeFromRainbow)
  226. {
  227. PlayerData.Instance().RH_IsFirstTimeFromRainbow = false;
  228. NewSequence();
  229. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21250");
  230. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21251");
  231. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  232. StartSequence(3);
  233. }
  234. else
  235. {
  236. int randomValue = Random.Range(0, 100);
  237. if (randomValue < 50)
  238. {
  239. NewSequence();
  240. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21252");
  241. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  242. StartSequence(2);
  243. }
  244. else
  245. {
  246. NewSequence();
  247. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21253");
  248. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  249. StartSequence(2);
  250. }
  251. }
  252. }
  253. }
  254. }
  255. //================================================================================
  256. //
  257. //================================================================================
  258. protected override void OnRightItemUsedInScene(ItemEnum item)
  259. {
  260. base.OnRightItemUsedInScene(item);
  261. if (item == ItemEnum.Ladder)
  262. {
  263. PlaceLadder();
  264. }
  265. else if (item == ItemEnum.Hat)
  266. {
  267. if (m_IsAtBottom == true)
  268. {
  269. NewSequence();
  270. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21350");
  271. //SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21351");
  272. StartSequence(1);
  273. //O código abaixo serve para evitar o uso do chapeu antes de subir a escada.
  274. ItemState myState = ItemState.Inventory;
  275. PlayerData.Instance().SetHat(myState);
  276. }
  277. else if (PlayerData.Instance().GetLadder() == ItemState.Used)
  278. {
  279. PlaceHat();
  280. }
  281. }
  282. }
  283. //================================================================================
  284. //
  285. //================================================================================
  286. private void PlaceHat()
  287. {
  288. NewSequence();
  289. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21520");
  290. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateHatOnly);
  291. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21521");
  292. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21522");
  293. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21523");
  294. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21524");
  295. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21525");
  296. SetSequence(7, EventSequenceItem.EventSequenceType.Callback, PlayHoopSfxAndUpdateItems);
  297. SetSequence(8, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21526");
  298. StartSequence(9);
  299. }
  300. //================================================================================
  301. //
  302. //================================================================================
  303. private void PlayHoopSfxAndUpdateItems()
  304. {
  305. // TODO: Play kHoopPresentedID (21514) SFX.
  306. UpdateItems();
  307. ((RH_RockHeadAnimation)m_CharacterAnimations[(int)Characters.RockHead]).UpdateSpeechAnimation();
  308. }
  309. //================================================================================
  310. //
  311. //================================================================================
  312. private void PlaceLadder()
  313. {
  314. NewSequence();
  315. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21501");
  316. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, "21502");
  317. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, AfterPlaceLadder);
  318. StartSequence(3);
  319. }
  320. //================================================================================
  321. //
  322. //================================================================================
  323. private void AfterPlaceLadder()
  324. {
  325. PlayerData.Instance().RH_GameState = 3;
  326. UpdateItems();
  327. }
  328. //================================================================================
  329. //
  330. //================================================================================
  331. protected override void OnWrongItemUsedInScene(ItemEnum item)
  332. {
  333. if (m_IsAtBottom)
  334. {
  335. WrongItemSpeech();
  336. }
  337. else
  338. {
  339. if (PlayerData.Instance().RH_DidTalkToRockHead)
  340. {
  341. string[] possibleNumbers = { "21530", "21531" };
  342. int randomValue = Random.Range(0, possibleNumbers.Length);
  343. NewSequence();
  344. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, possibleNumbers[randomValue]);
  345. StartSequence(1);
  346. }
  347. else
  348. {
  349. WrongItemSpeech();
  350. }
  351. }
  352. }
  353. //================================================================================
  354. //
  355. //================================================================================
  356. private void WrongItemSpeech()
  357. {
  358. CharactersCommon[] characters = {
  359. CharactersCommon.Sam,
  360. CharactersCommon.Reader,
  361. CharactersCommon.Sam,
  362. CharactersCommon.Reader,
  363. };
  364. string[] possibleNumbers = { "7010", "7011", "7012", "7013" };
  365. int randomValue = Random.Range(0, possibleNumbers.Length);
  366. NewSequence();
  367. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]);
  368. StartSequence(1);
  369. }
  370. //================================================================================
  371. //
  372. //================================================================================
  373. protected override void OnIdle()
  374. {
  375. int maxRandom = 0;
  376. int index = 0;
  377. if (PlayerData.Instance().RH_GameState < 3)
  378. {
  379. maxRandom = 100;
  380. index = 1;
  381. }
  382. else
  383. {
  384. if (m_IsAtBottom)
  385. {
  386. maxRandom = 100;
  387. index = 2;
  388. }
  389. else
  390. {
  391. maxRandom = 150;
  392. index = 3;
  393. }
  394. }
  395. int randomValue = Random.Range(0, maxRandom);
  396. if (randomValue < 50)
  397. {
  398. switch (index)
  399. {
  400. case 1:
  401. NewSequence();
  402. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21300");
  403. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21301");
  404. StartSequence(2);
  405. break;
  406. case 2:
  407. NewSequence();
  408. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21310");
  409. StartSequence(1);
  410. break;
  411. case 3:
  412. NewSequence();
  413. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21315");
  414. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21316");
  415. StartSequence(2);
  416. break;
  417. }
  418. }
  419. else if (randomValue < 100)
  420. {
  421. switch (index)
  422. {
  423. case 1:
  424. NewSequence();
  425. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21305");
  426. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21306");
  427. StartSequence(2);
  428. break;
  429. case 2:
  430. NewSequence();
  431. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21311");
  432. StartSequence(1);
  433. break;
  434. case 3:
  435. NewSequence();
  436. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21320");
  437. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21321");
  438. StartSequence(2);
  439. break;
  440. }
  441. }
  442. else
  443. {
  444. NewSequence();
  445. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21325");
  446. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21326");
  447. StartSequence(2);
  448. }
  449. }
  450. //================================================================================
  451. //
  452. //================================================================================
  453. public override void SpeechReader()
  454. {
  455. if (PlayerData.Instance().RH_GameState == 1)
  456. {
  457. int maxRandom = 150;
  458. if (PlayerData.Instance().DidVisitCloudSpellingChallenge())
  459. {
  460. maxRandom = 200;
  461. }
  462. int randomValue = Random.Range(0, maxRandom);
  463. if (randomValue < 50)
  464. {
  465. NewSequence();
  466. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21450");
  467. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21451");
  468. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21452");
  469. StartSequence(3);
  470. }
  471. else if (randomValue < 100)
  472. {
  473. NewSequence();
  474. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21300");
  475. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21301");
  476. StartSequence(2);
  477. }
  478. else if (randomValue < 150)
  479. {
  480. NewSequence();
  481. if (PlayerData.Instance().DidVisitCloudSpellingChallenge())
  482. {
  483. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21455");
  484. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21456");
  485. }
  486. else
  487. {
  488. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21457");
  489. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21458");
  490. }
  491. StartSequence(2);
  492. }
  493. else
  494. {
  495. NewSequence();
  496. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21457");
  497. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21458");
  498. StartSequence(2);
  499. }
  500. }
  501. else if (PlayerData.Instance().RH_GameState == 2)
  502. {
  503. NewSequence();
  504. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21351");
  505. StartSequence(1);
  506. }
  507. else
  508. {
  509. if (PlayerData.Instance().RH_GameState == 3 && m_IsAtBottom)
  510. {
  511. NewSequence();
  512. int randomValue = Random.Range(0, 100);
  513. if (randomValue < 50)
  514. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21310");
  515. else
  516. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21460");
  517. StartSequence(1);
  518. }
  519. else
  520. {
  521. RockClicked();
  522. }
  523. }
  524. }
  525. //================================================================================
  526. //
  527. //================================================================================
  528. public override void SpeechPaige()
  529. {
  530. int[] maxRandom = { 1, 2, 3, 0 };
  531. int randomValue = Random.Range(0, maxRandom[PlayerData.Instance().RH_GameState - 1]);
  532. switch (PlayerData.Instance().RH_GameState)
  533. {
  534. case 1:
  535. {
  536. string[] possibleNumbers = { "21400", "21401" };
  537. NewSequence();
  538. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, possibleNumbers[randomValue]);
  539. StartSequence(1);
  540. }
  541. break;
  542. case 2:
  543. {
  544. string[] possibleNumbers = { "21402", "21403", "21404" };
  545. NewSequence();
  546. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, possibleNumbers[randomValue]);
  547. StartSequence(1);
  548. }
  549. break;
  550. case 3:
  551. {
  552. if (PlayerData.Instance().GetHoop() == ItemState.None && PlayerData.Instance().GetHat() == ItemState.Used)
  553. {
  554. //mycode --rafael --> i coment the line below to avoid null reference. The song 21409 isnt in project.
  555. //NewSequence();
  556. //SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, "21409");
  557. //StartSequence(1);
  558. }
  559. else
  560. {
  561. string[] possibleNumbers = { "21405", "21406", "21407", "21408" };
  562. NewSequence();
  563. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, possibleNumbers[randomValue]);
  564. StartSequence(1);
  565. }
  566. }
  567. break;
  568. case 4:
  569. {
  570. //mycode --rafael --> i coment the line below to avoid null reference. The song 21409 isnt in project.
  571. //NewSequence();
  572. //SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentPaigeCharacter, "21409");
  573. //StartSequence(1);
  574. }
  575. break;
  576. }
  577. }
  578. //================================================================================
  579. //
  580. //================================================================================
  581. protected override void OnOtherCharacterInteraction()
  582. {
  583. RockClicked();
  584. }
  585. //================================================================================
  586. //
  587. //================================================================================
  588. private void RockClicked()
  589. {
  590. PlayerData.Instance().RH_DidTalkToRockHead = true;
  591. switch (PlayerData.Instance().RH_GameState)
  592. {
  593. case 1:
  594. SpeechReader();
  595. break;
  596. case 2:
  597. NewSequence();
  598. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21350");
  599. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21351");
  600. StartSequence(2);
  601. break;
  602. case 3:
  603. if (PlayerData.Instance().GetHat() != ItemState.Used)
  604. {
  605. if (m_IsAtBottom)
  606. {
  607. NewSequence();
  608. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21350");
  609. StartSequence(1);
  610. }
  611. else
  612. {
  613. int index = 1;
  614. ++PlayerData.Instance().RH_RockClickCount;
  615. if (PlayerData.Instance().RH_RockClickCount == 1)
  616. {
  617. if (PlayerData.Instance().DidVisitIrvinsHouse())
  618. index = 2;
  619. }
  620. else
  621. {
  622. if (m_MoreRockClicks == 1)
  623. {
  624. if (PlayerData.Instance().GetHat() == ItemState.None)
  625. {
  626. index = PlayerData.Instance().DidVisitCloudNineArtGallery() ? 4 : 3;
  627. }
  628. else
  629. {
  630. index = 5;
  631. }
  632. }
  633. else
  634. {
  635. if (m_MoreRockClicks > 4)
  636. {
  637. m_MoreRockClicks = 2;
  638. }
  639. index = m_MoreRockClicks + 4;
  640. }
  641. ++m_MoreRockClicks;
  642. }
  643. PlayRockHeadSpeechGameState3(index);
  644. }
  645. }
  646. break;
  647. case 4:
  648. if (m_IsAtBottom)
  649. {
  650. NewSequence();
  651. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21390");
  652. StartSequence(1);
  653. }
  654. else
  655. {
  656. NewSequence();
  657. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21391");
  658. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21392");
  659. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21393");
  660. StartSequence(3);
  661. }
  662. break;
  663. }
  664. }
  665. //================================================================================
  666. //
  667. //================================================================================
  668. private void PlayRockHeadSpeechGameState3(int index)
  669. {
  670. switch (index)
  671. {
  672. case 1:
  673. NewSequence();
  674. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21355");
  675. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21356");
  676. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21357");
  677. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21358");
  678. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21359");
  679. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21361");
  680. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21362");
  681. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21363");
  682. SetSequence(8, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21364");
  683. StartSequence(9);
  684. break;
  685. case 2:
  686. NewSequence();
  687. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21355");
  688. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21356");
  689. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21357");
  690. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21358");
  691. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21359");
  692. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21360");
  693. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21361");
  694. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21362");
  695. SetSequence(8, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21363");
  696. SetSequence(9, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21364");
  697. StartSequence(10);
  698. break;
  699. case 3:
  700. NewSequence();
  701. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21370");
  702. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21371");
  703. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21372");
  704. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21373");
  705. StartSequence(4);
  706. break;
  707. case 4:
  708. NewSequence();
  709. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21370");
  710. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21371");
  711. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21380");
  712. StartSequence(3);
  713. break;
  714. case 5:
  715. NewSequence();
  716. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21370");
  717. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21371");
  718. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21372");
  719. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21374");
  720. StartSequence(4);
  721. break;
  722. case 6:
  723. NewSequence();
  724. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21382");
  725. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21383");
  726. StartSequence(2);
  727. break;
  728. case 7:
  729. NewSequence();
  730. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21320");
  731. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21321");
  732. StartSequence(2);
  733. break;
  734. case 8:
  735. NewSequence();
  736. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21385");
  737. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.RockHead, "21386");
  738. StartSequence(2);
  739. break;
  740. }
  741. }
  742. //================================================================================
  743. //
  744. //================================================================================
  745. public void LadderClicked()
  746. {
  747. DisableColliders();
  748. if (m_IsAtBottom)
  749. {
  750. m_IsAtBottom = false;
  751. NewSequence();
  752. SetSequence(0, EventSequenceItem.EventSequenceType.Animation,
  753. m_CurrentReaderCharacter,
  754. READER_UP_LADDER,
  755. m_CharacterAnimations[(int)m_CurrentReaderCharacter].AnimationCyclesString[READER_UP_LADDER]);
  756. //SetSequenceCallbackWithParameters(1, EventSequenceItem.EventSequenceType.CallbackWithParameters, UpdateReaderOnly, false);
  757. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateReaderOnly);
  758. SetSequence(2, EventSequenceItem.EventSequenceType.Animation,
  759. m_CurrentSamCharacter,
  760. SAM_UP_LADDER,
  761. m_CharacterAnimations[(int)m_CurrentSamCharacter].AnimationCyclesString[SAM_UP_LADDER]);
  762. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, UpdateOnce);
  763. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, RestoreColliders);
  764. StartSequence(5, false);
  765. }
  766. else
  767. {
  768. m_IsAtBottom = true;
  769. NewSequence();
  770. SetSequence(0, EventSequenceItem.EventSequenceType.Animation,
  771. m_CurrentReaderCharacter,
  772. READER_DOWN_LADDER,
  773. m_CharacterAnimations[(int)m_CurrentReaderCharacter].AnimationCyclesString[READER_DOWN_LADDER]);
  774. //SetSequenceCallbackWithParameters(1, EventSequenceItem.EventSequenceType.CallbackWithParameters, UpdateReaderOnly, true);
  775. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateReaderOnly);
  776. SetSequence(2, EventSequenceItem.EventSequenceType.Animation,
  777. m_CurrentSamCharacter,
  778. SAM_DOWN_LADDER,
  779. m_CharacterAnimations[(int)m_CurrentSamCharacter].AnimationCyclesString[SAM_DOWN_LADDER]);
  780. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, UpdateOnce);
  781. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, RestoreColliders);
  782. StartSequence(5, false);
  783. }
  784. }
  785. //================================================================================
  786. //
  787. //================================================================================
  788. public void HoopClicked(ItemCommon item)
  789. {
  790. if (m_IsAtBottom)
  791. {
  792. // TODO: Play WAVE_COMSOFTCLICK.
  793. int randomValue = Random.Range(0, 100);
  794. if (randomValue < 50)
  795. {
  796. NewSequence();
  797. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21510");
  798. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, m_CurrentSamCharacter, "21511");
  799. StartSequence(2);
  800. }
  801. else
  802. {
  803. NewSequence();
  804. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21512");
  805. StartSequence(1);
  806. }
  807. }
  808. else
  809. {
  810. if (PlayerData.Instance().GetHat() == ItemState.Used)
  811. {
  812. // TODO: Play WAVE_COMPICKUP.
  813. NewSequence();
  814. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentReaderCharacter, "21513");
  815. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, item.DoAction);
  816. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, AfterGetHoop);
  817. StartSequence(3);
  818. }
  819. else
  820. {
  821. RockClicked();
  822. }
  823. }
  824. }
  825. //================================================================================
  826. //
  827. //================================================================================
  828. private void AfterGetHoop()
  829. {
  830. PlayerData.Instance().RH_GameState = 4;
  831. }
  832. //================================================================================
  833. //
  834. //================================================================================
  835. public void HidePurpleHoopAtRockHead()
  836. {
  837. m_Items[(int)Items.PurpleHoopAtRockHead].gameObject.SetActive(false);
  838. }
  839. //================================================================================
  840. //
  841. //================================================================================
  842. public void ShowPurpleHoopAtRockHead()
  843. {
  844. m_Items[(int)Items.PurpleHoopAtRockHead].gameObject.SetActive(true);
  845. }
  846. } // public class SceneRockHead : SceneCommon
  847. } // namespace ReaderRabbit