SceneRaingearRescue.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. //================================================================================
  2. //
  3. //================================================================================
  4. using UnityEngine;
  5. using System.Collections;
  6. using SimpleJSON;
  7. using System.Collections.Generic;
  8. using System;
  9. //================================================================================
  10. //
  11. //================================================================================
  12. namespace ReaderRabbit
  13. {
  14. //================================================================================
  15. //
  16. //================================================================================
  17. public class RaingearDescription
  18. {
  19. //================================================================================
  20. //
  21. //================================================================================
  22. public RaingearDescription()
  23. {
  24. GearColor = GearColor.R_COLOR;
  25. GearShape = GearShape.R_SHAPE;
  26. GearType = GearType.R_OBJECT_GEAR;
  27. }
  28. //================================================================================
  29. //
  30. //================================================================================
  31. public GearColor GearColor
  32. {
  33. get;
  34. set;
  35. }
  36. //================================================================================
  37. //
  38. //================================================================================
  39. public GearShape GearShape
  40. {
  41. get;
  42. set;
  43. }
  44. //================================================================================
  45. //
  46. //================================================================================
  47. public GearType GearType
  48. {
  49. get;
  50. set;
  51. }
  52. } // public class RaingearDescription
  53. //================================================================================
  54. //
  55. //================================================================================
  56. public class SceneRaingearRescue : SceneCommon
  57. {
  58. //================================================================================
  59. //
  60. //================================================================================
  61. private enum Characters
  62. {
  63. Reader = CharactersCommon.Reader,
  64. Sam = CharactersCommon.Sam,
  65. Paige = CharactersCommon.Paige,
  66. }
  67. //================================================================================
  68. //
  69. //================================================================================
  70. private const int WORD_LISTS_SIZE = 15;
  71. private const int NUMBER_OF_MINIGAME_LEVELS = 3;
  72. private const int NUMBER_OF_WINS_TO_END_GAME = 6;
  73. private const int SETS_PER_LEVEL_NORMAL_MODE = 2;
  74. private const int MINIMUM_TO_WIN = 10;
  75. private const int WIN_EXCELLENT = 16;
  76. private const int WIN_GOOD = 14;
  77. private const int WIN_OK = 12;
  78. //================================================================================
  79. //
  80. //================================================================================
  81. [SerializeField] private RaingearRescueBarrelsManager m_BarrelsManager;
  82. [SerializeField] private RaingearRescueFlagsManager m_FlagsManager;
  83. [SerializeField] private RaingearRescueObjectsSpawner m_ObjectsSpawner;
  84. [SerializeField] private RaingearRescueObjectsCounter m_ObjectsCounter;
  85. private int m_CurrentWordList;
  86. private int m_CurrentMinigameLevel;
  87. private int m_NumberOfWins;
  88. private List<RaingearDescription> m_CurrentDescription;
  89. private bool m_SpeechPaigeHighlightBarrels;
  90. private bool m_HasSpeechAfterPaigeSetupLines;
  91. private int m_SpeechPaigeCurrentWordList;
  92. int lang;
  93. //================================================================================
  94. //
  95. //================================================================================
  96. protected override void Start()
  97. {
  98. base.Start();
  99. //============================================================================
  100. //
  101. //============================================================================
  102. lang = PlayerPrefs.GetInt("language");
  103. if (lang == 0) m_SpeechFolder = "Resources_DA/Audio/RaingearRescue_Speech";
  104. else if (lang == 1) m_SpeechFolder = "Resources_EN/Audio/RaingearRescue_Speech";
  105. else if (lang == 2) m_SpeechFolder = "Resources_NO/Audio/RaingearRescue_Speech";
  106. else if (lang == 3) m_SpeechFolder = "Resources_SP/Audio/RaingearRescue_Speech";
  107. else if (lang == 4) m_SpeechFolder = "Resources_SW/Audio/RaingearRescue_Speech";
  108. //============================================================================
  109. //
  110. //============================================================================
  111. PlayerData.Instance().SetVisitedRaingearRescue(true);
  112. PlayerData.Instance().SetCurrentLocation(Location.RaingearRescue);
  113. PlayerData.Instance().UnlockActivity(Activity.RaingearRescue);
  114. AudioManager.Instance().PlayBGM("BGM_RaingearRescue");
  115. m_CurrentWordList = 1;
  116. m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.RaingearRescue);
  117. m_NumberOfWins = -1;
  118. if (PlayerData.Instance().IsPracticeMode())
  119. {
  120. m_FlagsManager.gameObject.SetActive(false);
  121. }
  122. else
  123. {
  124. m_FlagsManager.gameObject.SetActive(true);
  125. }
  126. }
  127. //================================================================================
  128. //
  129. //================================================================================
  130. public void LoadNextWordSet()
  131. {
  132. TextAsset jsonText = null;
  133. if (lang == 0) jsonText = Resources.Load<TextAsset>("Resources_DA/RaingearRescue/r1la3");
  134. else if (lang == 1) jsonText = Resources.Load<TextAsset>("Resources_EN/RaingearRescue/r1la3");
  135. else if (lang == 2) jsonText = Resources.Load<TextAsset>("Resources_NO/RaingearRescue/r1la3");
  136. else if (lang == 3) jsonText = Resources.Load<TextAsset>("Resources_SP/RaingearRescue/r1la3");
  137. else if (lang == 4) jsonText = Resources.Load<TextAsset>("Resources_SW/RaingearRescue/r1la3");
  138. JSONNode json = JSONNode.Parse(jsonText.text);
  139. int wordListSize = WORD_LISTS_SIZE;
  140. if (PlayerData.Instance().IsPracticeMode())
  141. {
  142. if (m_CurrentWordList > wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearRescue))
  143. {
  144. m_CurrentMinigameLevel++;
  145. if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
  146. {
  147. m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
  148. }
  149. PlayerData.Instance().SetActivityLevel(Activity.RaingearRescue, m_CurrentMinigameLevel);
  150. m_CurrentWordList = 1;
  151. wordListSize = WORD_LISTS_SIZE;
  152. }
  153. else if (m_CurrentWordList > wordListSize && PlayerData.Instance().IsActivityLocked(Activity.RaingearRescue))
  154. {
  155. m_CurrentWordList = 1;
  156. }
  157. }
  158. else if (m_CurrentWordList > SETS_PER_LEVEL_NORMAL_MODE && !PlayerData.Instance().IsActivityLocked(Activity.RaingearRescue))
  159. {
  160. m_CurrentWordList = 1;
  161. m_CurrentMinigameLevel++;
  162. if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
  163. {
  164. m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
  165. }
  166. PlayerData.Instance().SetActivityLevel(Activity.RaingearRescue, m_CurrentMinigameLevel);
  167. }
  168. JSONNode currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel];
  169. m_SpeechPaigeCurrentWordList = m_CurrentWordList - 1;
  170. m_CurrentDescription = ParseProblemDescription(currentLevelWordLists["WordList_" + m_CurrentWordList++]);
  171. m_ObjectsCounter.Reset();
  172. m_ObjectsSpawner.Reset();
  173. m_ObjectsSpawner.Setup(m_CurrentDescription);
  174. ShowPartialBarrelsManager();
  175. }
  176. //================================================================================
  177. //
  178. //================================================================================
  179. protected override void PlayFirstEvent()
  180. {
  181. ShowCharacters();
  182. m_SpeechPaigeHighlightBarrels = true;
  183. m_HasSpeechAfterPaigeSetupLines = true;
  184. if (m_IsFirstTime)
  185. {
  186. NewSequence();
  187. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27200");
  188. SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27201");
  189. SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27202");
  190. SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27203");
  191. SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27300");
  192. SetSequence(5, EventSequenceItem.EventSequenceType.Callback, LoadNextWordSet);
  193. SetSequence(6, EventSequenceItem.EventSequenceType.Callback, PaigeSpeechSetupLines);
  194. StartSequence(7);
  195. }
  196. else
  197. {
  198. NewSequence();
  199. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27301");
  200. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, LoadNextWordSet);
  201. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, PaigeSpeechSetupLines);
  202. StartSequence(3);
  203. }
  204. }
  205. //================================================================================
  206. //
  207. //================================================================================
  208. private void PaigeSpeechSetupLines()
  209. {
  210. Invoke("PaigeSpeechSetupLinesDelayed", 0.1f);
  211. }
  212. //================================================================================
  213. //
  214. //================================================================================
  215. private void PaigeSpeechSetupLinesDelayed()
  216. {
  217. int sequence = 0;
  218. NewSequence();
  219. if (m_SpeechPaigeHighlightBarrels)
  220. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, HighlightBarrelLeft);
  221. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27305");
  222. // pSayContainerAttributes.
  223. string primaryWord = RaingearRescueWords.GetPrimaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.LEFT_BARREL);
  224. string secondaryWord = RaingearRescueWords.GetSecondaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.LEFT_BARREL);
  225. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, primaryWord);
  226. if (!secondaryWord.Equals("0"))
  227. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, secondaryWord);
  228. if (m_SpeechPaigeHighlightBarrels)
  229. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, HighlightBarrelCenter);
  230. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27306");
  231. // pSayContainerAttributes.
  232. primaryWord = RaingearRescueWords.GetPrimaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.CENTER_BARREL);
  233. secondaryWord = RaingearRescueWords.GetSecondaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.CENTER_BARREL);
  234. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, primaryWord);
  235. if (!secondaryWord.Equals("0"))
  236. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, secondaryWord);
  237. if (m_SpeechPaigeHighlightBarrels)
  238. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, HighlightBarrelRight);
  239. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27307");
  240. // pSayContainerAttributes.
  241. primaryWord = RaingearRescueWords.GetPrimaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.RIGHT_BARREL);
  242. secondaryWord = RaingearRescueWords.GetSecondaryWord(m_CurrentMinigameLevel, m_SpeechPaigeCurrentWordList, BarrelPosition.RIGHT_BARREL);
  243. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, primaryWord);
  244. if (!secondaryWord.Equals("0"))
  245. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, secondaryWord);
  246. if (m_HasSpeechAfterPaigeSetupLines)
  247. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SpeechAfterPaigeSetupLines);
  248. StartSequence(sequence);
  249. }
  250. //================================================================================
  251. //
  252. //================================================================================
  253. private void SpeechAfterPaigeSetupLines()
  254. {
  255. Invoke("SpeechAfterPaigeSetupLinesDelayed", 0.1f);
  256. }
  257. //================================================================================
  258. //
  259. //================================================================================
  260. private void SpeechAfterPaigeSetupLinesDelayed()
  261. {
  262. NewSequence();
  263. if (m_IsFirstTime)
  264. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27350");
  265. else
  266. SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27351");
  267. SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
  268. SetSequence(2, EventSequenceItem.EventSequenceType.Callback, StartSpawning);
  269. StartSequence(3);
  270. }
  271. //================================================================================
  272. //
  273. //================================================================================
  274. private void StartSpawning()
  275. {
  276. ShowBarrelsManager();
  277. m_ObjectsSpawner.StartSpawning();
  278. AudioManager.Instance().PlayBGM("BGM_RaingearRescue2");
  279. }
  280. //================================================================================
  281. //
  282. //================================================================================
  283. private void HighlightBarrelLeft()
  284. {
  285. m_BarrelsManager.SetActiveBarrel(BarrelPosition.LEFT_BARREL);
  286. }
  287. //================================================================================
  288. //
  289. //================================================================================
  290. private void HighlightBarrelCenter()
  291. {
  292. m_BarrelsManager.SetActiveBarrel(BarrelPosition.CENTER_BARREL);
  293. }
  294. //================================================================================
  295. //
  296. //================================================================================
  297. private void HighlightBarrelRight()
  298. {
  299. m_BarrelsManager.SetActiveBarrel(BarrelPosition.RIGHT_BARREL);
  300. }
  301. //================================================================================
  302. //
  303. //================================================================================
  304. private void ShowCharacters()
  305. {
  306. m_CharacterAnimations[(int)Characters.Reader].gameObject.SetActive(true);
  307. m_CharacterAnimations[(int)Characters.Sam].gameObject.SetActive(true);
  308. m_BarrelsManager.gameObject.SetActive(false);
  309. }
  310. //================================================================================
  311. //
  312. //================================================================================
  313. private void ShowPartialBarrelsManager()
  314. {
  315. m_BarrelsManager.gameObject.SetActive(true);
  316. m_BarrelsManager.ShowLabels();
  317. }
  318. //================================================================================
  319. //
  320. //================================================================================
  321. private void ShowBarrelsManager()
  322. {
  323. m_CharacterAnimations[(int)Characters.Reader].gameObject.SetActive(false);
  324. m_CharacterAnimations[(int)Characters.Sam].gameObject.SetActive(false);
  325. m_BarrelsManager.Center();
  326. m_BarrelsManager.gameObject.SetActive(true);
  327. m_BarrelsManager.ShowAll();
  328. }
  329. //================================================================================
  330. //
  331. //================================================================================
  332. public void RoundFinished()
  333. {
  334. ShowCharacters();
  335. AudioManager.Instance().PlayBGM("BGM_RaingearRescue");
  336. int sequence = 0;
  337. NewSequence();
  338. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27400");
  339. if (m_ObjectsCounter.GetCurrentValue() < MINIMUM_TO_WIN)
  340. {
  341. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27410");
  342. int randomValue = UnityEngine.Random.Range(0, 200);
  343. if (randomValue < 50)
  344. {
  345. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27415");
  346. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27416");
  347. }
  348. else if (randomValue < 100)
  349. {
  350. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27417");
  351. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27418");
  352. }
  353. else if (randomValue < 150)
  354. {
  355. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27419");
  356. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27420");
  357. }
  358. else
  359. {
  360. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27421");
  361. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27422");
  362. }
  363. }
  364. else
  365. {
  366. ++m_NumberOfWins;
  367. m_FlagsManager.ActivateFlags(m_NumberOfWins);
  368. if (m_NumberOfWins < NUMBER_OF_WINS_TO_END_GAME)
  369. {
  370. if (m_ObjectsCounter.GetCurrentValue() < WIN_OK)
  371. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27432");
  372. else if (m_ObjectsCounter.GetCurrentValue() < WIN_GOOD)
  373. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27431");
  374. else if (m_ObjectsCounter.GetCurrentValue() < WIN_EXCELLENT)
  375. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27430");
  376. int randomValue = UnityEngine.Random.Range(0, 150);
  377. if (randomValue < 50)
  378. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27450");
  379. else if (randomValue < 100)
  380. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27451");
  381. else
  382. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27452");
  383. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27470");
  384. }
  385. else
  386. {
  387. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27480");
  388. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "27481");
  389. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "27482");
  390. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.EndGame);
  391. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, EndGame);
  392. }
  393. }
  394. if (m_NumberOfWins < NUMBER_OF_WINS_TO_END_GAME)
  395. {
  396. // Similar to PlayFirstEvent.
  397. m_SpeechPaigeHighlightBarrels = true;
  398. m_HasSpeechAfterPaigeSetupLines = true;
  399. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "27301");
  400. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, LoadNextWordSet);
  401. SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, PaigeSpeechSetupLines);
  402. }
  403. StartSequence(sequence);
  404. }
  405. //================================================================================
  406. //
  407. //================================================================================
  408. private void EndGame()
  409. {
  410. // TODO: Goto Credits screen with "Play again" button enabled. Also play "Congratulations" Reader speech.
  411. this.gameObject.SetActive(false);
  412. // HACK: Clear previous BGM (call twice).
  413. AudioManager.Instance().RestorePreviousBGM();
  414. AudioManager.Instance().RestorePreviousBGM();
  415. Options.Instance().Open(this);
  416. Options.Instance().ShowCredits(false);
  417. }
  418. //================================================================================
  419. //
  420. //================================================================================
  421. private List<RaingearDescription> ParseProblemDescription(JSONNode description)
  422. {
  423. List<RaingearDescription> result = new List<RaingearDescription>();
  424. string[] separators = { " " };
  425. string[] tokens = description.Value.Split(separators, StringSplitOptions.RemoveEmptyEntries);
  426. List<String> tokensList = new List<String>(tokens);
  427. List<RaingearDescription> barrelsSetupAuxList = new List<RaingearDescription>();
  428. while (tokensList.Count > 0)
  429. {
  430. RaingearDescription gearDescription = new RaingearDescription();
  431. int numberOfElements = int.Parse(tokensList[0]);
  432. tokensList.RemoveAt(0);
  433. while (tokensList.Count > 0 && !IsNumber(tokensList[0]))
  434. {
  435. if (IsGearColor(tokensList[0]))
  436. {
  437. gearDescription.GearColor = GetGearColorPerColorName(tokensList[0]);
  438. }
  439. else if (IsGearShape(tokensList[0]))
  440. {
  441. gearDescription.GearShape = GetGearShapePerShapeName(tokensList[0]);
  442. }
  443. else if (IsGearType(tokensList[0]))
  444. {
  445. gearDescription.GearType = GetGearTypePerTypeName(tokensList[0]);
  446. }
  447. tokensList.RemoveAt(0);
  448. }
  449. for (int i = 0; i < numberOfElements; ++i)
  450. {
  451. result.Add(gearDescription);
  452. }
  453. if (barrelsSetupAuxList.Count < 3)
  454. {
  455. barrelsSetupAuxList.Add(gearDescription);
  456. }
  457. }
  458. m_BarrelsManager.Setup(barrelsSetupAuxList);
  459. return result;
  460. }
  461. //================================================================================
  462. //
  463. //================================================================================
  464. private GearColor GetGearColorPerColorName(string color)
  465. {
  466. if (color == "red")
  467. {
  468. return GearColor.RED_GEAR;
  469. }
  470. else if (color == "yellow")
  471. {
  472. return GearColor.YELLOW_GEAR;
  473. }
  474. else if (color == "blue")
  475. {
  476. return GearColor.BLUE_GEAR;
  477. }
  478. else if (color == "green")
  479. {
  480. return GearColor.GREEN_GEAR;
  481. }
  482. else if (color == "rcolor")
  483. {
  484. return GearColor.R_COLOR;
  485. }
  486. else
  487. {
  488. return GearColor.INVALID_GEAR_COLOR;
  489. }
  490. }
  491. //================================================================================
  492. //
  493. //================================================================================
  494. private GearShape GetGearShapePerShapeName(string shape)
  495. {
  496. if (shape == "trapezoid")
  497. {
  498. return GearShape.TRAPEZOID_SHAPE;
  499. }
  500. else if (shape == "triangle")
  501. {
  502. return GearShape.TRIANGLE_SHAPE;
  503. }
  504. else if (shape == "square")
  505. {
  506. return GearShape.SQUARE_SHAPE;
  507. }
  508. else if (shape == "circle")
  509. {
  510. return GearShape.CIRCLE_SHAPE;
  511. }
  512. else if (shape == "rshape")
  513. {
  514. return GearShape.R_SHAPE;
  515. }
  516. else
  517. {
  518. return GearShape.INVALID_GEAR_SHAPE;
  519. }
  520. }
  521. //================================================================================
  522. //
  523. //================================================================================
  524. private GearType GetGearTypePerTypeName(string type)
  525. {
  526. if (type == "coat")
  527. {
  528. return GearType.COAT_GEAR;
  529. }
  530. else if (type == "boot")
  531. {
  532. return GearType.BOOT_GEAR;
  533. }
  534. else if (type == "umbrella")
  535. {
  536. return GearType.UMBRELLA_GEAR;
  537. }
  538. else if (type == "hat")
  539. {
  540. return GearType.HAT_GEAR;
  541. }
  542. else if (type == "robject")
  543. {
  544. return GearType.R_OBJECT_GEAR;
  545. }
  546. else
  547. {
  548. return GearType.INVALID_GEAR_TYPE;
  549. }
  550. }
  551. //================================================================================
  552. //
  553. //================================================================================
  554. private bool IsNumber(string s)
  555. {
  556. bool result = false;
  557. for (int i = 0; i < 10; ++i)
  558. {
  559. result |= (s == i.ToString());
  560. }
  561. return result;
  562. }
  563. //================================================================================
  564. //
  565. //================================================================================
  566. private bool IsGearColor(string color)
  567. {
  568. return (color == "red" || color == "yellow" || color == "blue" || color == "green" || color == "rcolor");
  569. }
  570. //================================================================================
  571. //
  572. //================================================================================
  573. private bool IsGearShape(string shape)
  574. {
  575. return (shape == "trapezoid" || shape == "triangle" || shape == "square" || shape == "circle" || shape == "rshape");
  576. }
  577. //================================================================================
  578. //
  579. //================================================================================
  580. private bool IsGearType(string shape)
  581. {
  582. return (shape == "coat" || shape == "boot" || shape == "hat" || shape == "umbrella" || shape == "robject");
  583. }
  584. //================================================================================
  585. //
  586. //================================================================================
  587. public RaingearRescueObjectsCounter ObjectsCounter
  588. {
  589. get { return m_ObjectsCounter; }
  590. }
  591. //================================================================================
  592. //
  593. //================================================================================
  594. public RaingearRescueBarrelsManager BarrelsManager
  595. {
  596. get { return m_BarrelsManager; }
  597. }
  598. } // public class SceneRaingearRescue : SceneCommon
  599. } // namespace ReaderRabbit