SceneFlowerpotPhonics.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using SimpleJSON;
  8. //================================================================================
  9. //
  10. //================================================================================
  11. namespace ReaderRabbit
  12. {
  13. //================================================================================
  14. //
  15. //================================================================================
  16. public class SceneFlowerpotPhonics : SceneCommon
  17. {
  18. //================================================================================
  19. //
  20. //================================================================================
  21. private enum Characters
  22. {
  23. Reader = CharactersCommon.Reader,
  24. Sam = CharactersCommon.Sam,
  25. Paige = CharactersCommon.Paige,
  26. Chester = CharactersCommon.Chester,
  27. Bloom = CharactersCommon.StartSceneSpecific,
  28. }
  29. //================================================================================
  30. //
  31. //================================================================================
  32. private const int MAX_PACKAGES = 3;
  33. private const int MAX_CORRECT_SPEECH = 5;
  34. private const int MAX_INCORRECT_SPEECH = 3;
  35. private const int MAX_PAIGE_CLICKS = 9;
  36. public int word_name_speech_id;
  37. public int INVALID_WORD_NAME_SPEECH_ID;//word_name_speech_id - 1;
  38. //================================================================================
  39. //
  40. //================================================================================
  41. private const int WORD_LIST_1_SIZE = 20;
  42. private const int WORD_LIST_2_SIZE = 28;
  43. private const int WORD_LIST_3_SIZE = 28;
  44. private const int NUMBER_OF_MINIGAME_LEVELS = 3;
  45. [SerializeField] private VaseManager m_VaseManager;
  46. [SerializeField] private SolutionBox m_SolutionBox;
  47. [SerializeField] private CartManager m_CartManager;
  48. [SerializeField] private GameObject m_NewCartItemSprite;
  49. [SerializeField] private OldCart m_OldCartItemSprite;
  50. [SerializeField] private GameObject m_CartItemCollectable;
  51. [SerializeField] private CollectableMarble m_Marble;
  52. public FlowerpotProblemDescription m_CurrentDescription;
  53. private int m_CurrentMinigameLevel;
  54. private int m_CurrentWordList;
  55. private int m_PaigeClickCount;
  56. private int m_IdleIndex;
  57. private int m_CorrectSpeechIndex;
  58. private int m_IncorrectSpeechIndex;
  59. private int m_PuzzleAttempts;
  60. private bool m_IsFirstWagon;
  61. private bool m_CartItemCollectableClicked;
  62. // HACK: Wait for n milliseconds before processing the next click, otherwise we might
  63. // cancel the box animation.
  64. const float SOLUTION_BOX_DELAY_NEXT_CLICK = 0.1f;
  65. protected float m_SolutionBoxDelayForNextClick;
  66. [SerializeField] private Transform m_SolutionBoxInDestination;
  67. [SerializeField] private Transform m_SolutionBoxOutDestination;
  68. [SerializeField] private float m_SolutionBoxMovementSpeed = 1.0f;
  69. const float CART_DELAY_NEXT_CLICK = 0.1f;
  70. protected float m_CartDelayForNextClick;
  71. [SerializeField] private Transform m_CartInDestination;
  72. [SerializeField] private Transform m_CartOutDestination;
  73. [SerializeField] private Transform m_NewCartDestination;
  74. [SerializeField] private float m_CartMovementSpeed = 1.0f;
  75. [SerializeField] private BoxCollider2D m_ScreenBlocker;
  76. public bool isLoad;
  77. private int lang;
  78. //================================================================================
  79. //
  80. //================================================================================
  81. //FP.DeleteItemsGameObjects();
  82. protected override void Awake()
  83. {
  84. LocFP FP = GetComponent<LocFP>();
  85. FP.CreateItems();
  86. }
  87. protected override void Start()
  88. {
  89. base.Start();
  90. lang = PlayerPrefs.GetInt("language");
  91. INVALID_WORD_NAME_SPEECH_ID = word_name_speech_id - 1;
  92. if(lang == 0) m_SpeechFolder = "Resources_DA/Audio/FlowerpotPhonics_Speech";
  93. else if (lang == 1) m_SpeechFolder = "Resources_EN/Audio/FlowerpotPhonics_Speech";
  94. else if (lang == 2) m_SpeechFolder = "Resources_NO/Audio/FlowerpotPhonics_Speech";
  95. else if (lang == 3) m_SpeechFolder = "Resources_SP/Audio/FlowerpotPhonics_Speech";
  96. else if (lang == 4) m_SpeechFolder = "Resources_SW/Audio/FlowerpotPhonics_Speech";
  97. PlayerData.Instance().SetVisitedFlowerpotPhonics(true);
  98. PlayerData.Instance().SetCurrentLocation(Location.FlowerpotPhonics);
  99. PlayerData.Instance().UnlockActivity(Activity.FlowerpotPhonics);
  100. AudioManager.Instance().PlayBGM("BGM_FlowerpotPhonics");
  101. // ******************** TODO: REMOVE ME, I'M DEBUG CODE ********************
  102. //PlayerData.Instance().FP_GameState = 1;
  103. //m_IsFirstTime = true;
  104. //PlayerData.Instance().SetWagon(ItemState.None);
  105. //PlayerData.Instance().FP_WagonHere = false;
  106. // ******************** TODO: REMOVE ME, I'M DEBUG CODE ********************
  107. this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.FlowerpotPhonics);
  108. this.m_CurrentWordList = 1;
  109. // gameState=1 user has not heard intro
  110. // gameState=2 user has heard intro but has not put an item
  111. // into any flowerpot
  112. // gameState=3 user has put 1 item into a flowerpot
  113. // gameState=4 user has put more than 1 item into flowerpot
  114. if (PlayerData.Instance().FP_GameState < 1)
  115. PlayerData.Instance().FP_GameState = 1;
  116. // If user enters in state 3, change to state 2.
  117. if (PlayerData.Instance().FP_GameState == 3)
  118. PlayerData.Instance().FP_GameState = 2;
  119. if (PlayerData.Instance().FP_GameState > 4 || PlayerData.Instance().IsPracticeMode())
  120. PlayerData.Instance().FP_GameState = 4;
  121. Invoke("EnableInput", 0.1f);
  122. SetupCartState();
  123. Invoke ("ResizePrizes", 0.01f);
  124. m_Marble.SetParentScene(this);
  125. m_PaigeClickCount = 0;
  126. m_IdleIndex = 0;
  127. m_CorrectSpeechIndex = 0;
  128. m_IncorrectSpeechIndex = 0;
  129. m_PuzzleAttempts = 0;
  130. m_IsFirstWagon = true;
  131. m_CartItemCollectableClicked = false;
  132. }
  133. //================================================================================
  134. //
  135. //================================================================================
  136. public void EnableInput()
  137. {
  138. m_ScreenBlocker.enabled = false;
  139. }
  140. //================================================================================
  141. //
  142. //================================================================================
  143. public void DisableInput()
  144. {
  145. m_ScreenBlocker.enabled = true;
  146. }
  147. //================================================================================
  148. //
  149. //================================================================================
  150. private void ResizePrizes()
  151. {
  152. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
  153. if (!m_CartItemCollectable.activeSelf)
  154. {
  155. //KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_CartItemCollectable);
  156. }
  157. if (!m_NewCartItemSprite.activeSelf)
  158. {
  159. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_NewCartItemSprite);
  160. }
  161. if (!m_OldCartItemSprite.gameObject.activeSelf)
  162. {
  163. //KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_OldCartItemSprite.gameObject);
  164. }
  165. m_SolutionBoxInDestination.position *= KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConversionRatio;
  166. m_SolutionBoxOutDestination.position *= KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConversionRatio;
  167. //m_SolutionBoxMovementSpeed *= KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConversionRatio;
  168. }
  169. //================================================================================
  170. //
  171. //================================================================================
  172. private void GiveWagon()
  173. {
  174. if (!PlayerData.Instance().IsPracticeMode())
  175. {
  176. if (PlayerData.Instance().GetWagon() == ItemState.None && !PlayerData.Instance().FP_WagonHere)
  177. {
  178. /*// TODO: Play red wagon animation.
  179. PlayerData.Instance().FP_WagonHere = true;
  180. m_NewCartItemSprite.SetActive(false);
  181. m_CartItemCollectable.SetActive(true);
  182. m_OldCartItemSprite.gameObject.SetActive(true);
  183. m_OldCartItemSprite.HideBoxes();*/
  184. NewCartAnimation();
  185. }
  186. // There is no else here. GiveMarble is now called in another part of the code.
  187. }
  188. }
  189. //================================================================================
  190. //
  191. //================================================================================
  192. public void LoadNextWordSet()
  193. {
  194. TextAsset jsonText = null;
  195. if(lang == 0) jsonText = Resources.Load<TextAsset>("Resources_DA/FlowerpotPhonics/r1ia3");
  196. else if (lang == 1) jsonText = Resources.Load<TextAsset>("Resources_EN/FlowerpotPhonics/r1ia3");
  197. else if (lang == 2) jsonText = Resources.Load<TextAsset>("Resources_NO/FlowerpotPhonics/r1ia3");
  198. else if (lang == 3) jsonText = Resources.Load<TextAsset>("Resources_SP/FlowerpotPhonics/r1ia3");
  199. else if (lang == 4) jsonText = Resources.Load<TextAsset>("Resources_SW/FlowerpotPhonics/r1ia3");
  200. JSONNode json = JSONNode.Parse(jsonText.text);
  201. //int amountOfWordList = json ["DataSet"] ["Level_" + m_CurrentMinigameLevel].Count; //mycode --rafael --> use this and not the constatants in this script. This will help in localization.
  202. int wordListSize = GetWordListSize(m_CurrentMinigameLevel);// mycode -rafael --> original --> int wordListSize = GetWordListSize(m_CurrentMinigameLevel);
  203. if (m_CurrentWordList > wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.FlowerpotPhonics))
  204. {
  205. m_CurrentMinigameLevel++;
  206. if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
  207. {
  208. m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
  209. }
  210. PlayerData.Instance().SetActivityLevel(Activity.FlowerpotPhonics, m_CurrentMinigameLevel);
  211. m_CurrentWordList = 1;
  212. wordListSize = GetWordListSize(m_CurrentMinigameLevel);
  213. }
  214. else if (m_CurrentWordList > wordListSize && PlayerData.Instance().IsActivityLocked(Activity.FlowerpotPhonics))
  215. {
  216. m_CurrentWordList = 0;
  217. }
  218. JSONNode currentLevelWordLists = json["DataSet"]["Level_"+m_CurrentMinigameLevel];
  219. m_CurrentDescription = ParseProblemDescription(currentLevelWordLists["WordList_"+m_CurrentWordList++]);
  220. m_VaseManager.SetupVases(m_CurrentDescription);
  221. m_SolutionBox.SetupSolutionBox(m_CurrentDescription, m_CurrentMinigameLevel < 2);
  222. // GiveWagon (old GiveNextPrize) is not called here anymore.
  223. //Invoke("SetupBoxes", 0.1f);
  224. }
  225. //================================================================================
  226. //
  227. //================================================================================
  228. private void LoadNextWordSetSpeech()
  229. {
  230. Invoke("LoadNextWordSetSpeechDelayed", 0.1f);
  231. }
  232. //================================================================================
  233. //
  234. //================================================================================
  235. private void LoadNextWordSetSpeechDelayed()
  236. {
  237. int sequence = 0;
  238. NewSequence();
  239. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20610");
  240. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(m_CurrentDescription.SolutionItemName);
  241. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  242. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  243. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SetupBoxes);
  244. // Play the correct speech 25% of the time, cycling through 1 of 4 lines.
  245. int randomValue = Random.Range(0, 200);
  246. if (randomValue < 50)
  247. {
  248. ++m_CorrectSpeechIndex;
  249. if (m_CorrectSpeechIndex >= MAX_CORRECT_SPEECH)
  250. m_CorrectSpeechIndex = 1;
  251. string[] possibleNumbers = { "20610", "20611", "20612", "20613", "20614" };
  252. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, possibleNumbers[m_CorrectSpeechIndex]);
  253. }
  254. StartSequence(sequence);
  255. }
  256. //================================================================================
  257. //
  258. //================================================================================
  259. private void SetupBoxes()
  260. {
  261. m_OldCartItemSprite.HideBoxes();
  262. m_CartManager.SetupNextBox(m_CurrentDescription);
  263. }
  264. //================================================================================
  265. //
  266. //================================================================================
  267. private FlowerpotProblemDescription ParseProblemDescription(JSONNode node)
  268. {
  269. JSONNode set = node["Set_" + Random.Range(1, 3)];
  270. FlowerpotProblemDescription description;
  271. string[] tokenizedSet = set.ToString().Replace("\"", "").Split(' ');
  272. description = new FlowerpotProblemDescription(tokenizedSet[0], tokenizedSet[1],
  273. tokenizedSet[2], tokenizedSet[3], tokenizedSet[4],
  274. tokenizedSet[5], tokenizedSet[6], tokenizedSet[7]);
  275. return description;
  276. }
  277. //================================================================================
  278. //
  279. //================================================================================
  280. private int GetWordListSize(int minigameLevel)
  281. {
  282. int wordListSize = 0;
  283. if (minigameLevel == 1)
  284. {
  285. wordListSize = WORD_LIST_1_SIZE;
  286. }
  287. else if (minigameLevel == 2)
  288. {
  289. wordListSize = WORD_LIST_2_SIZE;
  290. }
  291. else
  292. {
  293. wordListSize = WORD_LIST_3_SIZE;
  294. }
  295. return wordListSize;
  296. }
  297. //================================================================================
  298. //
  299. //================================================================================
  300. private void SetupCartState()
  301. {
  302. if (PlayerData.Instance().IsPracticeMode())
  303. {
  304. m_NewCartItemSprite.SetActive(false);
  305. m_CartItemCollectable.SetActive(false);
  306. m_OldCartItemSprite.gameObject.SetActive(true);
  307. m_OldCartItemSprite.HideBoxes();
  308. }
  309. else
  310. {
  311. if (PlayerData.Instance().GetWagon() == ItemState.Inventory
  312. || PlayerData.Instance().GetWagon() == ItemState.Used)
  313. {
  314. m_NewCartItemSprite.SetActive(false);
  315. m_CartItemCollectable.SetActive(false);
  316. m_OldCartItemSprite.gameObject.SetActive(true);
  317. m_OldCartItemSprite.HideBoxes();
  318. }
  319. else if (PlayerData.Instance().GetWagon() == ItemState.None)
  320. {
  321. if (PlayerData.Instance().FP_WagonHere)
  322. {
  323. m_NewCartItemSprite.SetActive(false);
  324. m_CartItemCollectable.SetActive(true);
  325. m_OldCartItemSprite.gameObject.SetActive(true);
  326. m_OldCartItemSprite.HideBoxes();
  327. }
  328. else
  329. {
  330. m_NewCartItemSprite.SetActive(true);
  331. m_CartItemCollectable.SetActive(false);
  332. m_OldCartItemSprite.gameObject.SetActive(false);
  333. }
  334. }
  335. }
  336. }
  337. //================================================================================
  338. //
  339. //================================================================================
  340. public VaseManager VaseManager
  341. {
  342. get { return m_VaseManager; }
  343. }
  344. //================================================================================
  345. //
  346. //================================================================================
  347. public SolutionBox SolutionBox
  348. {
  349. get { return m_SolutionBox; }
  350. }
  351. //================================================================================
  352. //
  353. //================================================================================
  354. public CartManager CartManager
  355. {
  356. get { return m_CartManager; }
  357. }
  358. //================================================================================
  359. //
  360. //================================================================================
  361. private void GiveMarble()
  362. {
  363. // TODO: Play kMarbleSFX and marble animation.
  364. m_Marble.gameObject.SetActive(true);
  365. m_Marble.Enable();
  366. }
  367. //================================================================================
  368. //
  369. //================================================================================
  370. public void GetMarble()
  371. {
  372. // Play kCOMPickUpSfxID.
  373. AudioManager.Instance().PlaySFX("1802");
  374. NewSequence();
  375. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Marble.DoAction);
  376. StartSequence(1);
  377. }
  378. //================================================================================
  379. //
  380. //================================================================================
  381. protected override void PlayFirstEvent()
  382. {
  383. if (!PlayerData.Instance().IsPracticeMode())
  384. {
  385. if (m_IsFirstTime)
  386. {
  387. SpeechBloom();
  388. }
  389. else
  390. {
  391. LoadNextWordSet();
  392. int sequence = 0;
  393. NewSequence();
  394. if (PlayerData.Instance().FP_GameState == 1)
  395. {
  396. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20500");
  397. }
  398. else
  399. {
  400. int randomValue = Random.Range(0, 150);
  401. if (randomValue < 50)
  402. {
  403. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20550");
  404. }
  405. else if (randomValue < 100)
  406. {
  407. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20551");
  408. }
  409. else
  410. {
  411. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20552");
  412. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20553");
  413. }
  414. }
  415. if (PlayerData.Instance().FP_GameState == 4)
  416. {
  417. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20610");
  418. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(m_CurrentDescription.SolutionItemName);
  419. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  420. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  421. }
  422. else
  423. {
  424. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20710");
  425. }
  426. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SetupBoxes);
  427. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  428. StartSequence(sequence);
  429. }
  430. }
  431. else
  432. {
  433. LoadNextWordSet();
  434. int sequence = 0;
  435. NewSequence();
  436. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20740");
  437. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20742");
  438. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20732");
  439. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20741");
  440. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20610");
  441. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(m_CurrentDescription.SolutionItemName);
  442. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  443. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  444. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SetupBoxes);
  445. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  446. StartSequence(sequence);
  447. }
  448. }
  449. //================================================================================
  450. //
  451. //================================================================================
  452. protected override void OnNavigation()
  453. {
  454. NewSequence();
  455. int randomValue = Random.Range(0, 150);
  456. if (randomValue < 50)
  457. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20110");
  458. else if (randomValue < 100)
  459. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20111");
  460. else
  461. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20112");
  462. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, base.OnNavigation);
  463. StartSequence(2);
  464. }
  465. //================================================================================
  466. //
  467. //================================================================================
  468. protected override void OnIdle()
  469. {
  470. if (PlayerData.Instance().FP_GameState > 3)
  471. {
  472. ++m_IdleIndex;
  473. if (m_IdleIndex > 2)
  474. m_IdleIndex = 1;
  475. NewSequence();
  476. if (m_IdleIndex == 1)
  477. {
  478. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20675");
  479. StartSequence(1);
  480. }
  481. else if (m_IdleIndex == 2)
  482. {
  483. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20676");
  484. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20677");
  485. StartSequence(2);
  486. }
  487. }
  488. else
  489. {
  490. SpeechBloom();
  491. }
  492. }
  493. //================================================================================
  494. //
  495. //================================================================================
  496. public override void SpeechReader()
  497. {
  498. int randomValue = Random.Range(0, 200);
  499. if (randomValue < 50)
  500. {
  501. NewSequence();
  502. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20744");
  503. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20745");
  504. StartSequence(2);
  505. }
  506. else if (randomValue < 100)
  507. {
  508. NewSequence();
  509. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20746");
  510. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20747");
  511. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20748");
  512. StartSequence(3);
  513. }
  514. else if (randomValue < 150)
  515. {
  516. NewSequence();
  517. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20805");
  518. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20806");
  519. StartSequence(2);
  520. }
  521. else
  522. {
  523. NewSequence();
  524. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20807");
  525. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20808");
  526. StartSequence(2);
  527. }
  528. }
  529. //================================================================================
  530. //
  531. //================================================================================
  532. public override void SpeechPaige()
  533. {
  534. string[] possibleNumbers = { "20750", "20751", "20752", "20753", "20754", "20755", "20756", "20757", "20758" };
  535. NewSequence();
  536. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleNumbers[m_PaigeClickCount]);
  537. StartSequence(1);
  538. ++m_PaigeClickCount;
  539. if (m_PaigeClickCount >= MAX_PAIGE_CLICKS)
  540. m_PaigeClickCount = 0;
  541. if (m_PaigeClickCount == 4 && m_CurrentMinigameLevel != 1)
  542. m_PaigeClickCount = 5;
  543. if (m_PaigeClickCount == 5 && m_CurrentMinigameLevel == 1)
  544. m_PaigeClickCount = 6;
  545. }
  546. //================================================================================
  547. //
  548. //================================================================================
  549. public void SpeechCorrectAnswerPlaced()
  550. {
  551. // Play kCorrectSfxID (1807).
  552. AudioManager.Instance().PlaySFX("1807");
  553. string[] possibleNumbers = { "20600", "20601", "20602", "20603" };
  554. int sequence = 0;
  555. NewSequence();
  556. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, possibleNumbers[Random.Range(0, possibleNumbers.Length)]);
  557. if (m_CartManager.CurrentNumberOfBoxes == MAX_PACKAGES)
  558. {
  559. string[] possibleNumbers2 = { "20605", "20606" };
  560. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, possibleNumbers2[Random.Range(0, possibleNumbers2.Length)]);
  561. if (m_IsFirstWagon)
  562. {
  563. m_IsFirstWagon = false;
  564. // Play kRedWagonSfxID (20450).
  565. AudioManager.Instance().PlaySFX("20450");
  566. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20609");
  567. }
  568. else if (!PlayerData.Instance().IsPracticeMode())
  569. {
  570. if (m_Marble.IsEnabled())
  571. {
  572. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20608");
  573. }
  574. else
  575. {
  576. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20607");
  577. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, GiveMarble);
  578. }
  579. }
  580. }
  581. else
  582. {
  583. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20604");
  584. }
  585. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SolutionBoxOut);
  586. StartSequence(sequence);
  587. }
  588. //================================================================================
  589. //
  590. //================================================================================
  591. private void CorrectAnswerMoveNextOn()
  592. {
  593. //LoadNextWordSet(m_CartManager.CurrentNumberOfBoxes == MAX_PACKAGES);
  594. LoadNextWordSet();
  595. }
  596. //================================================================================
  597. //
  598. //================================================================================
  599. public void SpeechIncorrectAnswerPlaced()
  600. {
  601. // Play kWrongSfxID (1808).
  602. AudioManager.Instance().PlaySFX("1808");
  603. ++m_IncorrectSpeechIndex;
  604. if (m_IncorrectSpeechIndex > MAX_INCORRECT_SPEECH)
  605. m_IncorrectSpeechIndex = 1;
  606. int sequence = 0;
  607. NewSequence();
  608. if (m_IncorrectSpeechIndex == 1)
  609. {
  610. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20650");
  611. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20651");
  612. }
  613. else if (m_IncorrectSpeechIndex == 2)
  614. {
  615. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20652");
  616. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20653");
  617. }
  618. else
  619. {
  620. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20654");
  621. }
  622. // After the 2nd attempt, act like Paige was clicked.
  623. ++m_PuzzleAttempts;
  624. if (m_PuzzleAttempts > 2)
  625. {
  626. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CallSpeechPaige);
  627. }
  628. StartSequence(sequence);
  629. }
  630. //================================================================================
  631. //
  632. //================================================================================
  633. private void CallSpeechPaige()
  634. {
  635. Invoke("SpeechPaige", 0.1f);
  636. }
  637. //================================================================================
  638. //
  639. //================================================================================
  640. protected override void OnOtherCharacterInteraction()
  641. {
  642. SpeechBloom();
  643. }
  644. //================================================================================
  645. //
  646. //================================================================================
  647. private void SpeechBloom()
  648. {
  649. if (PlayerData.Instance().FP_GameState == 1)
  650. {
  651. PlayerData.Instance().FP_GameState = 2;
  652. SceneFirstSequencePart1();
  653. }
  654. else if (PlayerData.Instance().FP_GameState == 2)
  655. {
  656. NewSequence();
  657. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20710");
  658. StartSequence(1);
  659. }
  660. else if (PlayerData.Instance().FP_GameState == 3)
  661. {
  662. NewSequence();
  663. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20730");
  664. StartSequence(1);
  665. }
  666. else if (PlayerData.Instance().FP_GameState == 4)
  667. {
  668. SpeechBloomGameState4();
  669. }
  670. }
  671. //================================================================================
  672. //
  673. //================================================================================
  674. private void SceneFirstSequencePart1()
  675. {
  676. UpdateIdleDelay();
  677. NewSequence();
  678. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20500");
  679. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20700");
  680. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20701");
  681. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20702");
  682. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20703");
  683. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20704");
  684. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20705");
  685. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20706");
  686. SetSequence(8, EventSequenceItem.EventSequenceType.Callback, SceneFirstSequencePart2);
  687. StartSequence(9);
  688. }
  689. //================================================================================
  690. //
  691. //================================================================================
  692. private void SceneFirstSequencePart2()
  693. {
  694. UpdateIdleDelay();
  695. Invoke("StartSceneFirstSequencePart2", 0.1f);
  696. }
  697. //================================================================================
  698. //
  699. //================================================================================
  700. private void StartSceneFirstSequencePart2()
  701. {
  702. UpdateIdleDelay();
  703. NewSequence();
  704. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20707");
  705. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, ShowBagOnly);
  706. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, SetupBoxes);
  707. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20708");
  708. SetSequence(4, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  709. StartSequence(5);
  710. }
  711. //================================================================================
  712. //
  713. //================================================================================
  714. private void ShowBagOnly()
  715. {
  716. // Play kPackageOpenID.
  717. AudioManager.Instance().PlaySFX("20451");
  718. LoadNextWordSet();
  719. m_SolutionBox.DisableItem();
  720. }
  721. //================================================================================
  722. //
  723. //================================================================================
  724. private void EnableSolutionBoxItem()
  725. {
  726. m_SolutionBox.EnableItem();
  727. }
  728. //================================================================================
  729. //
  730. //================================================================================
  731. private void SpeechBloomGameState4()
  732. {
  733. int randomValue = Random.Range(0, 350);
  734. if (randomValue < 50)
  735. {
  736. NewSequence();
  737. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20749");
  738. StartSequence(1);
  739. }
  740. else if (randomValue < 100)
  741. {
  742. NewSequence();
  743. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20740");
  744. StartSequence(1);
  745. }
  746. else if (randomValue < 150)
  747. {
  748. NewSequence();
  749. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20741");
  750. StartSequence(1);
  751. }
  752. else if (randomValue < 200)
  753. {
  754. NewSequence();
  755. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20742");
  756. StartSequence(1);
  757. }
  758. else if (randomValue < 250)
  759. {
  760. NewSequence();
  761. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20743");
  762. StartSequence(1);
  763. }
  764. else if (randomValue < 300)
  765. {
  766. NewSequence();
  767. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20744");
  768. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20745");
  769. StartSequence(2);
  770. }
  771. else
  772. {
  773. NewSequence();
  774. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20746");
  775. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20747");
  776. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20748");
  777. StartSequence(3);
  778. }
  779. }
  780. //================================================================================
  781. //
  782. //================================================================================
  783. public void VaseClicked(Vase.VaseType vaseType)
  784. {
  785. if (PlayerData.Instance().FP_GameState == 1)
  786. {
  787. SpeechBloom();
  788. }
  789. else
  790. {
  791. if (!m_CartManager.IsItemBeingDragged())
  792. {
  793. NewSequence();
  794. if (m_CurrentMinigameLevel == 1)
  795. {
  796. switch (vaseType)
  797. {
  798. case Vase.VaseType.BEGINNING_SOUND:
  799. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20825");
  800. break;
  801. case Vase.VaseType.VOWEL_SOUND:
  802. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20826");
  803. break;
  804. case Vase.VaseType.ENDING_SOUND:
  805. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20827");
  806. break;
  807. }
  808. }
  809. else
  810. {
  811. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20828");
  812. }
  813. StartSequence(1);
  814. }
  815. }
  816. }
  817. //================================================================================
  818. //
  819. //================================================================================
  820. public void SolutionBoxClicked()
  821. {
  822. if (m_SolutionBox.IsItemEnabled())
  823. {
  824. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(m_CurrentDescription.SolutionItemName);
  825. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  826. {
  827. NewSequence();
  828. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  829. StartSequence(1);
  830. }
  831. }
  832. }
  833. //================================================================================
  834. //
  835. //================================================================================
  836. public void NewCartClicked()
  837. {
  838. if (!PlayerData.Instance().FP_WagonHere && PlayerData.Instance().GetWagon() == ItemState.None)
  839. {
  840. NewSequence();
  841. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20830");
  842. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20836");
  843. StartSequence(2);
  844. }
  845. }
  846. //================================================================================
  847. //
  848. //================================================================================
  849. public void OldCartClicked()
  850. {
  851. if (PlayerData.Instance().GetWagon() == ItemState.Inventory)
  852. {
  853. NewSequence();
  854. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20832");
  855. StartSequence(1);
  856. }
  857. else if (PlayerData.Instance().GetWagon() == ItemState.None && PlayerData.Instance().FP_WagonHere)
  858. {
  859. NewSequence();
  860. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20830");
  861. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20831");
  862. StartSequence(2);
  863. }
  864. }
  865. //================================================================================
  866. //
  867. //================================================================================
  868. public void CollectableCartClicked()
  869. {
  870. if (m_CartItemCollectableClicked)
  871. return;
  872. else
  873. m_CartItemCollectableClicked = true;
  874. NewSequence();
  875. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20837");
  876. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20838");
  877. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, CollectCart);
  878. StartSequence(3);
  879. }
  880. //================================================================================
  881. //
  882. //================================================================================
  883. private void CollectCart()
  884. {
  885. m_CartItemCollectable.SetActive(false);
  886. Chester.Instance().PutItem(ItemEnum.Wagon, this, this.GetChesterPosition().x, this.GetChesterPosition().y);
  887. PlayerData.Instance().FP_WagonHere = false;
  888. }
  889. //================================================================================
  890. //
  891. //================================================================================
  892. public void SpeechAnswerPickedUp(string itemName)
  893. {
  894. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(itemName);
  895. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  896. {
  897. NewSequence();
  898. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  899. StartSequence(1);
  900. }
  901. }
  902. //================================================================================
  903. //
  904. //================================================================================
  905. public void GrowDone(Vase.VaseType vaseType, string itemName)
  906. {
  907. int sequence = 0;
  908. NewSequence();
  909. int targetSpeechId = word_name_speech_id + m_VaseManager.GetValidWordIndex(itemName);
  910. if (targetSpeechId != INVALID_WORD_NAME_SPEECH_ID)
  911. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, targetSpeechId.ToString());
  912. if (PlayerData.Instance().FP_GameState == 2)
  913. {
  914. PlayerData.Instance().FP_GameState = 3;
  915. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20711");
  916. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20712");
  917. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "20713");
  918. if (vaseType == Vase.VaseType.BEGINNING_SOUND)
  919. {
  920. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20714");
  921. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20715");
  922. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20716");
  923. }
  924. else if (vaseType == Vase.VaseType.VOWEL_SOUND)
  925. {
  926. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20717");
  927. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20715");
  928. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20719");
  929. }
  930. else if (vaseType == Vase.VaseType.ENDING_SOUND)
  931. {
  932. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20720");
  933. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20715");
  934. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20722");
  935. }
  936. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20723");
  937. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20724");
  938. }
  939. else if (PlayerData.Instance().FP_GameState == 3)
  940. {
  941. PlayerData.Instance().FP_GameState = 4;
  942. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, EnableSolutionBoxItem);
  943. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20731");
  944. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20732");
  945. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20733");
  946. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20734");
  947. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "20735");
  948. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Bloom, "20736");
  949. }
  950. StartSequence(sequence);
  951. }
  952. //================================================================================
  953. //
  954. //================================================================================
  955. private void SolutionBoxIn()
  956. {
  957. DisableInput();
  958. m_SolutionBoxDelayForNextClick = Time.time + SOLUTION_BOX_DELAY_NEXT_CLICK;
  959. // Run some cloud moving animation before we finally remove it from the scene.
  960. iTween.MoveTo(m_SolutionBox.gameObject,
  961. iTween.Hash(new object[] {
  962. "position", m_SolutionBoxInDestination,
  963. "time", m_SolutionBoxMovementSpeed,
  964. "easetype", iTween.EaseType.linear,
  965. "oncompletetarget", this.gameObject,
  966. "oncomplete", "SolutionBoxInFinished",
  967. "onupdatetarget", this.gameObject,
  968. "onupdate", "SolutionBoxInAnimationUpdate"
  969. }));
  970. }
  971. //================================================================================
  972. //
  973. //================================================================================
  974. private void SolutionBoxOut()
  975. {
  976. DisableInput();
  977. m_SolutionBoxDelayForNextClick = Time.time + SOLUTION_BOX_DELAY_NEXT_CLICK;
  978. // Run some cloud moving animation before we finally remove it from the scene.
  979. iTween.MoveTo(m_SolutionBox.gameObject,
  980. iTween.Hash(new object[] {
  981. "position", m_SolutionBoxOutDestination,
  982. "time", m_SolutionBoxMovementSpeed,
  983. "easetype", iTween.EaseType.linear,
  984. "oncompletetarget", this.gameObject,
  985. "oncomplete", "SolutionBoxOutFinished",
  986. "onupdatetarget", this.gameObject,
  987. "onupdate", "SolutionBoxOutAnimationUpdate"
  988. }));
  989. }
  990. //================================================================================
  991. //
  992. //================================================================================
  993. private void SolutionBoxInAnimationUpdate()
  994. {
  995. if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft) && Time.time > m_SolutionBoxDelayForNextClick)
  996. {
  997. iTween.Stop(m_SolutionBox.gameObject);
  998. iTween.MoveTo(m_SolutionBox.gameObject,
  999. iTween.Hash(new object[] {
  1000. "position", m_SolutionBoxInDestination,
  1001. "time", 0.0f,
  1002. "easetype", iTween.EaseType.linear
  1003. }));
  1004. SolutionBoxInFinished();
  1005. }
  1006. }
  1007. //================================================================================
  1008. //
  1009. //================================================================================
  1010. private void SolutionBoxOutAnimationUpdate()
  1011. {
  1012. if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft) && Time.time > m_SolutionBoxDelayForNextClick)
  1013. {
  1014. iTween.Stop(m_SolutionBox.gameObject);
  1015. iTween.MoveTo(m_SolutionBox.gameObject,
  1016. iTween.Hash(new object[] {
  1017. "position", m_SolutionBoxOutDestination,
  1018. "time", 0.0f,
  1019. "easetype", iTween.EaseType.linear
  1020. }));
  1021. SolutionBoxOutFinished();
  1022. }
  1023. }
  1024. //================================================================================
  1025. //
  1026. //================================================================================
  1027. private void SolutionBoxInFinished()
  1028. {
  1029. EnableInput();
  1030. LoadNextWordSetSpeech();
  1031. }
  1032. //================================================================================
  1033. //
  1034. //================================================================================
  1035. private void SolutionBoxOutFinished()
  1036. {
  1037. EnableInput();
  1038. // Animate old wagon going out of screen. CartOut/In will call SolutionBoxIn later.
  1039. if (m_CartManager.CurrentNumberOfBoxes == MAX_PACKAGES)
  1040. {
  1041. CartOut();
  1042. }
  1043. else
  1044. {
  1045. NewSequence();
  1046. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, CorrectAnswerMoveNextOn);
  1047. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, SolutionBoxIn);
  1048. StartSequence(2);
  1049. }
  1050. }
  1051. //================================================================================
  1052. //
  1053. //================================================================================
  1054. private void CartIn()
  1055. {
  1056. DisableInput();
  1057. m_CartDelayForNextClick = Time.time + CART_DELAY_NEXT_CLICK;
  1058. iTween.MoveTo(m_OldCartItemSprite.gameObject,
  1059. iTween.Hash(new object[] {
  1060. "position", m_CartInDestination,
  1061. "time", m_CartMovementSpeed,
  1062. "easetype", iTween.EaseType.linear,
  1063. "oncompletetarget", this.gameObject,
  1064. "oncomplete", "CartInFinished",
  1065. "onupdatetarget", this.gameObject,
  1066. "onupdate", "CartInAnimationUpdate"
  1067. }));
  1068. }
  1069. //================================================================================
  1070. //
  1071. //================================================================================
  1072. private void CartOut()
  1073. {
  1074. DisableInput();
  1075. m_CartDelayForNextClick = Time.time + CART_DELAY_NEXT_CLICK;
  1076. // When player unloads the first wagon (new red one), the old one is not visible and must only play the CartIn animation (after playing the red cart animation).
  1077. if (PlayerData.Instance().GetWagon() == ItemState.None && !PlayerData.Instance().FP_WagonHere && !PlayerData.Instance().IsPracticeMode())
  1078. {
  1079. CartOutFinished();
  1080. m_OldCartItemSprite.transform.position = m_CartOutDestination.position;
  1081. m_OldCartItemSprite.ShowBoxes();
  1082. return;
  1083. }
  1084. iTween.MoveTo(m_OldCartItemSprite.gameObject,
  1085. iTween.Hash(new object[] {
  1086. "position", m_CartOutDestination,
  1087. "time", m_CartMovementSpeed,
  1088. "easetype", iTween.EaseType.linear,
  1089. "oncompletetarget", this.gameObject,
  1090. "oncomplete", "CartOutFinished",
  1091. "onupdatetarget", this.gameObject,
  1092. "onupdate", "CartOutAnimationUpdate"
  1093. }));
  1094. }
  1095. //================================================================================
  1096. //
  1097. //================================================================================
  1098. private void CartInAnimationUpdate()
  1099. {
  1100. if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft) && Time.time > m_CartDelayForNextClick)
  1101. {
  1102. iTween.Stop(m_OldCartItemSprite.gameObject);
  1103. iTween.MoveTo(m_OldCartItemSprite.gameObject,
  1104. iTween.Hash(new object[] {
  1105. "position", m_CartInDestination,
  1106. "time", 0.0f,
  1107. "easetype", iTween.EaseType.linear
  1108. }));
  1109. CartInFinished();
  1110. }
  1111. }
  1112. //================================================================================
  1113. //
  1114. //================================================================================
  1115. private void CartOutAnimationUpdate()
  1116. {
  1117. if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft) && Time.time > m_CartDelayForNextClick)
  1118. {
  1119. iTween.Stop(m_OldCartItemSprite.gameObject);
  1120. iTween.MoveTo(m_OldCartItemSprite.gameObject,
  1121. iTween.Hash(new object[] {
  1122. "position", m_CartOutDestination,
  1123. "time", 0.0f,
  1124. "easetype", iTween.EaseType.linear
  1125. }));
  1126. CartOutFinished();
  1127. }
  1128. }
  1129. //================================================================================
  1130. //
  1131. //================================================================================
  1132. private void CartInFinished()
  1133. {
  1134. EnableInput();
  1135. m_CartManager.gameObject.SetActive(true);
  1136. CorrectAnswerMoveNextOn();
  1137. SolutionBoxIn();
  1138. }
  1139. //================================================================================
  1140. //
  1141. //================================================================================
  1142. private void CartOutFinished()
  1143. {
  1144. EnableInput();
  1145. m_OldCartItemSprite.ShowBoxes();
  1146. int sequence = 0;
  1147. NewSequence();
  1148. if (!PlayerData.Instance().IsPracticeMode() && PlayerData.Instance().GetWagon() == ItemState.None && !PlayerData.Instance().FP_WagonHere)
  1149. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, NewCartAnimation);
  1150. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CartIn);
  1151. StartSequence(sequence);
  1152. }
  1153. //================================================================================
  1154. //
  1155. //================================================================================
  1156. private void NewCartAnimation()
  1157. {
  1158. DisableInput();
  1159. m_CartDelayForNextClick = Time.time + CART_DELAY_NEXT_CLICK;
  1160. iTween.MoveTo(m_NewCartItemSprite.gameObject,
  1161. iTween.Hash(new object[] {
  1162. "position", m_NewCartDestination,
  1163. "time", m_CartMovementSpeed,
  1164. "easetype", iTween.EaseType.linear,
  1165. "oncompletetarget", this.gameObject,
  1166. "oncomplete", "NewCartAnimationFinished",
  1167. "onupdatetarget", this.gameObject,
  1168. "onupdate", "NewCartAnimationUpdate"
  1169. }));
  1170. }
  1171. //================================================================================
  1172. //
  1173. //================================================================================
  1174. private void NewCartAnimationUpdate()
  1175. {
  1176. if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft) && Time.time > m_CartDelayForNextClick)
  1177. {
  1178. iTween.Stop(m_NewCartItemSprite.gameObject);
  1179. iTween.MoveTo(m_NewCartItemSprite.gameObject,
  1180. iTween.Hash(new object[] {
  1181. "position", m_NewCartDestination,
  1182. "time", 0.0f,
  1183. "easetype", iTween.EaseType.linear
  1184. }));
  1185. NewCartAnimationFinished();
  1186. }
  1187. }
  1188. //================================================================================
  1189. //
  1190. //================================================================================
  1191. private void NewCartAnimationFinished()
  1192. {
  1193. EnableInput();
  1194. PlayerData.Instance().FP_WagonHere = true;
  1195. m_NewCartItemSprite.SetActive(false);
  1196. m_CartItemCollectable.SetActive(true);
  1197. m_OldCartItemSprite.gameObject.SetActive(true);
  1198. }
  1199. } // public class SceneFlowerpotPhonics : SceneCommon
  1200. } // namespace ReaderRabbit