SceneGumballScience.cs 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. using SimpleJSON;
  7. using System.Collections.Generic;
  8. //================================================================================
  9. //
  10. //================================================================================
  11. namespace ReaderRabbit
  12. {
  13. //================================================================================
  14. //
  15. //================================================================================
  16. public class SceneGumballScience : 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. Gum = CharactersCommon.StartSceneSpecific,
  28. }
  29. //================================================================================
  30. //
  31. //================================================================================
  32. private const int SAM_CANDY_ANIMATION = (int)SamAnimation.AnimationCycles.Misc1 + 1;
  33. private const int SAM_WHISTLE_ANIMATION = SAM_CANDY_ANIMATION + 1;
  34. //================================================================================
  35. //
  36. //================================================================================
  37. private const int WORD_LIST_1_SIZE = 11;
  38. private const int WORD_LIST_2_SIZE = 12;
  39. private const int WORD_LIST_3_SIZE = 12;
  40. private const int WORD_LIST_1_NON_PRACTICE_SIZE = 3;
  41. private const int NUMBER_OF_MINIGAME_LEVELS = 3;
  42. private const int NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE = 3;
  43. public int INITIAL_SENTENCE_LIST = 25750;
  44. private Vector3 PRIZES_EXIT_POSITION = new Vector3(582, -316, -0.25f);
  45. private int lang;
  46. //================================================================================
  47. //
  48. //================================================================================
  49. [SerializeField] private GameObject m_PrizeCandy;
  50. [SerializeField] private GameObject m_PrizeMarble;
  51. [SerializeField] private GameObject m_PrizeWhistle;
  52. [SerializeField] private GameObject m_AnimationCandy;
  53. [SerializeField] private GameObject m_AnimationMarble;
  54. [SerializeField] private GameObject m_AnimationWhistle;
  55. [SerializeField] private List<Transform> m_AnimationCandyPath;
  56. [SerializeField] private List<Transform> m_AnimationMarblePath;
  57. [SerializeField] private List<Transform> m_AnimationWhistlePath;
  58. [SerializeField] private CollectableMarble m_Marble;
  59. [SerializeField]
  60. private GumballMachine m_GumballMachine;
  61. private int m_CurrentWordList;
  62. public int m_CurrentMinigameLevel;
  63. private int m_WinsCount;
  64. private int m_TotalCorrectCount;
  65. private int m_NumGumClicks;
  66. private int m_NumPaigeClicks;
  67. private int m_MarbleSpeechCount;
  68. private int m_WrongCount;
  69. private int m_NumberOfCurGuiderClicks;
  70. private int m_NumberCandyClicks;
  71. private int m_WordClicks;
  72. private bool m_BoolRampClicked;
  73. private bool m_BoolTokenReleaseClicked;
  74. private bool m_BoolSentenceClicked;
  75. private GumballScienceBallGuider m_CurrentClickedGuider;
  76. private Dictionary<string, string> m_WordsList;
  77. private List<string> m_SentencesList;
  78. private PrizeCandy m_PrizeCandyScript; // mycode --rafael
  79. public Collider2D blocker;
  80. //================================================================================
  81. //
  82. //================================================================================
  83. protected override void Start()
  84. {
  85. base.Start();
  86. //============================================================================
  87. //
  88. //============================================================================
  89. lang = PlayerPrefs.GetInt("language");
  90. switch (lang)
  91. {
  92. case 0:
  93. m_SpeechFolder = "Resources_DA/Audio/GumballScience_Speech";
  94. break;
  95. case 1:
  96. m_SpeechFolder = "Resources_EN/Audio/GumballScience_Speech";
  97. break;
  98. case 2:
  99. m_SpeechFolder = "Resources_NO/Audio/GumballScience_Speech";
  100. break;
  101. case 3:
  102. m_SpeechFolder = "Resources_SP/Audio/GumballScience_Speech";
  103. break;
  104. case 4:
  105. m_SpeechFolder = "Resources_SW/Audio/GumballScience_Speech";
  106. break;
  107. }
  108. //============================================================================
  109. //
  110. //============================================================================
  111. m_PrizeCandyScript = m_PrizeCandy.GetComponent<PrizeCandy>(); // mycode --rafael
  112. PlayerData.Instance().SetVisitedGumballScience(true);
  113. PlayerData.Instance().SetCurrentLocation(Location.GumballScience);
  114. PlayerData.Instance().UnlockActivity(Activity.GumballScience);
  115. AudioManager.Instance().PlayBGM("BGM_GumballScience");
  116. this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.GumballScience);
  117. this.m_CurrentWordList = 0;
  118. this.m_WinsCount = 0;
  119. this.m_TotalCorrectCount = 0;
  120. this.m_NumGumClicks = 0;
  121. this.m_NumPaigeClicks = 0;
  122. this.m_MarbleSpeechCount = 0;
  123. this.m_WrongCount = 0;
  124. this.m_NumberOfCurGuiderClicks = 0;
  125. this.m_WordClicks = 0;
  126. this.m_BoolTokenReleaseClicked = false; //myCode --rafael. Anteriormente o valor era "false".
  127. this.m_BoolRampClicked = false;
  128. this.m_BoolSentenceClicked = false;
  129. //TODO: Manage animations instead of initializing it directly.
  130. //Invoke("LoadNextLevel", 0.5f);
  131. SetupWordsList();
  132. SetupSentencesList();
  133. Invoke("UpdateSizesAndPositions", 0.01f);
  134. m_Marble.SetParentScene(this);
  135. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
  136. }
  137. //================================================================================
  138. //
  139. //================================================================================
  140. private void SetupWordsList()
  141. {
  142. TextAsset text;
  143. text = null;
  144. switch (lang)
  145. {
  146. case 0:
  147. text = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1words");
  148. break;
  149. case 1:
  150. text = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1words");
  151. break;
  152. case 2:
  153. text = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1words");
  154. break;
  155. case 3:
  156. text = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1words");
  157. break;
  158. case 4:
  159. text = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1words");
  160. break;
  161. }
  162. m_WordsList = new Dictionary<string,string>();
  163. string[] separators = {"\r","\n"};
  164. string[] tokens = text.ToString().Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
  165. foreach(string token in tokens)
  166. {
  167. Debug.Log(token);
  168. m_WordsList.Add(token.Split(';')[1], token.Split(';')[0]);
  169. }
  170. }
  171. //================================================================================
  172. //
  173. //================================================================================
  174. private void SetupSentencesList()
  175. {
  176. TextAsset jsonText;
  177. jsonText = null;
  178. switch (lang)
  179. {
  180. case 0:
  181. jsonText = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1data");
  182. break;
  183. case 1:
  184. jsonText = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1data");
  185. break;
  186. case 2:
  187. jsonText = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1data");
  188. break;
  189. case 3:
  190. jsonText = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1data");
  191. break;
  192. case 4:
  193. jsonText = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1data");
  194. break;
  195. }
  196. JSONNode json = JSONNode.Parse(jsonText.text);
  197. m_SentencesList = new List<string>();
  198. for (int i = 1; i <= 3; ++i)
  199. {
  200. JSONNode currentLevelWordLists = json["DataSet"]["Level_" + i];
  201. int j = 1;
  202. while (currentLevelWordLists["DataSet_" + j] != null)
  203. {
  204. JSONNode dataSet = currentLevelWordLists["DataSet_" + j];
  205. for (int k = 1; k <= 3; ++k)
  206. {
  207. JSONNode set = dataSet["Set_" + k];
  208. string fullSentence = set.ToString().Split('.')[0].Replace("\"", "").Replace("\\", "") + ".";
  209. string[] sentenceTokens = fullSentence.Split('_');
  210. string sentenceToken = sentenceTokens[0];
  211. if (sentenceToken.EndsWith(" "))
  212. {
  213. sentenceToken = sentenceToken.Remove(sentenceToken.Length - 1, 1);
  214. }
  215. if (!m_SentencesList.Contains(sentenceToken))
  216. {
  217. m_SentencesList.Add(sentenceToken);
  218. }
  219. sentenceToken = sentenceTokens[1];
  220. if (sentenceToken.StartsWith(" "))
  221. {
  222. sentenceToken = sentenceToken.Remove(0, 1);
  223. }
  224. if (!m_SentencesList.Contains(sentenceToken))
  225. {
  226. m_SentencesList.Add(sentenceToken);
  227. }
  228. }
  229. j++;
  230. }
  231. }
  232. m_SentencesList.Sort((x, y) => string.Compare(x, y));
  233. }
  234. //================================================================================
  235. //
  236. //================================================================================
  237. private void UpdateSizesAndPositions()
  238. {
  239. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeCandy);
  240. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeMarble, false);
  241. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeWhistle);
  242. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationCandy);
  243. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationMarble);
  244. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationWhistle);
  245. }
  246. //================================================================================
  247. //
  248. //================================================================================
  249. protected override void PlayFirstEvent()
  250. {
  251. base.PlayFirstEvent();
  252. int numberOfSpeeches = 0;
  253. NewSequence();
  254. if (!PlayerData.Instance().IsPracticeMode())
  255. {
  256. if (m_IsFirstTime)
  257. {
  258. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25150");
  259. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25151");
  260. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
  261. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25350");
  262. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25351");
  263. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25354");
  264. //TODO: Blink hook
  265. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25360");
  266. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25361");
  267. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25362");
  268. }
  269. else if (PlayerData.Instance().GetWhistle() == ItemState.None)
  270. {
  271. if (this.m_PrizeWhistle.activeSelf)
  272. {
  273. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25180");
  274. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25181");
  275. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25182");
  276. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25183");
  277. }
  278. else
  279. {
  280. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25175");
  281. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25176");
  282. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25177");
  283. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25178");
  284. }
  285. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
  286. }
  287. else if (PlayerData.Instance().GetWhistle() != ItemState.None)
  288. {
  289. int randomNumber = Random.Range(1, 3);
  290. if (randomNumber == 1)
  291. {
  292. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25190");
  293. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25176");
  294. }
  295. else if (randomNumber == 2)
  296. {
  297. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25182");
  298. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25183");
  299. }
  300. else if (randomNumber == 3)
  301. {
  302. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25196");
  303. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25197");
  304. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25198");
  305. }
  306. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
  307. }
  308. }
  309. else
  310. {
  311. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25360");
  312. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25361");
  313. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
  314. }
  315. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  316. StartSequence(numberOfSpeeches);
  317. }
  318. //================================================================================
  319. //
  320. //================================================================================
  321. private void LoadNextLevel()
  322. {
  323. TextAsset jsonText;
  324. jsonText = null;
  325. switch (lang)
  326. {
  327. case 0:
  328. jsonText = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1data");
  329. break;
  330. case 1:
  331. jsonText = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1data");
  332. break;
  333. case 2:
  334. jsonText = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1data");
  335. break;
  336. case 3:
  337. jsonText = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1data");
  338. break;
  339. case 4:
  340. jsonText = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1data");
  341. break;
  342. }
  343. JSONNode json = JSONNode.Parse(jsonText.text);
  344. JSONNode currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel];
  345. int wordListSize = GetCurrentWordListSize();
  346. m_CurrentWordList++;
  347. if (m_CurrentWordList >= wordListSize) //(m_CurrentWordList > wordListSize)
  348. {
  349. m_CurrentWordList = 1;
  350. //Updates mini-game's next level
  351. if (m_CurrentWordList < wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath)) //(m_CurrentWordList > wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath))
  352. {
  353. m_CurrentMinigameLevel++;
  354. if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
  355. {
  356. m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
  357. }
  358. currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel]; //myCode --rafael.
  359. PlayerData.Instance().SetActivityLevel(Activity.GumballScience, m_CurrentMinigameLevel);
  360. }
  361. }
  362. //Get a random word list set
  363. JSONNode selectedWordList = currentLevelWordLists["DataSet_" + m_CurrentWordList];
  364. JSONNode wordListSet = selectedWordList["Set_" + Random.Range(1, 4)];
  365. m_GumballMachine.Setup(wordListSet.Value, m_CurrentMinigameLevel);
  366. }
  367. //================================================================================
  368. //
  369. //================================================================================
  370. private int GetCurrentWordListSize()
  371. {
  372. int wordListSize = 0;
  373. //Check number of word lists
  374. if (m_CurrentMinigameLevel == 1)
  375. {
  376. if (!PlayerData.Instance().IsPracticeMode() && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath))
  377. {
  378. wordListSize = WORD_LIST_1_SIZE;//my code --rafael -> anteriormente era a seguinte constante WssORD_LIST_1_NON_PRACTICE_SIZE;
  379. }
  380. else
  381. {
  382. wordListSize = WORD_LIST_1_SIZE;
  383. }
  384. }
  385. else if (m_CurrentMinigameLevel == 2)
  386. {
  387. wordListSize = WORD_LIST_2_SIZE;
  388. }
  389. else
  390. {
  391. wordListSize = WORD_LIST_3_SIZE;
  392. }
  393. return wordListSize;
  394. }
  395. //================================================================================
  396. //
  397. //================================================================================
  398. public void ExecuteBallPath()
  399. {
  400. DisableInput();
  401. m_GumballMachine.ExecutePath();
  402. }
  403. //================================================================================
  404. //
  405. //================================================================================
  406. public void EnableInput()
  407. {
  408. blocker.enabled = false;
  409. m_GumballMachine.BallGuidersManager.EnableGuidersInput();
  410. m_GumballMachine.BallGuidersManager.EnableHook();
  411. }
  412. //================================================================================
  413. //
  414. //================================================================================
  415. public void DisableInput()
  416. {
  417. blocker.enabled = true;
  418. m_GumballMachine.BallGuidersManager.DisableHook();
  419. }
  420. //================================================================================
  421. //
  422. //================================================================================
  423. public void PlayCorrectAnswerSequence(string[] sentenceParts)
  424. {
  425. m_TotalCorrectCount++;
  426. int numberOfSpeeches = 0;
  427. NewSequence();
  428. string[] possibleWords = { "25205", "25206", "25207", "25208", "25209", "25210" };
  429. int randomNumber = Random.Range(0, possibleWords.Length);
  430. AudioManager.Instance().PlaySFX("25200");
  431. numberOfSpeeches = PlaySentence(sentenceParts, numberOfSpeeches);
  432. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, possibleWords[randomNumber]);
  433. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, GivePrize);
  434. if (!PlayerData.Instance().IsPracticeMode())
  435. {
  436. if (m_WinsCount + 1 == NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE && PlayerData.Instance().GetWhistle() == ItemState.None)
  437. {
  438. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25226");
  439. }
  440. else
  441. {
  442. if ((m_WinsCount + 1) % NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE == 0 && (PlayerData.Instance().GetWhistle() != ItemState.None ||
  443. m_PrizeWhistle.gameObject.activeSelf))
  444. {
  445. AudioManager.Instance().PlaySFX("2143");
  446. m_MarbleSpeechCount++;
  447. if (m_MarbleSpeechCount == 1)
  448. {
  449. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25230");
  450. }
  451. else if (m_MarbleSpeechCount == 2)
  452. {
  453. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25231");
  454. }
  455. else if (m_MarbleSpeechCount == 3)
  456. {
  457. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25232");
  458. m_MarbleSpeechCount = 0;
  459. }
  460. }
  461. }
  462. StartSequence(numberOfSpeeches);
  463. }
  464. else
  465. {
  466. GivePrize();
  467. }
  468. }
  469. //================================================================================
  470. //
  471. //================================================================================
  472. public void PlayWrongAnswerSequence(string[] sentenceParts, bool sameWord)
  473. {
  474. m_WrongCount++;
  475. int numberOfSpeeches = 0;
  476. string[] possibleWords = { "25261", "25262", "25263", "25264", "25265", "25266" };
  477. Characters[] possibleCharacters = { Characters.Gum, Characters.Sam, Characters.Reader, Characters.Gum, Characters.Sam, Characters.Reader };
  478. int randomNumber = Random.Range(0, possibleWords.Length);
  479. numberOfSpeeches = PlaySentence(sentenceParts, numberOfSpeeches);
  480. AudioManager.Instance().PlaySFX("25260");
  481. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
  482. if (sameWord)
  483. {
  484. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25268");
  485. }
  486. if (m_WrongCount == 4 && m_NumPaigeClicks == 0 && m_NumGumClicks == 0)
  487. {
  488. string[] possibleCharactersSpeeches = { "25270", "25271", "25273"}; //mycode --rafael --> I can found audio 25272 in the game project. This audio goes in that array.
  489. Characters[] possibleCharacters2 = { Characters.Gum, Characters.Paige, Characters.Paige, Characters.Paige };
  490. //randomNumber = Random.Range(0, possibleWords.Length);
  491. randomNumber = Random.Range(0, 3); //mycode --rafael --> original code commented above.
  492. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, possibleCharacters2[randomNumber], possibleCharactersSpeeches[randomNumber]);
  493. m_WrongCount = 0;
  494. }
  495. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
  496. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, EnableInput);
  497. StartSequence(numberOfSpeeches, false);
  498. }
  499. //================================================================================
  500. //
  501. //================================================================================
  502. public void PlayMissedSlotFeedback(bool sameSide)
  503. {
  504. if (sameSide)
  505. {
  506. NewSequence();
  507. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25268");
  508. StartSequence(1);
  509. }
  510. else
  511. {
  512. string[] possibleWords = { "25250", "25251", "25252", "25253", "25254"};
  513. Characters[] possibleCharacters = { Characters.Sam, Characters.Reader, Characters.Sam, Characters.Reader, Characters.Sam };
  514. int randomNumber = Random.Range(0, possibleWords.Length);
  515. NewSequence();
  516. /*SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
  517. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
  518. StartSequence(2);*/
  519. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
  520. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
  521. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, EnableInput); //mycode --rafael --original commented above.
  522. StartSequence(3, false);
  523. BoolTokenReleaseClicked = false; //mycode --rafael
  524. }
  525. }
  526. //================================================================================
  527. //
  528. //================================================================================
  529. public void GivePrize()
  530. {
  531. m_GumballMachine.BallGuidersManager.Reset(m_CurrentMinigameLevel);
  532. m_GumballMachine.Tray.CloseTray(() =>
  533. {
  534. DisableInput();
  535. if (!PlayerData.Instance().IsPracticeMode())
  536. {
  537. m_WinsCount++;
  538. if (m_WinsCount < NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE)
  539. {
  540. m_GumballMachine.UpdateWhistleState(m_WinsCount + 1);
  541. }
  542. if (m_WinsCount == NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE && PlayerData.Instance().GetWhistle() == ItemState.None)
  543. {
  544. m_GumballMachine.UpdateWhistleState(m_WinsCount + 1);
  545. PlayGivePrizeAnimation(m_PrizeWhistle);
  546. }
  547. else if (m_WinsCount % NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE == 0)
  548. {
  549. PlayGivePrizeAnimation(m_PrizeMarble);
  550. }
  551. else
  552. {
  553. m_PrizeCandyScript.isCollected = false; //mycode --rafael.
  554. PlayGivePrizeAnimation(m_PrizeCandy);
  555. }
  556. }
  557. else
  558. {
  559. LoadNextLevel();
  560. }
  561. });
  562. }
  563. //================================================================================
  564. //
  565. //================================================================================
  566. private void PlayGivePrizeAnimation(GameObject prize)
  567. {
  568. List<Vector3> path = new List<Vector3>();
  569. string onComplete = "";
  570. GameObject prizeAnimation = null;
  571. AudioManager.Instance().PlaySFX("25220");
  572. if (prize == m_PrizeCandy)
  573. {
  574. m_AnimationCandy.SetActive(true);
  575. m_AnimationCandy.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
  576. prizeAnimation = m_AnimationCandy;
  577. foreach (Transform t in m_AnimationCandyPath)
  578. {
  579. path.Add(t.position);
  580. }
  581. onComplete = "EnableCandy";
  582. }
  583. else if (prize == m_PrizeMarble)
  584. {
  585. m_AnimationMarble.SetActive(true);
  586. m_AnimationMarble.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
  587. prizeAnimation = m_AnimationMarble;
  588. foreach (Transform t in m_AnimationMarblePath)
  589. {
  590. path.Add(t.position);
  591. }
  592. onComplete = "EnableMarble";
  593. }
  594. else if (prize == m_PrizeWhistle)
  595. {
  596. m_AnimationWhistle.SetActive(true);
  597. m_AnimationWhistle.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
  598. prizeAnimation = m_AnimationWhistle;
  599. foreach (Transform t in m_AnimationWhistlePath)
  600. {
  601. path.Add(t.position);
  602. }
  603. onComplete = "EnableWhistle";
  604. }
  605. iTween.MoveTo(prizeAnimation, iTween.Hash(new object[] {
  606. "path", path.ToArray(), "time", 1f, "easetype", iTween.EaseType.linear, "oncompletetarget", this.gameObject, "oncomplete", onComplete
  607. }));
  608. }
  609. //================================================================================
  610. //
  611. //================================================================================
  612. protected override void OnIdle()
  613. {
  614. base.OnIdle();
  615. if (!PlayerData.Instance().IsPracticeMode())
  616. {
  617. int randomNumber = Random.Range(1, 4);
  618. int numberOfSpeeches = 0;
  619. NewSequence();
  620. if (randomNumber == 1)
  621. {
  622. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25300");
  623. }
  624. else if (randomNumber == 2)
  625. {
  626. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25301");
  627. }
  628. else if (randomNumber == 3)
  629. {
  630. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25304");
  631. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25305");
  632. }
  633. else if (randomNumber == 4)
  634. {
  635. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25306");
  636. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25307");
  637. }
  638. StartSequence(numberOfSpeeches);
  639. }
  640. }
  641. //================================================================================
  642. //
  643. //================================================================================
  644. public override void SpeechReader()
  645. {
  646. base.SpeechReader();
  647. if (!PlayerData.Instance().IsPracticeMode())
  648. {
  649. int randomNumber = Random.Range(1, 4);
  650. int numberOfSpeeches = 0;
  651. NewSequence();
  652. if (PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
  653. {
  654. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25152");
  655. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25456");
  656. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25457");
  657. }
  658. else if (PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf)
  659. {
  660. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25465");
  661. }
  662. else if (PlayerData.Instance().GetWhistle() != ItemState.None)
  663. {
  664. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25470");
  665. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25300");
  666. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25472");
  667. }
  668. StartSequence(numberOfSpeeches);
  669. }
  670. }
  671. //================================================================================
  672. //
  673. //================================================================================
  674. public override void SpeechPaige()
  675. {
  676. base.SpeechPaige();
  677. int numberOfSpeeches = 0;
  678. m_NumPaigeClicks++;
  679. NewSequence();
  680. if (PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
  681. {
  682. if (!m_BoolRampClicked)
  683. {
  684. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25405");
  685. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25406");
  686. }
  687. else
  688. {
  689. if (!m_BoolTokenReleaseClicked)
  690. {
  691. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
  692. }
  693. else
  694. {
  695. string[] possibleSpeehces = {"25268", "25405", "25406", "25407", "25415", "25416", "25417", "25418", "25419", "25420", "25425", "25426", "25410"};
  696. int index = 4 + m_NumPaigeClicks - 1;
  697. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleSpeehces[index]);
  698. }
  699. }
  700. }
  701. else if (PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf)
  702. {
  703. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25425");
  704. }
  705. else if (PlayerData.Instance().GetWhistle() != ItemState.None)
  706. {
  707. string[] possibleSpeehces = { "25426", "25416", "25417", "25418", "25419", "25420"};
  708. int index = m_NumPaigeClicks - 1;
  709. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleSpeehces[index]);
  710. }
  711. int maxPaigeClicks = 3;
  712. if (m_CurrentMinigameLevel == 3 && ((PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf) || PlayerData.Instance().GetWhistle() != ItemState.None))
  713. {
  714. maxPaigeClicks = 6;
  715. }
  716. if (m_NumPaigeClicks >= maxPaigeClicks)
  717. {
  718. m_NumPaigeClicks = 0;
  719. }
  720. StartSequence(numberOfSpeeches);
  721. }
  722. //================================================================================
  723. //
  724. //================================================================================
  725. protected override void OnOtherCharacterInteraction()
  726. {
  727. base.OnOtherCharacterInteraction();
  728. int numberOfSpeeches = 0;
  729. bool seqDone = false;
  730. m_NumGumClicks++;
  731. NewSequence();
  732. if ((PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf) ||
  733. (PlayerData.Instance().GetWhistle() != ItemState.None))
  734. {
  735. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25378");
  736. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25380");
  737. }
  738. else if(PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
  739. {
  740. if (!m_BoolRampClicked)
  741. {
  742. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25370");
  743. }
  744. else
  745. {
  746. if (!m_BoolTokenReleaseClicked)
  747. {
  748. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25371");
  749. }
  750. else
  751. {
  752. if (m_TotalCorrectCount == 0)
  753. {
  754. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25372");
  755. }
  756. else
  757. {
  758. seqDone = true;
  759. }
  760. }
  761. }
  762. if (!m_BoolSentenceClicked)
  763. {
  764. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25373");
  765. }
  766. if (seqDone && m_BoolSentenceClicked)
  767. {
  768. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25376");
  769. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25377");
  770. }
  771. }
  772. StartSequence(numberOfSpeeches);
  773. }
  774. //================================================================================
  775. //
  776. //================================================================================
  777. public void OnClickWhistle()
  778. {
  779. int numberOfSpeeches = 0;
  780. NewSequence();
  781. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25152");
  782. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25456");
  783. StartSequence(numberOfSpeeches);
  784. }
  785. //================================================================================
  786. //
  787. //================================================================================
  788. public void GetWhistle()
  789. {
  790. AudioManager.Instance().PlaySFX("1802");
  791. int numberOfSpeeches = 0;
  792. NewSequence();
  793. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.AnimationWithSfx,
  794. Characters.Sam,
  795. SAM_WHISTLE_ANIMATION,
  796. m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_WHISTLE_ANIMATION],
  797. "25224"); //TODO: confirm sfx
  798. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25571");
  799. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, AddWhistleToChest);
  800. StartSequence(numberOfSpeeches);
  801. }
  802. //================================================================================
  803. //
  804. //================================================================================
  805. public void OnClickCandy()
  806. {
  807. int numberOfSpeeches = 0;
  808. m_NumberCandyClicks++;
  809. NewSequence();
  810. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.AnimationWithSfx,
  811. Characters.Sam,
  812. SAM_CANDY_ANIMATION,
  813. m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_CANDY_ANIMATION],
  814. "1802"); //TODO: confirm sfx
  815. if (m_NumberCandyClicks < 4)
  816. {
  817. string[] possibleSpeeches = {"25555", "25556", "25557", "25558", "25559", "25560", "25561", "25562", "25563" };
  818. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, possibleSpeeches[m_NumberCandyClicks-1]);
  819. }
  820. else
  821. {
  822. int randomNumber = Random.Range(1, 4);
  823. if (randomNumber == 1)
  824. {
  825. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25561");
  826. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25562");
  827. }
  828. else if (randomNumber == 2)
  829. {
  830. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25559");
  831. }
  832. else if (randomNumber == 3)
  833. {
  834. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25560");
  835. }
  836. else if (randomNumber == 4)
  837. {
  838. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25563");
  839. }
  840. }
  841. StartSequence(numberOfSpeeches);
  842. }
  843. //================================================================================
  844. //
  845. //================================================================================
  846. private void AddWhistleToChest()
  847. {
  848. Chester.Instance().PutItem(ItemEnum.Whistle, this, this.GetChesterPosition().x, this.GetChesterPosition().y);
  849. }
  850. //================================================================================
  851. //
  852. //================================================================================
  853. public void OnClickGuider(GumballScienceBallGuider guider)
  854. {
  855. this.BoolRampClicked = true;
  856. if (!guider.Blocked)
  857. {
  858. if (m_CurrentClickedGuider == guider)
  859. {
  860. m_NumberOfCurGuiderClicks++;
  861. }
  862. else
  863. {
  864. m_CurrentClickedGuider = guider;
  865. }
  866. if (!m_BoolTokenReleaseClicked && m_NumberOfCurGuiderClicks == 3)
  867. {
  868. NewSequence();
  869. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
  870. StartSequence(1);
  871. m_NumberOfCurGuiderClicks = 0;
  872. }
  873. }
  874. else
  875. {
  876. AudioManager.Instance().PlaySFX("25127");
  877. NewSequence();
  878. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25410");
  879. StartSequence(1);
  880. }
  881. }
  882. //================================================================================
  883. //
  884. //================================================================================
  885. public void EnableCandy()
  886. {
  887. m_AnimationCandy.SetActive(false);
  888. m_PrizeCandy.SetActive(true);
  889. Invoke("LoadNextLevel", 0.5f);
  890. }
  891. //================================================================================
  892. //
  893. //================================================================================
  894. public void EnableMarble()
  895. {
  896. m_AnimationMarble.SetActive(false);
  897. //rafael alteration.
  898. Vector2 gunballPosition = m_GumballMachine.transform.position;
  899. gunballPosition.x = -134;
  900. gunballPosition.y = 18;
  901. m_PrizeMarble.transform.localPosition = gunballPosition;
  902. m_PrizeMarble.SetActive(true);
  903. Invoke("LoadNextLevel", 0.5f);
  904. }
  905. //================================================================================
  906. //
  907. //================================================================================
  908. public void EnableWhistle()
  909. {
  910. m_AnimationWhistle.SetActive(false);
  911. m_PrizeWhistle.SetActive(true);
  912. Invoke("LoadNextLevel", 0.5f);
  913. }
  914. //================================================================================
  915. //
  916. //================================================================================
  917. public void OnClickMarble()
  918. {
  919. if (PlayerData.Instance().GetGreenMarbleCount() == 0)
  920. {
  921. NewSequence();
  922. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25572");
  923. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_PrizeMarble.GetComponent<CollectableMarble>().DoAction);
  924. StartSequence(2);
  925. }
  926. else
  927. {
  928. m_PrizeMarble.GetComponent<CollectableMarble>().DoAction();
  929. }
  930. }
  931. //================================================================================
  932. //
  933. //================================================================================
  934. public void OnClickWord(string word)
  935. {
  936. m_WordClicks++;
  937. int numberOfSpeeches = 0;
  938. NewSequence();
  939. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, m_WordsList[word]);
  940. if (!m_BoolTokenReleaseClicked && m_WordClicks == 3)
  941. {
  942. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
  943. m_WordClicks = 0;
  944. }
  945. StartSequence(numberOfSpeeches);
  946. }
  947. //================================================================================
  948. //
  949. //================================================================================
  950. public void OnClickSentence(string sentence)
  951. {
  952. m_WordClicks++;
  953. int numberOfSpeeches = 0;
  954. NewSequence();
  955. int indexOfFirstUnderscore = sentence.IndexOf("_");
  956. sentence = sentence.Replace("_", "");
  957. sentence = sentence.Insert(indexOfFirstUnderscore, "_");
  958. string[] separators = { " " };
  959. string[] tokenizedSentence = sentence.Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
  960. string part = "";
  961. foreach (string token in tokenizedSentence)
  962. {
  963. if (token == "_")
  964. {
  965. if (part.Length > 0)
  966. {
  967. if (part.EndsWith(" "))
  968. {
  969. part = part.Remove(part.Length - 1, 1);
  970. }
  971. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
  972. }
  973. part = "";
  974. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, PlayBlankSFX);
  975. }
  976. else
  977. {
  978. part += token + " ";
  979. }
  980. }
  981. if (part.Length > 0)
  982. {
  983. if (part.EndsWith(" "))
  984. {
  985. part = part.Remove(part.Length - 1, 1);
  986. }
  987. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
  988. }
  989. if (!m_BoolTokenReleaseClicked && m_WordClicks == 3)
  990. {
  991. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
  992. m_WordClicks = 0;
  993. }
  994. StartSequence(numberOfSpeeches);
  995. }
  996. //================================================================================
  997. //
  998. //================================================================================
  999. public int PlaySentence(string[] sentenceParts, int numberOfSpeeches)
  1000. {
  1001. for (int i = 0; i < sentenceParts.Length; ++i)
  1002. {
  1003. if (sentenceParts[i].StartsWith(" "))
  1004. {
  1005. sentenceParts[i] = sentenceParts[i].Remove(0, 1);
  1006. }
  1007. if (sentenceParts[i].EndsWith(" "))
  1008. {
  1009. sentenceParts[i] = sentenceParts[i].Remove(sentenceParts[i].Length - 1, 1);
  1010. }
  1011. }
  1012. foreach (string part in sentenceParts)
  1013. {
  1014. if (int.Parse(GetSentencePartSpeechId(part)) >= INITIAL_SENTENCE_LIST)
  1015. {
  1016. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ " + GetSentencePartSpeechId(part));
  1017. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
  1018. }
  1019. else if (int.Parse(GetSentencePartSpeechId(part + ".")) >= INITIAL_SENTENCE_LIST)
  1020. {
  1021. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ ." + GetSentencePartSpeechId(part + "."));
  1022. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part + "."));
  1023. }
  1024. else if (part.Equals("."))//mycode --rafael. Correct the problem with frases like "A young dog is called a _____"
  1025. {
  1026. numberOfSpeeches++;
  1027. }
  1028. else
  1029. {
  1030. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ " + part);
  1031. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, m_WordsList[part]);
  1032. }
  1033. }
  1034. return numberOfSpeeches;
  1035. }
  1036. //================================================================================
  1037. //
  1038. //================================================================================
  1039. private void PlayBlankSFX()
  1040. {
  1041. AudioManager.Instance().PlaySFX("25999");
  1042. }
  1043. //================================================================================
  1044. //
  1045. //================================================================================
  1046. public string GetSentencePartSpeechId(string sentencePart)
  1047. {
  1048. int partId = INITIAL_SENTENCE_LIST + m_SentencesList.IndexOf(sentencePart) - 1;
  1049. return partId.ToString();
  1050. }
  1051. //================================================================================
  1052. //
  1053. //================================================================================
  1054. public int CurrentMinigameLevel
  1055. {
  1056. get { return m_CurrentMinigameLevel; }
  1057. }
  1058. //================================================================================
  1059. //
  1060. //================================================================================
  1061. public bool BoolRampClicked
  1062. {
  1063. get { return m_BoolRampClicked; }
  1064. set { m_BoolRampClicked = value; }
  1065. }
  1066. //================================================================================
  1067. //
  1068. //================================================================================
  1069. public bool BoolTokenReleaseClicked
  1070. {
  1071. get { return m_BoolTokenReleaseClicked; }
  1072. set { m_BoolTokenReleaseClicked = value; }
  1073. }
  1074. //================================================================================
  1075. //
  1076. //================================================================================
  1077. public bool BoolSentenceClicked
  1078. {
  1079. get { return m_BoolSentenceClicked; }
  1080. set { m_BoolSentenceClicked = value; }
  1081. }
  1082. } // public class SceneGumballScience : SceneCommon
  1083. } // namespace ReaderRabbit