SceneSillySandwichShop.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  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 SceneSillySandwichShop : SceneCommon
  17. {
  18. private enum Characters
  19. {
  20. Reader = CharactersCommon.Reader,
  21. Sam = CharactersCommon.Sam,
  22. Paige = CharactersCommon.Paige,
  23. Chester = CharactersCommon.Chester,
  24. LizardCashier = CharactersCommon.StartSceneSpecific,
  25. }
  26. private const int WORD_LIST_1_SIZE = 15;
  27. private const int WORD_LIST_2_SIZE = 27;
  28. private const int WORD_LIST_3_SIZE = 15;
  29. [SerializeField] private IngredientSelectionMachine m_IngredientSelectionMachine;
  30. [SerializeField] private CoinManager m_CoinManager;
  31. [SerializeField] private SandwichManager m_SandwichManager;
  32. [SerializeField] private SandwichHook m_SandwichHook;
  33. [SerializeField] private CollectableMarble m_Marble;
  34. private IngredientDescriptor m_SelectedIngredient;
  35. private IngredientDescriptor m_DraggedIngredient;
  36. private SpriteRenderer m_DraggedIngredientSprite;
  37. private int m_CurrentMinigameLevel;
  38. private bool m_SandwichIsClosing;
  39. private Vector3 m_PreviousMousePosition;
  40. private int m_WrongGuesses;
  41. private bool m_NotEnoughMoneySpchHeard;
  42. private bool m_TooMuchMoneySpchHeard;
  43. private int m_IdleHelpIndex;
  44. private int m_NumItemsUnlocked;
  45. private int m_MainCharSpchIndex;
  46. private int m_NumClicksPaige;
  47. private int m_ClawClickedCount;
  48. private bool m_FirstToppingSpchHeard;
  49. private bool m_RingBellSamSpchHeard;
  50. private int lang;
  51. //================================================================================
  52. //
  53. //================================================================================
  54. protected override void Start()
  55. {
  56. base.Start();
  57. //============================================================================
  58. //
  59. //============================================================================
  60. lang = PlayerPrefs.GetInt("language");
  61. if (lang == 0)
  62. m_SpeechFolder = "Resources_DA/Audio/SillySandwichShop_Speech";
  63. else if (lang == 1)
  64. m_SpeechFolder = "Resources_EN/Audio/SillySandwichShop_Speech";
  65. else if (lang == 2)
  66. m_SpeechFolder = "Resources_NO/Audio/SillySandwichShop_Speech";
  67. else if (lang == 3)
  68. m_SpeechFolder = "Resources_SP/Audio/SillySandwichShop_Speech";
  69. else if (lang == 4)
  70. m_SpeechFolder = "Resources_SW/Audio/SillySandwichShop_Speech";
  71. //============================================================================
  72. //
  73. //============================================================================
  74. PlayerData.Instance().SetVisitedSillySandwichShop(true);
  75. PlayerData.Instance().SetCurrentLocation(Location.SillySandwichShop);
  76. PlayerData.Instance().UnlockActivity(Activity.SillySandwichShop);
  77. AudioManager.Instance().PlayBGM("BGM_SillySandwichShop");
  78. this.m_WrongGuesses = 0;
  79. this.m_IdleHelpIndex = 0;
  80. this.m_NumItemsUnlocked = 0;
  81. this.m_MainCharSpchIndex = 0;
  82. this.m_NumClicksPaige = 0;
  83. this.m_NotEnoughMoneySpchHeard = false;
  84. this.m_TooMuchMoneySpchHeard = false;
  85. this.m_IngredientSelectionMachine.Owner = this;
  86. this.m_RingBellSamSpchHeard = false;
  87. this.m_ClawClickedCount = 0;
  88. // TODO: Load the saved level
  89. this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.SillySandwichShop);
  90. this.m_SandwichIsClosing = false;
  91. m_Marble.SetParentScene(this);
  92. KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
  93. LoadIngredientsDescriptions();
  94. }
  95. //================================================================================
  96. //
  97. //================================================================================
  98. protected override void PlayFirstEvent()
  99. {
  100. base.PlayFirstEvent();
  101. if (!PlayerData.Instance().IsPracticeMode())
  102. {
  103. if (m_IsFirstTime)
  104. {
  105. NewSequence();
  106. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19300");
  107. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19301");
  108. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19302");
  109. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19303");
  110. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19304");
  111. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19305");
  112. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19306");
  113. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19307");
  114. SetSequence(8, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19308");
  115. SetSequence(9, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19309");
  116. StartSequence(10);
  117. }
  118. else
  119. {
  120. int randomNumber = Random.Range(0, 1);
  121. string [] possibleSpeeches = {"19350", "19351"};
  122. NewSequence();
  123. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber]);
  124. StartSequence(1);
  125. }
  126. }
  127. else
  128. {
  129. NewSequence();
  130. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19300");
  131. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19301");
  132. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19302");
  133. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19303");
  134. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19304");
  135. SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19305");
  136. SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19306");
  137. SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19307");
  138. SetSequence(8, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19308");
  139. SetSequence(9, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19309");
  140. StartSequence(10);
  141. }
  142. }
  143. //================================================================================
  144. //
  145. //================================================================================
  146. public void OnChangeIngredient()
  147. {
  148. if (m_SandwichIsClosing)
  149. {
  150. GivePrize();
  151. return;
  152. }
  153. if (m_DraggedIngredient != null)
  154. {
  155. GameObject.Destroy(m_DraggedIngredient.gameObject);
  156. m_DraggedIngredient = null;
  157. m_DraggedIngredientSprite = null;
  158. }
  159. m_CoinManager.DisableAllCoins();
  160. }
  161. //================================================================================
  162. //
  163. //================================================================================
  164. public void PlayIngredientName(IngredientDescriptor ingredient)
  165. {
  166. NewSequence();
  167. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, ingredient.SoundId);
  168. StartSequence(1);
  169. }
  170. //================================================================================
  171. //
  172. //================================================================================
  173. public void TriggerMinigameStart(IngredientDescriptor ingredient)
  174. {
  175. if (m_SandwichIsClosing)
  176. {
  177. GivePrize();
  178. return;
  179. }
  180. int numberOfSpeeches = 0;
  181. NewSequence();
  182. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, ingredient.SoundId);
  183. if (m_SelectedIngredient == null)
  184. {
  185. if (!ingredient.Purchased)
  186. {
  187. AudioManager.Instance().PlaySFX("1806");
  188. if (!m_FirstToppingSpchHeard)
  189. {
  190. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19700");
  191. m_FirstToppingSpchHeard = true;
  192. }
  193. int randomNumber = Random.Range(5, 9);
  194. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "1970" + randomNumber);
  195. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19710");
  196. KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("ingredient.Price: " + ingredient.Price);
  197. numberOfSpeeches = SayPrice(ingredient.Price, numberOfSpeeches);
  198. }
  199. else
  200. {
  201. if (m_SandwichManager.IsIngredientMaxed(ingredient))
  202. {
  203. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19746");
  204. }
  205. }
  206. }
  207. else
  208. {
  209. if (!ingredient.Purchased)
  210. {
  211. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19715");
  212. numberOfSpeeches = SayPrice(ingredient.Price, numberOfSpeeches);
  213. AudioManager.Instance().PlaySFX("19711");
  214. if (m_CoinManager.TotalPrice == 0)
  215. {
  216. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19716");
  217. }
  218. else
  219. {
  220. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19717");
  221. }
  222. }
  223. else
  224. {
  225. if (m_SandwichManager.IsIngredientMaxed(ingredient))
  226. {
  227. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19746");
  228. }
  229. }
  230. }
  231. m_SelectedIngredient = ingredient;
  232. m_WrongGuesses = 0;
  233. m_CoinManager.Setup(ingredient.AvailableCoins[0],
  234. ingredient.AvailableCoins[1],
  235. ingredient.AvailableCoins[2],
  236. ingredient.AvailableCoins[3]);
  237. StartSequence(numberOfSpeeches);
  238. }
  239. //================================================================================
  240. //
  241. //================================================================================
  242. private void LoadIngredientsDescriptions()
  243. {
  244. TextAsset jsonText = null;
  245. if(lang == 0) jsonText = Resources.Load<TextAsset>("Resources_DA/SillySandwichShop/r1ia2");
  246. else if(lang == 1) jsonText = Resources.Load<TextAsset>("Resources_EN/SillySandwichShop/r1ia2");
  247. else if (lang == 2) jsonText = Resources.Load<TextAsset>("Resources_NO/SillySandwichShop/r1ia2");
  248. else if (lang == 3) jsonText = Resources.Load<TextAsset>("Resources_SP/SillySandwichShop/r1ia2");
  249. else if (lang == 4) jsonText = Resources.Load<TextAsset>("Resources_SW/SillySandwichShop/r1ia2");
  250. JSONNode json = JSONNode.Parse(jsonText.text);
  251. JSONNode currentLevelWordLists = json["DataSet"]["Level_"+m_CurrentMinigameLevel];
  252. int wordListSize = 0;
  253. if (currentLevelWordLists == 1)
  254. {
  255. wordListSize = WORD_LIST_1_SIZE;
  256. }
  257. else if (currentLevelWordLists == 2)
  258. {
  259. wordListSize = WORD_LIST_2_SIZE;
  260. }
  261. else
  262. {
  263. wordListSize = WORD_LIST_3_SIZE;
  264. }
  265. m_IngredientSelectionMachine.SetupIngredientsDescriptions(currentLevelWordLists, wordListSize);
  266. }
  267. //================================================================================
  268. //
  269. //================================================================================
  270. public void OnClickRingBell()
  271. {
  272. if (m_SandwichIsClosing)
  273. {
  274. GivePrize();
  275. return;
  276. }
  277. if (m_SelectedIngredient == null)
  278. {
  279. NewSequence();
  280. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19550");
  281. StartSequence(1);
  282. }
  283. else
  284. {
  285. m_CoinManager.UpdateTotalPrice();
  286. if (m_CoinManager.TotalPrice == 0)
  287. {
  288. NewSequence();
  289. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19603");
  290. StartSequence(0);
  291. }
  292. else if (!m_SelectedIngredient.Purchased)
  293. {
  294. m_CoinManager.UpdateTotalPrice();
  295. if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price)
  296. {
  297. int numberOfSpeeches = 0;
  298. int randomNumber = Random.Range(0, 3);
  299. int randomNumber2 = Random.Range(0, 4);
  300. string[] possibleSpeeches = { "19400", "19401", "19402", "19403" };
  301. string[] possibleSpeeches2 = { "19404", "19405", "19406", "19407", "19408" };
  302. NewSequence();
  303. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber]);
  304. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches2[randomNumber2]);
  305. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, PlayUnlockSfx);
  306. if (m_NumItemsUnlocked == 1)
  307. {
  308. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19415");
  309. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19416");
  310. }
  311. else if (m_NumItemsUnlocked == 2)
  312. {
  313. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19554");
  314. }
  315. else if (m_NumItemsUnlocked == 3)
  316. {
  317. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19417");
  318. }
  319. StartSequence(numberOfSpeeches++);
  320. m_SelectedIngredient.Purchased = true;
  321. AudioManager.Instance().PlaySFX("19420");
  322. m_CoinManager.DisableAllCoins(false);
  323. m_IngredientSelectionMachine.UpdateIngredientsAreaBorder(m_SelectedIngredient);
  324. m_WrongGuesses = 0;
  325. m_NumItemsUnlocked++;
  326. }
  327. else
  328. {
  329. SayIncorrectPrice();
  330. }
  331. }
  332. }
  333. }
  334. //================================================================================
  335. //
  336. //================================================================================
  337. public void PlayUnlockSfx()
  338. {
  339. AudioManager.Instance().PlaySFX("19410");
  340. }
  341. //================================================================================
  342. //
  343. //================================================================================
  344. public void OnClickLizard()
  345. {
  346. int numberOfSpeeches = 0;
  347. NewSequence();
  348. if (m_SelectedIngredient == null)
  349. {
  350. if (m_NumItemsUnlocked == 0)
  351. {
  352. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19550");
  353. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19551");
  354. }
  355. else if (m_NumItemsUnlocked == 1 && m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
  356. {
  357. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19552");
  358. }
  359. else if (m_NumItemsUnlocked == 1 && m_SandwichManager.GetNumberOfDifferendIngredients() > 0)
  360. {
  361. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19553");
  362. }
  363. else if (m_NumItemsUnlocked > 1 && m_SandwichManager.GetNumberOfDifferendIngredients() < 3)
  364. {
  365. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19554");
  366. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19555");
  367. }
  368. else if (m_NumItemsUnlocked > 2)
  369. {
  370. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19556");
  371. }
  372. }
  373. else
  374. {
  375. if (m_CoinManager.TotalPrice == 0)
  376. {
  377. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19560");
  378. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19561");
  379. }
  380. else
  381. {
  382. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19562");
  383. }
  384. }
  385. StartSequence(numberOfSpeeches);
  386. }
  387. //================================================================================
  388. //
  389. //================================================================================
  390. protected override void OnOtherCharacterInteraction()
  391. {
  392. base.OnOtherCharacterInteraction();
  393. OnClickLizard();
  394. }
  395. //================================================================================
  396. //
  397. //================================================================================
  398. public override void SpeechReader()
  399. {
  400. base.SpeechReader();
  401. m_MainCharSpchIndex++;
  402. if (m_MainCharSpchIndex > 4)
  403. {
  404. m_MainCharSpchIndex = 1;
  405. }
  406. NewSequence();
  407. if (m_MainCharSpchIndex == 1)
  408. {
  409. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19650");
  410. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19651");
  411. }
  412. else if (m_MainCharSpchIndex == 2)
  413. {
  414. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19652");
  415. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19653");
  416. }
  417. else if (m_MainCharSpchIndex == 3)
  418. {
  419. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19654");
  420. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19655");
  421. }
  422. else if (m_MainCharSpchIndex == 4)
  423. {
  424. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19656");
  425. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19657");
  426. }
  427. StartSequence(2);
  428. }
  429. //================================================================================
  430. //
  431. //================================================================================
  432. public override void SpeechPaige()
  433. {
  434. base.SpeechPaige();
  435. int numberOfSpeeches = 0;
  436. NewSequence();
  437. if (m_SelectedIngredient == null)
  438. {
  439. if (m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
  440. {
  441. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19600");
  442. }
  443. else
  444. {
  445. if (m_SandwichManager.GetNumberOfDifferendIngredients() < 3)
  446. {
  447. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19601");
  448. }
  449. else
  450. {
  451. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19602");
  452. }
  453. }
  454. }
  455. else
  456. {
  457. if (m_CoinManager.TotalPrice == 0)
  458. {
  459. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19603");
  460. }
  461. else
  462. {
  463. m_NumClicksPaige++;
  464. if(m_NumClicksPaige > 4)
  465. {
  466. m_NumClicksPaige = 1;
  467. }
  468. if (m_NumItemsUnlocked == 0)
  469. {
  470. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19610");
  471. }
  472. else
  473. {
  474. if (m_NumClicksPaige == 4)
  475. {
  476. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19611");
  477. }
  478. else if (m_NumClicksPaige == 3)
  479. {
  480. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19612");
  481. }
  482. else if (m_NumClicksPaige == 2)
  483. {
  484. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19613");
  485. }
  486. else if (m_NumClicksPaige == 1)
  487. {
  488. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19614");
  489. }
  490. }
  491. }
  492. }
  493. StartSequence(numberOfSpeeches);
  494. }
  495. //================================================================================
  496. //
  497. //================================================================================
  498. protected override void Update()
  499. {
  500. base.Update();
  501. if (m_SandwichIsClosing)
  502. {
  503. if (Input.GetMouseButton(0))
  504. {
  505. GivePrize();
  506. }
  507. }
  508. else if (m_DraggedIngredient != null)
  509. {
  510. //this.m_DraggedIngredient.transform.position += (Camera.main.ScreenToWorldPoint(Input.mousePosition) - m_PreviousMousePosition);
  511. m_PreviousMousePosition = Input.mousePosition;
  512. m_PreviousMousePosition.y = -(Screen.height - m_PreviousMousePosition.y);
  513. m_PreviousMousePosition.y += this.m_DraggedIngredientSprite.bounds.extents.y;
  514. m_PreviousMousePosition.x -= this.m_DraggedIngredientSprite.bounds.extents.x;
  515. this.m_DraggedIngredient.transform.position = m_PreviousMousePosition;
  516. #if UNITY_IPHONE || UNITY_ANDROID
  517. if (Input.GetMouseButtonUp(0))
  518. {
  519. if (m_DraggedIngredient.Purchased)
  520. UpPurchasedIngredient(m_DraggedIngredient);
  521. }
  522. #endif
  523. }
  524. //m_PreviousMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
  525. }
  526. //================================================================================
  527. //
  528. //================================================================================
  529. public void SetSelectedIngredient(IngredientDescriptor ingredient)
  530. {
  531. if (m_DraggedIngredient == null)
  532. m_DraggedIngredient = m_IngredientSelectionMachine.InstantiatePurchasedIngredient(ingredient);
  533. if (m_DraggedIngredient != null)
  534. m_DraggedIngredientSprite = m_DraggedIngredient.GetComponent<SpriteRenderer>();
  535. }
  536. //================================================================================
  537. //
  538. //================================================================================
  539. public void ReleasePurchasedIngredient(bool destroy)
  540. {
  541. m_DraggedIngredient.GetComponent<Collider2D>().enabled = false;
  542. if (destroy)
  543. {
  544. GameObject.Destroy(m_DraggedIngredient.gameObject);
  545. }
  546. m_DraggedIngredient = null;
  547. m_DraggedIngredientSprite = null;
  548. }
  549. //================================================================================
  550. //
  551. //================================================================================
  552. public void UpPurchasedIngredient(IngredientDescriptor ingredient)
  553. {
  554. SetSelectedIngredient(ingredient);
  555. if (IsSelectedIngredient(ingredient))
  556. {
  557. Vector2 mousePosition = Input.mousePosition;
  558. mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
  559. ReleasePurchasedIngredient(!SandwichManager.ProcessIngredientAddition(ingredient, mousePosition));
  560. }
  561. }
  562. //================================================================================
  563. //
  564. //================================================================================
  565. public bool IsSelectedIngredient(IngredientDescriptor ingredient)
  566. {
  567. return (m_DraggedIngredient == ingredient);
  568. }
  569. //================================================================================
  570. //
  571. //================================================================================
  572. protected override void OnIdle()
  573. {
  574. base.OnIdle();
  575. m_IdleHelpIndex++;
  576. if (m_IdleHelpIndex > 2)
  577. {
  578. m_IdleHelpIndex = 1;
  579. }
  580. int numberOfSpeeches = 0;
  581. NewSequence();
  582. if (m_CoinManager.TotalPrice > 0)
  583. {
  584. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19500");
  585. }
  586. if(m_IdleHelpIndex == 1)
  587. {
  588. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19501");
  589. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19502");
  590. }
  591. else
  592. {
  593. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19503");
  594. }
  595. StartSequence(numberOfSpeeches);
  596. }
  597. //================================================================================
  598. //
  599. //================================================================================
  600. public IngredientSelectionMachine IngredientSelectionMachine
  601. {
  602. get { return m_IngredientSelectionMachine; }
  603. }
  604. //================================================================================
  605. //
  606. //================================================================================
  607. public CoinManager CoinManager
  608. {
  609. get { return m_CoinManager; }
  610. }
  611. //================================================================================
  612. //
  613. //================================================================================
  614. public SandwichManager SandwichManager
  615. {
  616. get { return m_SandwichManager; }
  617. }
  618. //================================================================================
  619. //
  620. //================================================================================
  621. public void OnClickHook()
  622. {
  623. if (SandwichManager.HasEnoughIngredients())
  624. {
  625. AudioManager.Instance().PlaySFX("19725");
  626. m_SandwichHook.CloseSandwich();
  627. Invoke ("EnableClickToGivePrize", 0.1f);
  628. }
  629. PlayOnClickClawSpeech();
  630. }
  631. //================================================================================
  632. //
  633. //================================================================================
  634. private void EnableClickToGivePrize()
  635. {
  636. m_SandwichIsClosing = true;
  637. }
  638. //================================================================================
  639. //
  640. //================================================================================
  641. private void GivePrize()
  642. {
  643. m_SandwichIsClosing = false;
  644. // TODO: Check if in practice mode
  645. PlayCollecItemSpeech();
  646. Chester.Instance().PutItemMultiple(ItemMultipleEnum.Sandwich, this, this.GetChesterPosition().x, this.GetChesterPosition().y);
  647. if (m_CurrentMinigameLevel < 3 && !PlayerData.Instance().IsActivityLocked(Activity.SillySandwichShop))
  648. {
  649. m_CurrentMinigameLevel++;
  650. }
  651. PlayerData.Instance().SetActivityLevel(Activity.SillySandwichShop, m_CurrentMinigameLevel);
  652. RestartMinigame();
  653. }
  654. //================================================================================
  655. //
  656. //================================================================================
  657. public void EnableMarble()
  658. {
  659. AudioManager.Instance().PlaySFX("19735");
  660. m_Marble.gameObject.SetActive(true);
  661. }
  662. //================================================================================
  663. //
  664. //================================================================================
  665. private void RestartMinigame()
  666. {
  667. this.LoadIngredientsDescriptions();
  668. this.m_SandwichHook.Reset();
  669. this.m_SandwichManager.Reset();
  670. this.m_CoinManager.Reset();
  671. this.m_IngredientSelectionMachine.Reset();
  672. this.m_NumItemsUnlocked = 0;
  673. this.m_WrongGuesses = 0;
  674. }
  675. //================================================================================
  676. //
  677. //================================================================================
  678. protected override void OnNavigation()
  679. {
  680. string[] possibleSpeeches = { "19110", "19111", "19112", "19113" };
  681. Characters[] characters = { Characters.Reader, Characters.Sam, Characters.LizardCashier, Characters.LizardCashier };
  682. int random = Random.Range(0, possibleSpeeches.Length);
  683. NewSequence();
  684. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[random], possibleSpeeches[random]);
  685. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, base.OnNavigation);
  686. StartSequence(2, false);
  687. }
  688. //================================================================================
  689. //
  690. //================================================================================
  691. public void OnClickCashRegister()
  692. {
  693. if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price)
  694. {
  695. SayPrice();
  696. }
  697. else
  698. {
  699. SayIncorrectPrice();
  700. }
  701. }
  702. //================================================================================
  703. //
  704. //================================================================================
  705. public void SayPrice()
  706. {
  707. SayPrice(m_CoinManager.TotalPrice, 0);
  708. }
  709. //================================================================================
  710. //
  711. //================================================================================
  712. public int SayPrice(params object[] parameters)
  713. {
  714. int price = (int)parameters[0];
  715. int cents = price % 100;
  716. int dollars = (price - cents) / 100;
  717. int numberOfSpeeches = (int)parameters[1];
  718. if (price > 199)
  719. {
  720. if (price > 1999)
  721. {
  722. int onesDigit = dollars % 10;
  723. int tensDigit = dollars / 10 - onesDigit / 10;
  724. if (tensDigit > 1)
  725. {
  726. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19279 + tensDigit - 2).ToString());
  727. }
  728. else if (tensDigit == 1)
  729. {
  730. onesDigit = onesDigit + 10;
  731. }
  732. if (onesDigit > 0)
  733. {
  734. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + onesDigit - 1).ToString());
  735. }
  736. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19287");
  737. if (cents > 0)
  738. {
  739. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
  740. }
  741. }
  742. else
  743. {
  744. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + dollars - 1).ToString());
  745. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19289");
  746. if (cents > 0)
  747. {
  748. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
  749. }
  750. }
  751. }
  752. else
  753. {
  754. if (price > 99)
  755. {
  756. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + dollars - 1).ToString());
  757. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19288");
  758. if (cents > 0)
  759. {
  760. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
  761. }
  762. }
  763. }
  764. if (cents > 0)
  765. {
  766. if (cents == 1)
  767. {
  768. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19260");
  769. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19291");
  770. }
  771. else
  772. {
  773. int onesDigit = cents % 10;
  774. int tensDigit = cents / 10 - onesDigit / 10;
  775. if (tensDigit > 1)
  776. {
  777. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19279 + tensDigit - 2).ToString());
  778. }
  779. else if (tensDigit == 1)
  780. {
  781. onesDigit = onesDigit + 10;
  782. }
  783. if (onesDigit > 0)
  784. {
  785. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + onesDigit - 1).ToString());
  786. }
  787. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19290");
  788. }
  789. }
  790. if (dollars == 0 && cents == 0)
  791. {
  792. //TODO: Could not found the sound 2867
  793. //SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "2867");
  794. }
  795. return numberOfSpeeches;
  796. }
  797. //================================================================================
  798. //
  799. //================================================================================
  800. public void SayIncorrectPrice()
  801. {
  802. m_WrongGuesses++;
  803. int numberOfSpeeches = 0;
  804. NewSequence();
  805. if (m_CoinManager.TotalPrice < m_SelectedIngredient.Price)
  806. {
  807. string[] possibleSpeeches = { "19450", "19451", "19452" };
  808. if (!m_NotEnoughMoneySpchHeard)
  809. {
  810. int randomNumber = Random.Range(1, 3);
  811. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber - 1]);
  812. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19453");
  813. numberOfSpeeches = SayPrice(m_SelectedIngredient.Price, numberOfSpeeches);
  814. if (m_CurrentMinigameLevel == 1)
  815. {
  816. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19454");
  817. numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice, numberOfSpeeches);
  818. }
  819. m_NotEnoughMoneySpchHeard = true;
  820. }
  821. else
  822. {
  823. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19460");
  824. numberOfSpeeches = SayPrice(m_SelectedIngredient.Price - m_CoinManager.TotalPrice, numberOfSpeeches);
  825. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19462");
  826. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19464");
  827. numberOfSpeeches = SayPrice(m_SelectedIngredient.Price - m_CoinManager.TotalPrice, numberOfSpeeches);
  828. }
  829. }
  830. else
  831. {
  832. string[] possibleSpeeches = { "19475", "19476", "19477" };
  833. if (!m_TooMuchMoneySpchHeard)
  834. {
  835. int randomNumber = Random.Range(1, 3);
  836. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber - 1]);
  837. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19453");
  838. numberOfSpeeches = SayPrice(m_SelectedIngredient.Price, numberOfSpeeches);
  839. if (m_CurrentMinigameLevel == 1)
  840. {
  841. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19454");
  842. numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice, numberOfSpeeches);
  843. }
  844. m_TooMuchMoneySpchHeard = true;
  845. }
  846. else
  847. {
  848. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19480");
  849. numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice - m_SelectedIngredient.Price, numberOfSpeeches);
  850. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19482");
  851. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19484");
  852. numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice - m_SelectedIngredient.Price, numberOfSpeeches);
  853. }
  854. }
  855. if (m_WrongGuesses == 5)
  856. {
  857. int randomNumber = Random.Range(1, 2);
  858. if (randomNumber == 1)
  859. {
  860. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19490");
  861. }
  862. else
  863. {
  864. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19491");
  865. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19492");
  866. }
  867. }
  868. else if (m_WrongGuesses == 7)
  869. {
  870. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19493");
  871. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19494");
  872. }
  873. StartSequence(numberOfSpeeches);
  874. }
  875. //================================================================================
  876. //
  877. //================================================================================
  878. public void PlayReleaseCoinSpeech()
  879. {
  880. if (this.m_CurrentMinigameLevel == 1)
  881. {
  882. if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price && !m_RingBellSamSpchHeard)
  883. {
  884. m_RingBellSamSpchHeard = true;
  885. NewSequence();
  886. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19722");
  887. StartSequence(1);
  888. }
  889. }
  890. }
  891. //================================================================================
  892. //
  893. //================================================================================
  894. public void PlayChangedYourMindSpeech(IngredientDescriptor ingredient)
  895. {
  896. AudioManager.Instance().PlaySFX("19172");
  897. if (m_SelectedIngredient == null || m_SelectedIngredient.IngredientName == ingredient.IngredientName)
  898. {
  899. NewSequence();
  900. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19720");
  901. StartSequence(1);
  902. }
  903. }
  904. //================================================================================
  905. //
  906. //================================================================================
  907. public void PlayOnClickClawSpeech()
  908. {
  909. m_ClawClickedCount++;
  910. if (m_ClawClickedCount > 3)
  911. {
  912. m_ClawClickedCount = 1;
  913. }
  914. int numberOfSpeeches = 0;
  915. NewSequence();
  916. if (m_SandwichManager.HasEnoughIngredients())
  917. {
  918. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19726");
  919. if (!PlayerData.Instance().IsPracticeMode())
  920. {
  921. if (PlayerData.Instance().RTM_UsedCatapultCount > 0)
  922. {
  923. string[] possibleSpeeches = { "19727", "19728", "19729" };
  924. Characters[] speechers = { Characters.Reader, Characters.Sam, Characters.Reader };
  925. int randomNumber = Random.Range(0, possibleSpeeches.Length);
  926. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, speechers[randomNumber], possibleSpeeches[randomNumber]);
  927. }
  928. else
  929. {
  930. string[] possibleSpeeches = { "19730", "19731" };
  931. Characters[] speechers = { Characters.Reader, Characters.Sam };
  932. int randomNumber = Random.Range(0, possibleSpeeches.Length);
  933. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, speechers[randomNumber], possibleSpeeches[randomNumber]);
  934. }
  935. }
  936. }
  937. else
  938. {
  939. if (m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
  940. {
  941. if (m_NumItemsUnlocked == 0)
  942. {
  943. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19739");
  944. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19740");
  945. }
  946. else
  947. {
  948. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19738");
  949. }
  950. }
  951. else
  952. {
  953. if (m_ClawClickedCount == 1)
  954. {
  955. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19741");
  956. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19742");
  957. }
  958. else if (m_ClawClickedCount == 2)
  959. {
  960. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19743");
  961. }
  962. else if (m_ClawClickedCount == 3)
  963. {
  964. SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19744");
  965. }
  966. }
  967. }
  968. StartSequence(numberOfSpeeches);
  969. }
  970. //================================================================================
  971. //
  972. //================================================================================
  973. public void PlayCollecItemSpeech()
  974. {
  975. if(!PlayerData.Instance().IsPracticeMode())
  976. {
  977. int speechCount = 0;
  978. NewSequence();
  979. if (!m_Marble.gameObject.activeSelf)
  980. {
  981. SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19732");
  982. SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19733");
  983. SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Callback, EnableMarble);
  984. }
  985. else
  986. {
  987. SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19734");
  988. }
  989. StartSequence(speechCount);
  990. }
  991. }
  992. //================================================================================
  993. //
  994. //================================================================================
  995. public void GetMarble()
  996. {
  997. m_Marble.DoAction();
  998. }
  999. } // public class SceneSillySandwichShop : SceneCommon
  1000. } // namespace ReaderRabbit