SceneAmazingArtGallery.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. //================================================================================
  7. //
  8. //================================================================================
  9. namespace ReaderRabbit
  10. {
  11. //================================================================================
  12. //
  13. //================================================================================
  14. public class SceneAmazingArtGallery : SceneCommon
  15. {
  16. //================================================================================
  17. //
  18. //================================================================================
  19. private enum Characters
  20. {
  21. Reader = CharactersCommon.Reader,
  22. Sam = CharactersCommon.Sam,
  23. Paige = CharactersCommon.Paige,
  24. }
  25. //================================================================================
  26. //
  27. //================================================================================
  28. [SerializeField] private Painter m_Painter;
  29. private const int REQUIRED_PAGES = 4;
  30. private const int READER_MAX_SPEECH_INDEX = 7;
  31. private int m_ReaderSpeechIndex;
  32. private int m_GameState;
  33. //================================================================================
  34. //
  35. //================================================================================
  36. protected override void Start()
  37. {
  38. base.Start();
  39. //============================================================================
  40. //
  41. //============================================================================
  42. int lang = PlayerPrefs.GetInt("language");
  43. if (lang == 0)
  44. m_SpeechFolder = "Resources_DA/Audio/AmazingArtGallery_Speech";
  45. else if (lang == 1)
  46. m_SpeechFolder = "Resources_EN/Audio/AmazingArtGallery_Speech";
  47. else if (lang == 2)
  48. m_SpeechFolder = "Resources_NO/Audio/AmazingArtGallery_Speech";
  49. else if (lang == 3)
  50. m_SpeechFolder = "Resources_SP/Audio/AmazingArtGallery_Speech";
  51. else if (lang == 4)
  52. m_SpeechFolder = "Resources_SW/Audio/AmazingArtGallery_Speech";
  53. //============================================================================
  54. //
  55. //============================================================================
  56. PlayerData.Instance().SetVisitedAmazingArtGallery(true);
  57. PlayerData.Instance().SetCurrentLocation(Location.AmazingArtGallery);
  58. PlayerData.Instance().UnlockActivity(Activity.AmazingArtGallery);
  59. AudioManager.Instance().PlayBGM("BGM_AmazingArtGallery");
  60. m_ReaderSpeechIndex = 0;
  61. if (m_Painter.FramesManager.GetMarkedFrameCount() > 0)
  62. m_GameState = 3;
  63. else
  64. {
  65. if (m_IsFirstTime)
  66. m_GameState = 2;
  67. else
  68. {
  69. if (SelectedPaintingFrame != null && (SelectedPaintingFrame.Equals("Blue") || SelectedPaintingFrame.Equals("Cyan")))
  70. m_GameState = 2;
  71. else
  72. m_GameState = 1;
  73. }
  74. }
  75. }
  76. //================================================================================
  77. //
  78. //================================================================================
  79. public static string SelectedPaintingFrame
  80. {
  81. get; set;
  82. }
  83. //================================================================================
  84. //
  85. //================================================================================
  86. protected override void StartedFadeOut ()
  87. {
  88. base.StartedFadeOut();
  89. m_Painter.SaveCurrentFrames();
  90. }
  91. //================================================================================
  92. //
  93. //================================================================================
  94. protected override void PlayFirstEvent()
  95. {
  96. switch (m_GameState)
  97. {
  98. case 1:
  99. ++PlayerData.Instance().AAG_Enter1Count;
  100. if (PlayerData.Instance().AAG_Enter1Count == 1)
  101. {
  102. NewSequence();
  103. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11350");
  104. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  105. StartSequence(2);
  106. }
  107. else
  108. {
  109. Characters[] possibleCharacters = { Characters.Sam, Characters.Reader, Characters.Sam };
  110. string[] possibleNumbers = { "11351", "11352", "11353" };
  111. int randomValue = Random.Range(0, possibleNumbers.Length);
  112. NewSequence();
  113. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
  114. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  115. StartSequence(2);
  116. }
  117. break;
  118. case 2:
  119. ++PlayerData.Instance().AAG_Enter2Count;
  120. if (PlayerData.Instance().AAG_Enter2Count == 1)
  121. {
  122. NewSequence();
  123. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11360");
  124. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11361");
  125. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  126. StartSequence(3);
  127. }
  128. else
  129. {
  130. Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader };
  131. string[] possibleNumbers = { "11370", "11371", "11372" };
  132. int randomValue = Random.Range(0, possibleNumbers.Length);
  133. NewSequence();
  134. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
  135. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  136. StartSequence(2);
  137. }
  138. break;
  139. case 3:
  140. ++PlayerData.Instance().AAG_Enter3Count;
  141. if (PlayerData.Instance().AAG_Enter3Count == 1)
  142. {
  143. NewSequence();
  144. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11380");
  145. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  146. StartSequence(2);
  147. }
  148. else
  149. {
  150. Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader };
  151. string[] possibleNumbers = { "11381", "11382", "11383" };
  152. int randomValue = Random.Range(0, possibleNumbers.Length);
  153. NewSequence();
  154. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
  155. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
  156. StartSequence(2);
  157. }
  158. break;
  159. }
  160. }
  161. //================================================================================
  162. //
  163. //================================================================================
  164. private void PaigeHelpSpeech()
  165. {
  166. Invoke("PaigeHelpSpeechDelayed", 0.1f);
  167. }
  168. //================================================================================
  169. //
  170. //================================================================================
  171. private void PaigeHelpSpeechDelayed()
  172. {
  173. int k = 0;
  174. if (!PlayerData.Instance().AAG_PaintUsed)
  175. {
  176. NewSequence();
  177. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.SelectBrush);
  178. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11600");
  179. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.RestorePreviousSelectedTool);
  180. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  181. StartSequence(4);
  182. k = 1;
  183. }
  184. if (k == 0 && !PlayerData.Instance().AAG_TwoPagesUsed)
  185. {
  186. NewSequence();
  187. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.NextButtonHighlight);
  188. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11601");
  189. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.NextButtonNoHighlight);
  190. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  191. StartSequence(4);
  192. k = 2;
  193. }
  194. if (k == 0 && !PlayerData.Instance().AAG_FillUsed)
  195. {
  196. NewSequence();
  197. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.SelectBucket);
  198. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11602");
  199. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.RestorePreviousSelectedTool);
  200. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  201. StartSequence(4);
  202. k = 3;
  203. }
  204. if (k == 0 && !PlayerData.Instance().AAG_StampUsed)
  205. {
  206. // TODO: Highlight all stamps.
  207. NewSequence();
  208. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11603");
  209. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  210. StartSequence(2);
  211. k = 4;
  212. }
  213. if (k == 0 && !PlayerData.Instance().AAG_PlayUsed)
  214. {
  215. NewSequence();
  216. SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.PlayButtonHighlight);
  217. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11604");
  218. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.PlayButtonNoHighlight);
  219. SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  220. StartSequence(4);
  221. k = 5;
  222. }
  223. }
  224. //================================================================================
  225. //
  226. //================================================================================
  227. protected override void OnIdle()
  228. {
  229. string[] possibleNumbers = { "11500", "11501", "11502", "11503" };
  230. Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader, Characters.Sam };
  231. int randomValue = Random.Range(0, possibleNumbers.Length);
  232. NewSequence();
  233. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
  234. StartSequence(1);
  235. }
  236. //================================================================================
  237. //
  238. //================================================================================
  239. public override void SpeechReader()
  240. {
  241. ++m_ReaderSpeechIndex;
  242. if (m_ReaderSpeechIndex > READER_MAX_SPEECH_INDEX)
  243. m_ReaderSpeechIndex = 1;
  244. switch (m_ReaderSpeechIndex)
  245. {
  246. case 1:
  247. NewSequence();
  248. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11650");
  249. StartSequence(1);
  250. break;
  251. case 2:
  252. NewSequence();
  253. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11651");
  254. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11652");
  255. StartSequence(2);
  256. break;
  257. case 3:
  258. NewSequence();
  259. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11653");
  260. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11654");
  261. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11655");
  262. StartSequence(3);
  263. break;
  264. case 4:
  265. NewSequence();
  266. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11656");
  267. StartSequence(1);
  268. break;
  269. case 5:
  270. NewSequence();
  271. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11657");
  272. StartSequence(1);
  273. break;
  274. case 6:
  275. NewSequence();
  276. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11658");
  277. StartSequence(1);
  278. break;
  279. case 7:
  280. NewSequence();
  281. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11659");
  282. StartSequence(1);
  283. break;
  284. }
  285. }
  286. //================================================================================
  287. //
  288. //================================================================================
  289. public override void SpeechPaige()
  290. {
  291. NewSequence();
  292. int sequence = 0;
  293. bool queued = false;
  294. if (m_Painter.FramesManager.CurrentFrameIndex != 0
  295. && m_Painter.FramesManager.IsFrameMarked(m_Painter.FramesManager.CurrentFrameIndex - 1)
  296. && !PlayerData.Instance().AAG_PaigeClicked)
  297. {
  298. PlayerData.Instance().AAG_PaigeClicked = true;
  299. // User it not on first page and the previous page is not blank.
  300. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11550");
  301. queued = true;
  302. }
  303. if (m_Painter.FramesManager.GetMarkedFrameCount() == 1 && !queued)
  304. {
  305. // User has only drawn on page 1.
  306. int randomValue = Random.Range(0, 100);
  307. if (randomValue < 50)
  308. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11552");
  309. else
  310. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11553");
  311. queued = true;
  312. }
  313. if (m_Painter.FramesManager.GetMarkedFrameCount() < REQUIRED_PAGES
  314. && !PlayerData.Instance().IsPracticeMode()
  315. && !queued)
  316. {
  317. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11554");
  318. queued = true;
  319. }
  320. if (!queued)
  321. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11555");
  322. StartSequence(sequence);
  323. }
  324. //================================================================================
  325. //
  326. //================================================================================
  327. public void NextClick(int frameIndex)
  328. {
  329. if (PlayerData.Instance().AAG_NextClickCount == 0)
  330. {
  331. ++PlayerData.Instance().AAG_NextClickCount;
  332. NewSequence();
  333. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11700");
  334. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11701");
  335. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11702");
  336. StartSequence(3);
  337. }
  338. if (PlayerData.Instance().AAG_NextClickCount == 1 && frameIndex == 3)
  339. {
  340. ++PlayerData.Instance().AAG_NextClickCount;
  341. NewSequence();
  342. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11703");
  343. StartSequence(1);
  344. }
  345. }
  346. //================================================================================
  347. //
  348. //================================================================================
  349. public void UndoClick()
  350. {
  351. NewSequence();
  352. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11239");
  353. StartSequence(1);
  354. }
  355. } // public class SceneAmazingArtGallery : SceneCommon
  356. } // namespace ReaderRabbit