MiniGameManager.cs 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Serialization;
  4. using System;
  5. using System.Xml;
  6. using System.Text;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using Random = UnityEngine.Random;
  10. public class MinigameAward
  11. {
  12. #region Config
  13. public static int DropCoin;
  14. public static int DropDiamond;
  15. public static string DisplayContent;
  16. public int Rate; //小游戏评级
  17. public int Score;
  18. public float MinScore = 1;
  19. public float MaxScore = Mathf.Infinity;
  20. public int CoinAward;
  21. public int DiamondAward;
  22. public bool HaveDiamondFlag;
  23. public static int UnlockFlowerID;
  24. public static bool UnlockFlowerFlag;
  25. public static bool HaveNewFlowerFlag;
  26. #region 配置
  27. public int MinDiamondAward;
  28. public int MaxDiamondAward;
  29. public string CoinAwardFml;
  30. public string UnlockFlowerFml;
  31. public string DiamondAwardFml;
  32. public static string FlowerIDRateFml; //根据花的ID计算获得的概率
  33. public static string FlowerAmtRateFml; //根据花的数量计算获得的概率
  34. public List<float> RateStandard = new List<float>();
  35. public List<float> UnlockFlowerRate = new List<float>();
  36. #endregion
  37. #endregion
  38. public void GetAward(int score)
  39. {
  40. #region 获得奖励
  41. #region Rate
  42. Score = (int)Mathf.Clamp(score, MinScore, MaxScore);
  43. if (Score < RateStandard[1])
  44. {
  45. Rate = 0;
  46. }
  47. else if (Score < RateStandard[2])
  48. {
  49. Rate = 1;
  50. }
  51. else
  52. {
  53. Rate = 2;
  54. }
  55. #endregion
  56. #region Reset
  57. UnlockFlowerFlag = false;
  58. HaveDiamondFlag = false;
  59. #endregion
  60. StringBuilder sb = new StringBuilder();
  61. #region Coin
  62. CoinAward = (int)Auxiliary.FmlParse(CoinAwardFml, "s", Score.ToString(), "l", Mathf.Clamp(Manager.GardenLevel, 1, 9999).ToString());
  63. CoinAward = (int)(CoinAward * (1 + Manager.SkillPlus) + DropCoin);
  64. CoinAward = (int) Mathf.Clamp(CoinAward, 1, Mathf.Infinity);
  65. ResourceManager.Get<Text>(ObjectLabel.Da_CoinLab).text = CoinAward.ToString();
  66. ResourceManager.Get<Text>(ObjectLabel.Da_CoinLab).Resize(true, false);
  67. ResourceManager.Get<ContentSizeFitter>(ObjectLabel.Da_CoinGroup).enabled = true;
  68. ResourceManager.SetActive(ObjectLabel.Da_CoinLab, true);
  69. Manager.AddCoin(CoinAward, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.MiniGame);
  70. sb.AppendFormat("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.CoinSprite, CoinAward);
  71. #endregion
  72. #region Diamond
  73. float diamondRate = (float)Auxiliary.FmlParse(DiamondAwardFml, "l", Mathf.Clamp(Manager.GardenLevel, 1, 1000).ToString());
  74. if (Random.Range(0, 1f) <= diamondRate)
  75. {
  76. HaveDiamondFlag = true;
  77. DiamondAward = (int)(Mathf.Lerp(MinDiamondAward, MaxDiamondAward, Random.Range(0, 1f)) + DropDiamond);
  78. ResourceManager.Get<Text>(ObjectLabel.Da_DiamondLab).text = DiamondAward.ToString();
  79. ResourceManager.Get<Text>(ObjectLabel.Da_DiamondLab).Resize(true, false);
  80. ResourceManager.Get<ContentSizeFitter>(ObjectLabel.Da_DiamondGroup).enabled = true;
  81. ResourceManager.SetActive(ObjectLabel.Da_DiamondLab, true);
  82. Manager.AddDiamond(DiamondAward, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.MiniGame);
  83. ResourceManager.SetActive(ObjectLabel.Da_Diamond, true);
  84. sb.AppendFormat("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.DiamondSprite, DiamondAward);
  85. }
  86. else
  87. {
  88. if (DropDiamond > 0)
  89. {
  90. HaveDiamondFlag = true;
  91. DiamondAward = DropDiamond;
  92. ResourceManager.Get<Text>(ObjectLabel.Da_DiamondLab).text = DiamondAward.ToString();
  93. ResourceManager.Get<Text>(ObjectLabel.Da_DiamondLab).Resize(true, false);
  94. ResourceManager.Get<ContentSizeFitter>(ObjectLabel.Da_DiamondGroup).enabled = true;
  95. ResourceManager.SetActive(ObjectLabel.Da_DiamondLab, true);
  96. Manager.AddDiamond(DiamondAward, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.MiniGame);
  97. ResourceManager.SetActive(ObjectLabel.Da_Diamond, true);
  98. sb.AppendFormat("{0}{1}{2} ", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.DiamondSprite, DiamondAward);
  99. }
  100. else
  101. {
  102. DiamondAward = 0;
  103. }
  104. }
  105. #endregion
  106. #region Flower
  107. if (TutorialManager.NewplayerTutorial)
  108. {
  109. UnlockFlowerFlag = true;
  110. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[1];
  111. ResourceManager.SetActive(ObjectLabel.Da_FlowerIcon, true);
  112. ResourceManager.Get<Image>(ObjectLabel.Da_FlowerIcon).sprite = flowerInfo.Icon;
  113. ResourceManager.Get<Image>(ObjectLabel.Da_FlowerIcon).Resize(true, 0.25f, 0.25f);
  114. ResourceManager.SetText(ObjectLabel.Da_FlowerLab, flowerInfo.Name);
  115. sb.AppendFormat("{0}{1}{2}", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.FlowerSprite, flowerInfo.Name);
  116. }
  117. else
  118. {
  119. if (!HaveNewFlowerFlag)
  120. {
  121. UnlockFlowerFlag = true;
  122. if (Random.Range(0, 1f) <= UnlockFlowerRate[Rate])
  123. {
  124. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[UnlockFlowerID];
  125. flowerInfo.Add();
  126. ResourceManager.SetActive(ObjectLabel.Da_Flower, true);
  127. ResourceManager.Get<Image>(ObjectLabel.Da_FlowerIcon).sprite = flowerInfo.Icon;
  128. ResourceManager.Get<Image>(ObjectLabel.Da_FlowerIcon).Resize(true, 0.25f, 0.25f);
  129. ResourceManager.SetText(ObjectLabel.Da_FlowerLab, flowerInfo.Name);
  130. sb.AppendFormat("{0}{1}{2}", Language.GetStr(LanguageLabel.UI__J_Info0), TransferLabel.FlowerSprite, flowerInfo.Name);
  131. }
  132. else
  133. {
  134. ResourceManager.SetActive(ObjectLabel.Da_Flower, false);
  135. ResourceManager.SetText(ObjectLabel.Da_FlowerLab, Language.GetStr(LanguageLabel.UI__Da_HigherScore));
  136. }
  137. }
  138. }
  139. #endregion
  140. DisplayContent = sb.ToString();
  141. DropCoin = 0;
  142. DropDiamond = 0;
  143. #endregion
  144. ResourceManager.SetActive(ObjectLabel.Da_Info, true);
  145. Auxiliary.Instance.DelayCall
  146. (
  147. () =>
  148. {
  149. ResourceManager.Get<Text>(ObjectLabel.Da_CoinLab).SetLayoutDirty();
  150. ResourceManager.Get<Text>(ObjectLabel.Da_DiamondLab).SetLayoutDirty();
  151. ResourceManager.Get<ContentSizeFitter>(ObjectLabel.Da_CoinGroup).enabled = false;
  152. ResourceManager.Get<ContentSizeFitter>(ObjectLabel.Da_DiamondGroup).enabled = false;
  153. SetupAnimation();
  154. },
  155. 2
  156. );
  157. }
  158. public static int SelectUnlockFlowerID(List<int> flowerIDs)
  159. {
  160. for (int i = 0; i < flowerIDs.Count; i++)
  161. {
  162. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[flowerIDs[i]];
  163. float flowerIDRate = (float)Auxiliary.FmlParse(FlowerIDRateFml, "i", flowerIDs[i].ToString());
  164. if (Random.Range(0f, 1f) <= flowerIDRate)
  165. {
  166. float flowerAmtRate = (float)Auxiliary.FmlParse(FlowerAmtRateFml, "a", flowerInfo.amount.ToString());
  167. if (Random.Range(0f, 1f) <= flowerAmtRate)
  168. {
  169. return flowerIDs[i];
  170. }
  171. }
  172. }
  173. return flowerIDs.Random(1)[0];
  174. }
  175. public void SetupAnimation()
  176. {
  177. #region 构造动画
  178. #region Reset
  179. ResourceManager.Get(ObjectLabel.Da_Info).TweenForCG();
  180. ResourceManager.SetText(ObjectLabel.Da_Tit, Language.GetStr(LanguageLabel.UI__Da_Tit1));
  181. ResourceManager.SetText(ObjectLabel.Da_CoinLab, "0");
  182. ResourceManager.SetText(ObjectLabel.Da_DiamondLab, "0");
  183. ResourceManager.SetActive(ObjectLabel.Da_Lab, false);
  184. ResourceManager.SetActive(ObjectLabel.Da_Quit, false);
  185. ResourceManager.SetActive(ObjectLabel.Da_Cancel, false);
  186. ResourceManager.SetActive(ObjectLabel.Da_CoinLab, false);
  187. ResourceManager.SetActive(ObjectLabel.Da_ScoreTit, false);
  188. ResourceManager.SetActive(ObjectLabel.Da_ScoreLab, false);
  189. ResourceManager.SetActive(ObjectLabel.Da_GetAward, false);
  190. ResourceManager.SetActive(ObjectLabel.Da_DiamondLab, false);
  191. ResourceManager.SetActive(ObjectLabel.Da_VGroup, true);
  192. ResourceManager.SetActive(ObjectLabel.Da_HGroup1, false);
  193. ResourceManager.SetActive(ObjectLabel.Da_FlowerGroup, false);
  194. ResourceManager.SetActive(ObjectLabel.Da_DiamondGroup, false);
  195. if (UnlockFlowerFlag)
  196. {
  197. ResourceManager.SetActive(ObjectLabel.Da_FlowerGroup, true);
  198. }
  199. if (HaveDiamondFlag)
  200. {
  201. ResourceManager.SetActive(ObjectLabel.Da_DiamondGroup, true);
  202. }
  203. Auxiliary.Instance.DelayCall
  204. (
  205. () =>
  206. {
  207. ResourceManager.Get<VerticalLayoutGroup>(ObjectLabel.Da_VGroup).enabled = false;
  208. ResourceManager.SetActive(ObjectLabel.Da_CoinGroup, false);
  209. ResourceManager.SetActive(ObjectLabel.Da_FlowerGroup, false);
  210. ResourceManager.SetActive(ObjectLabel.Da_DiamondGroup, false);
  211. },
  212. 1
  213. );
  214. float timeCoin = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(CoinAward / 15f));
  215. float timeScore = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(Score / 50f));
  216. float timeDiamond = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(DiamondAward / 15f));
  217. float time = Mathf.Max(timeCoin, timeDiamond);
  218. ResourceManager.Get(ObjectLabel.Da_CoinLab).CreateTweenNumber(0, CoinAward, time, false, true, Curve.EaseOutQuad);
  219. ResourceManager.Get(ObjectLabel.Da_ScoreLab).CreateTweenNumber(0, Score, timeScore, false, true, Curve.EaseOutQuad);
  220. ResourceManager.Get(ObjectLabel.Da_DiamondLab).CreateTweenNumber(0, DiamondAward, time, false, true, Curve.EaseOutQuad);
  221. #endregion
  222. #region 花
  223. TweenRoot tween;
  224. if (UnlockFlowerFlag)
  225. {
  226. tween = ResourceManager.Get(ObjectLabel.Da_CoinLab).GetTweenNumber();
  227. tween.AddEventOnetime
  228. (
  229. EventType.ForwardFinish,
  230. () =>
  231. {
  232. ResourceManager.Get(ObjectLabel.Da_FlowerGroup).TweenReForScale();
  233. }
  234. );
  235. }
  236. #endregion
  237. #region 按钮
  238. if (UnlockFlowerFlag)
  239. {
  240. tween = ResourceManager.Get(ObjectLabel.Da_FlowerGroup).GetTweenScale();
  241. tween.AddEventOnetime
  242. (
  243. EventType.ForwardFinish,
  244. () =>
  245. {
  246. ResourceManager.Get(ObjectLabel.Da_GetAward).TweenReForCG();
  247. }
  248. );
  249. }
  250. else
  251. {
  252. tween = ResourceManager.Get(ObjectLabel.Da_CoinLab).GetTweenNumber();
  253. tween.AddEventOnetime
  254. (
  255. EventType.ForwardFinish,
  256. () =>
  257. {
  258. ResourceManager.Get(ObjectLabel.Da_GetAward).TweenReForCG();
  259. }
  260. );
  261. }
  262. if (TutorialManager.NewplayerTutorial)
  263. {
  264. tween = ResourceManager.Get(ObjectLabel.Da_GetAward).GetTweenCG();
  265. tween.AddEventOnetime
  266. (
  267. EventType.ForwardFinish,
  268. () =>
  269. {
  270. Tutorial.HightScreen(ResourceManager.Get(ObjectLabel.Da_Arrow0), ResourceManager.Get(ObjectLabel.Da_Arrow1), ResourceManager.Get(ObjectLabel.Da_GetAward));
  271. }
  272. );
  273. }
  274. ResourceManager.AddButtonEventOnetime
  275. (
  276. ObjectLabel.Da_GetAward,
  277. () =>
  278. {
  279. ResourceManager.Get(ObjectLabel.Da_VGroup).GetComponent<VerticalLayoutGroup>().enabled = true;
  280. }
  281. );
  282. #endregion
  283. #region 得分
  284. if (Rate == 0)
  285. {
  286. tween = ResourceManager.Get(ObjectLabel.Da_Star1).GetTweenScale();
  287. }
  288. else if (Rate == 1)
  289. {
  290. tween = ResourceManager.Get(ObjectLabel.Da_Star2).GetTweenScale();
  291. }
  292. else if (Rate == 2)
  293. {
  294. tween = ResourceManager.Get(ObjectLabel.Da_Star3).GetTweenScale();
  295. }
  296. tween.AddEventOnetime
  297. (
  298. EventType.ForwardFinish,
  299. () =>
  300. {
  301. ResourceManager.Get(ObjectLabel.Da_ScoreTit).TweenReForFont();
  302. }
  303. );
  304. tween = ResourceManager.Get(ObjectLabel.Da_ScoreTit).GetTweenFont();
  305. tween.InOrigin = true;
  306. tween.AddEventOnetime
  307. (
  308. EventType.ForwardFinish,
  309. () =>
  310. {
  311. ResourceManager.Get(ObjectLabel.Da_ScoreLab).TweenReForNumber();
  312. }
  313. );
  314. #endregion
  315. #region 五角星
  316. tween = ResourceManager.Get(ObjectLabel.Da_Star3).GetTweenScale();
  317. tween.InOrigin = true;
  318. tween = ResourceManager.Get(ObjectLabel.Da_Star2).GetTweenScale();
  319. tween.InOrigin = true;
  320. tween = ResourceManager.Get(ObjectLabel.Da_Star1).GetTweenScale();
  321. tween.InOrigin = true;
  322. tween = ResourceManager.Get(ObjectLabel.Da_Info).GetTweenCG();
  323. tween.AddEventOnetime
  324. (
  325. EventType.ForwardFinish,
  326. () =>
  327. {
  328. ResourceManager.Get(ObjectLabel.Da_Star1).TweenReForScale();
  329. ResourceManager.SetActive(ObjectLabel.Da_HGroup1, true);
  330. }
  331. );
  332. if (Rate == 0)
  333. {
  334. ResourceManager.SetActive(ObjectLabel.Da_Star2, false);
  335. ResourceManager.SetActive(ObjectLabel.Da_Star3, false);
  336. }
  337. else if (Rate == 1)
  338. {
  339. ResourceManager.SetActive(ObjectLabel.Da_Star2, true);
  340. ResourceManager.SetActive(ObjectLabel.Da_Star3, false);
  341. tween = ResourceManager.Get(ObjectLabel.Da_Star1).GetTweenScale();
  342. tween.AddEventOnetime
  343. (
  344. EventType.ForwardFinish,
  345. () =>
  346. {
  347. ResourceManager.Get(ObjectLabel.Da_Star2).TweenReForScale();
  348. }
  349. );
  350. }
  351. else if (Rate == 2)
  352. {
  353. ResourceManager.SetActive(ObjectLabel.Da_Star2, true);
  354. ResourceManager.SetActive(ObjectLabel.Da_Star3, true);
  355. tween = ResourceManager.Get(ObjectLabel.Da_Star1).GetTweenScale();
  356. tween.AddEventOnetime
  357. (
  358. EventType.ForwardFinish,
  359. () =>
  360. {
  361. ResourceManager.Get(ObjectLabel.Da_Star2).TweenReForScale();
  362. }
  363. );
  364. tween = ResourceManager.Get(ObjectLabel.Da_Star2).GetTweenScale();
  365. tween.AddEventOnetime
  366. (
  367. EventType.ForwardFinish,
  368. () =>
  369. {
  370. ResourceManager.Get(ObjectLabel.Da_Star3).TweenReForScale();
  371. }
  372. );
  373. }
  374. #endregion
  375. #region 金币钻石
  376. tween = ResourceManager.Get(ObjectLabel.Da_ScoreLab).GetTweenNumber();
  377. tween.AddEventOnetime
  378. (
  379. EventType.ForwardFinish,
  380. () =>
  381. {
  382. ResourceManager.Get(ObjectLabel.Da_CoinGroup).TweenReForScale();
  383. if (HaveDiamondFlag)
  384. {
  385. ResourceManager.Get(ObjectLabel.Da_DiamondGroup).TweenReForScale();
  386. }
  387. }
  388. );
  389. tween = ResourceManager.Get(ObjectLabel.Da_CoinGroup).GetTweenScale();
  390. tween.AddEventOnetime
  391. (
  392. EventType.ForwardFinish,
  393. () =>
  394. {
  395. ResourceManager.Get(ObjectLabel.Da_CoinLab).TweenReForNumber();
  396. }
  397. );
  398. if (HaveDiamondFlag)
  399. {
  400. tween = ResourceManager.Get(ObjectLabel.Da_DiamondGroup).GetTweenScale();
  401. tween.AddEventOnetime
  402. (
  403. EventType.ForwardFinish,
  404. () =>
  405. {
  406. ResourceManager.Get(ObjectLabel.Da_DiamondLab).TweenReForNumber();
  407. }
  408. );
  409. }
  410. #endregion
  411. #endregion
  412. }
  413. public MinigameAward(XmlAttributeCollection attribute)
  414. {
  415. Flower.AwardCoinFml = attribute[8].Value;
  416. DropGold.CoinFml = attribute[7].Value;
  417. Star.MinigameCD = float.Parse(attribute[9].Value);
  418. Star.Time = float.Parse(attribute[11].Value);
  419. string[] strings = attribute[10].Value.Split(',');
  420. GardenManager.MinCreateStarTime = float.Parse(strings[0]);
  421. GardenManager.MaxCreateStarTime = float.Parse(strings[1]);
  422. GardenManager.CreateStarTimer = Mathf.Lerp(GardenManager.MinCreateStarTime, GardenManager.MaxCreateStarTime, Random.Range(0f, 1f));
  423. CoinAwardFml = attribute[1].Value;
  424. UnlockFlowerFml = attribute[4].Value;
  425. DiamondAwardFml = attribute[3].Value;
  426. FlowerIDRateFml = attribute[12].Value;
  427. FlowerAmtRateFml = attribute[13].Value;
  428. strings = attribute[2].Value.Split(',');
  429. MinDiamondAward = int.Parse(strings[0]);
  430. MaxDiamondAward = int.Parse(strings[1]);
  431. strings = attribute[5].Value.Split(',');
  432. UnlockFlowerRate = new List<float>()
  433. {
  434. float.Parse(strings[0]),
  435. float.Parse(strings[1]),
  436. float.Parse(strings[2]),
  437. };
  438. strings = attribute[6].Value.Split(',');
  439. RateStandard = new List<float>()
  440. {
  441. float.Parse(strings[0]),
  442. float.Parse(strings[1]),
  443. float.Parse(strings[2]),
  444. };
  445. }
  446. }
  447. public enum MiniGameType
  448. {
  449. Punch, //打地鼠
  450. Memory, //记住花的消失顺序
  451. Find, //找落单的花
  452. }
  453. public class MiniGameManager : Regist
  454. {
  455. #region Config
  456. public static int Score
  457. {
  458. get { return score; }
  459. set
  460. {
  461. score = value;
  462. ResourceManager.SetText(ObjectLabel.D_ScoreLab, ScoreTextPrefix + score);
  463. }
  464. }
  465. private static int score;
  466. public static string ScoreTextPrefix;
  467. public static bool Game
  468. {
  469. get { return game; }
  470. set
  471. {
  472. game = value;
  473. if (game)
  474. {
  475. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab1));
  476. }
  477. else
  478. {
  479. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab0));
  480. }
  481. }
  482. }
  483. private static bool game;
  484. public static bool Pause
  485. {
  486. get { return pause; }
  487. set
  488. {
  489. pause = value;
  490. if (Game)
  491. {
  492. if (pause)
  493. {
  494. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab2));
  495. }
  496. else
  497. {
  498. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab1));
  499. }
  500. }
  501. else if (IsPrepare)
  502. {
  503. if (pause)
  504. {
  505. PrepareText.GetStreamScale().Pause();
  506. }
  507. else
  508. {
  509. PrepareText.GetStreamScale().Resume();
  510. }
  511. }
  512. }
  513. }
  514. private static bool pause;
  515. public static bool Panalty
  516. {
  517. get { return panalty; }
  518. set
  519. {
  520. panalty = value;
  521. if (Game)
  522. {
  523. if (panalty)
  524. {
  525. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab3));
  526. }
  527. else
  528. {
  529. ResourceManager.SetText(ObjectLabel.D_StatusLab, Language.GetStr(LanguageLabel.UI__D_StatusLab1));
  530. }
  531. }
  532. }
  533. }
  534. private static bool panalty;
  535. public static float GameTimer
  536. {
  537. get { return gameTimer; }
  538. set
  539. {
  540. gameTimer = value;
  541. MinigameTimerText.text = (GameTime-gameTimer).ToString("0.0");
  542. MinigameTimerBk.fillAmount = gameTimer/GameTime;
  543. MinigameTimerBk.material.SetFloat(MaterialLabel.TimerMatFill, MinigameTimerBk.fillAmount);
  544. }
  545. }
  546. private static float gameTimer;
  547. public static Text PrepareText;
  548. public static Text MinigameTimerText;
  549. public static Image MinigameTimerBk;
  550. public static Transform DisplayGrid;
  551. public static Transform MinigameTimerParent;
  552. public static Transform MinigameBeginButtonParent;
  553. public static Transform PunchGameStatusParent;
  554. public static Transform MemoryGameStatusParent;
  555. public static Transform FindGameStatusParent;
  556. public static Transform PunchGameOperateParent;
  557. public static Transform MemoryGameOperateParent;
  558. public static Transform FindGameOperateParent;
  559. public static Transform FindGameCorrectButtonParent;
  560. public static List<Drop> DropAwardList = new List<Drop>();
  561. public static List<Flower> MinigameIdleFlowerList = new List<Flower>();
  562. public static Dictionary<int, Flower> MinigameFlowerDictionary = new Dictionary<int, Flower>();
  563. public static int PunchCorrectScore = 15;
  564. public static int PunchGameSlotAmt = 9;
  565. public static List<int> PunchGameSlotIDs = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
  566. public static List<Flower> PunchGameOperateList = new List<Flower>();
  567. public static int MaxFadeAmt = 6;
  568. public static int FindCorrectScore = 40;
  569. public static List<int> FindGameSlotIDs = new List<int> {0, 1, 2, 3, 4, 5, 6, 7, 8};
  570. public static List<int> FindGameIndexList = new List<int>();
  571. public static List<int> FindGameFlowerIDs = new List<int>();
  572. public static int MemoryCorrectScore = 20;
  573. public static float MemoryGameDecreaseRate = 0.3f;
  574. public static List<int> MemoryGameSlotIDs = new List<int> { 0, 1, 3, 4, 6, 7 };
  575. public static List<Flower> MemoryGameFadeList = new List<Flower>();
  576. public static int MiniGameIndex; //从上一次掉落钻石开始计起 进行了几次小游戏
  577. public static bool IsPrepare;
  578. public static bool PlayNewflowerEffectFlag;
  579. public static float CreateOperateTime = 1.5f;
  580. public static float CreateOperateTimer;
  581. public static float OperateDecreaseRate = 0.03f;
  582. public static float CurrentCreateOperateTime;
  583. public static bool PunchGameTutorialFlag = true;
  584. public static int DropGoldMinIndex = 3;
  585. public static int DropGoldMaxIndex = 6;
  586. public static int DropDiamondMinIndex = 5;
  587. public static int DropDiamondMaxIndex = 9;
  588. public static float DropDiamondRate = 0.01f;
  589. public static float DropDiamondOffsetTime = 5;
  590. public static float DropGoldTimer;
  591. public static float DropDiamondTimer;
  592. public static bool CreateDropDiamondFlag;
  593. public static float FlowerFadeTime = 2f;
  594. public static float FlowerFadeTimer;
  595. public static float CurrentFlowerFadeTime;
  596. public static float PanaltyTime = 1f;
  597. public static float PanaltyTimer;
  598. public static float PrepareTime = 3;
  599. public static float PrepareTimer;
  600. public static float GameTime = 45f;
  601. public static float MinMinigameCD = 180;
  602. public static float MaxMinigameCD = 300;
  603. public static MiniGameType miniGameType;
  604. public static List<Transform> D_MemoryGameBtns = new List<Transform>();
  605. public static List<Transform> D_MemoryGameIcons = new List<Transform>();
  606. public static List<Transform> D_MemoryGameTicks = new List<Transform>();
  607. public static List<Transform> D_MemoryGameArrows = new List<Transform>();
  608. public static List<Transform> D_FindGameBtns = new List<Transform>();
  609. public static List<Transform> D_FindGameIcons = new List<Transform>();
  610. public static List<Transform> D_FindGameArrows = new List<Transform>();
  611. public static List<Transform> MinigameSlots = new List<Transform>();
  612. public static MinigameAward MinigameAward;
  613. #endregion
  614. private void Update()
  615. {
  616. if (Pause)
  617. {
  618. return;
  619. }
  620. if (Game)
  621. {
  622. PunchGameThread();
  623. MemoryGameThread();
  624. FindGameThread();
  625. }
  626. if (IsPrepare)
  627. {
  628. PrepareThread();
  629. }
  630. }
  631. private void PunchGameThread()
  632. {
  633. if (miniGameType != MiniGameType.Punch)
  634. {
  635. return;
  636. }
  637. GameTimer += Time.deltaTime;
  638. if (GameTimer >= GameTime)
  639. {
  640. GameOver();
  641. return;
  642. }
  643. if (Panalty)
  644. {
  645. PanaltyTimer -= Time.deltaTime;
  646. if (PanaltyTimer <= 0)
  647. {
  648. Panalty = false;
  649. }
  650. }
  651. if (MinigameIdleFlowerList.Count > 0)
  652. {
  653. CreateOperateTimer -= Time.deltaTime;
  654. if (CreateOperateTimer <= 0)
  655. {
  656. CurrentCreateOperateTime -= CurrentCreateOperateTime * OperateDecreaseRate;
  657. CreateOperateTimer = CurrentCreateOperateTime;
  658. CreatePunchGameOperate();
  659. }
  660. }
  661. DropAwardThread();
  662. }
  663. private void MemoryGameThread()
  664. {
  665. if (miniGameType != MiniGameType.Memory)
  666. {
  667. return;
  668. }
  669. GameTimer += Time.deltaTime;
  670. if (GameTimer >= GameTime)
  671. {
  672. GameOver();
  673. return;
  674. }
  675. if (Panalty)
  676. {
  677. PanaltyTimer -= Time.deltaTime;
  678. if (PanaltyTimer <= 0)
  679. {
  680. Panalty = false;
  681. }
  682. }
  683. if (MemoryGameFadeList.Count < MaxFadeAmt)
  684. {
  685. FlowerFadeTimer -= Time.deltaTime;
  686. if (FlowerFadeTimer <= 0)
  687. {
  688. FlowerFadeTimer = CurrentFlowerFadeTime;
  689. MemoryGameFadeNext();
  690. }
  691. }
  692. DropAwardThread();
  693. }
  694. private void FindGameThread()
  695. {
  696. if (miniGameType != MiniGameType.Find)
  697. {
  698. return;
  699. }
  700. GameTimer += Time.deltaTime;
  701. if (GameTimer >= GameTime)
  702. {
  703. GameOver();
  704. return;
  705. }
  706. if (Panalty)
  707. {
  708. PanaltyTimer -= Time.deltaTime;
  709. if (PanaltyTimer <= 0)
  710. {
  711. Panalty = false;
  712. }
  713. }
  714. DropAwardThread();
  715. }
  716. private void DropAwardThread()
  717. {
  718. DropGoldTimer -= Time.deltaTime;
  719. if (DropGoldTimer < 0)
  720. {
  721. DropGoldTimer = Random.Range(DropGoldMinIndex, DropGoldMaxIndex);
  722. DropAwardList.Add(ResourceManager.GetDrop(ObjType.DropGold));
  723. }
  724. if (CreateDropDiamondFlag)
  725. {
  726. DropDiamondTimer -= Time.deltaTime;
  727. if (DropDiamondTimer < 0)
  728. {
  729. CreateDropDiamondFlag = false;
  730. DropAwardList.Add(ResourceManager.GetDrop(ObjType.DropDiamond));
  731. }
  732. }
  733. }
  734. private void PrepareThread()
  735. {
  736. PrepareTimer -= Time.deltaTime;
  737. if (PrepareTimer <= 0)
  738. {
  739. IsPrepare = false;
  740. GameBegin();
  741. }
  742. }
  743. public override void FirstInit()
  744. {
  745. MinigameAward = new MinigameAward(ConfigManager.GetAwardConfig());
  746. MiniGameIndex = ConfigManager.GetIntFormConfig(PlayerConfigLabel.MiniGameIndex);
  747. }
  748. public override void RegistReference()
  749. {
  750. DisplayGrid = ResourceManager.Get(ObjectLabel.D_Grid);
  751. MinigameBeginButtonParent = ResourceManager.Get(ObjectLabel.D_Begin);
  752. MinigameTimerParent = ResourceManager.Get(ObjectLabel.D_Timer);
  753. PunchGameStatusParent = ResourceManager.Get(ObjectLabel.D_Status1);
  754. MemoryGameStatusParent = ResourceManager.Get(ObjectLabel.D_Status2);
  755. FindGameStatusParent = ResourceManager.Get(ObjectLabel.D_Status3);
  756. PunchGameOperateParent = ResourceManager.Get(ObjectLabel.D_Operate1);
  757. MemoryGameOperateParent = ResourceManager.Get(ObjectLabel.D_Operate2);
  758. FindGameOperateParent = ResourceManager.Get(ObjectLabel.D_Operate3);
  759. MinigameTimerText = ResourceManager.Get<Text>(ObjectLabel.D_TimerLab);
  760. PrepareText = ResourceManager.Get<Text>(ObjectLabel.D_PrepareLab);
  761. MinigameTimerBk = ResourceManager.Get<Image>(ObjectLabel.D_TimerIcon);
  762. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot1));
  763. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot2));
  764. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot3));
  765. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot4));
  766. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot5));
  767. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot6));
  768. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot7));
  769. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot8));
  770. MinigameSlots.Add(ResourceManager.Get(GardenLabel.MinigameSlot9));
  771. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn1));
  772. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn2));
  773. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn3));
  774. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn4));
  775. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn5));
  776. D_MemoryGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn6));
  777. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick1));
  778. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick2));
  779. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick3));
  780. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick4));
  781. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick5));
  782. D_MemoryGameTicks.Add(ResourceManager.Get(ObjectLabel.D_FlowerTick6));
  783. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon1));
  784. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon2));
  785. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon3));
  786. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon4));
  787. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon5));
  788. D_MemoryGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon6));
  789. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow1));
  790. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow2));
  791. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow3));
  792. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow4));
  793. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow5));
  794. D_MemoryGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow6));
  795. D_FindGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn7));
  796. D_FindGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn8));
  797. D_FindGameBtns.Add(ResourceManager.Get(ObjectLabel.D_FlowerBtn9));
  798. D_FindGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon7));
  799. D_FindGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon8));
  800. D_FindGameIcons.Add(ResourceManager.Get(ObjectLabel.D_FlowerIcon9));
  801. D_FindGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow7));
  802. D_FindGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow8));
  803. D_FindGameArrows.Add(ResourceManager.Get(ObjectLabel.D_FlowerArrow9));
  804. }
  805. public static void TryGetNewFlower()
  806. {
  807. bool newFlowerFlag = ConfigManager.GetBoolFormConfig(PlayerConfigLabel.NewFlowerFlag);
  808. if (newFlowerFlag)
  809. {
  810. List<int> unlockedFlowerIDList = GardenManager.UnlockedFlowerIDList;
  811. if (GardenManager.FirstUnlockFlowerID != -1)
  812. unlockedFlowerIDList.Add(GardenManager.FirstUnlockFlowerID);
  813. MinigameAward.UnlockFlowerID = MinigameAward.SelectUnlockFlowerID(unlockedFlowerIDList);
  814. MinigameAward.HaveNewFlowerFlag = false;
  815. }
  816. else
  817. {
  818. MinigameAward.HaveNewFlowerFlag = true;
  819. }
  820. }
  821. public static void ResetNewFlowerFlag()
  822. {
  823. float flowerRate = (float) Auxiliary.FmlParse(MinigameAward.UnlockFlowerFml, "l", Manager.GardenLevel.ToString(), "f", GardenManager.TotalUnlockFlower.ToString());
  824. if (Random.Range(0, 1f) <= flowerRate)
  825. {
  826. ConfigManager.SaveBoolToConfig(PlayerConfigLabel.NewFlowerFlag, true);
  827. }
  828. else
  829. {
  830. ConfigManager.SaveBoolToConfig(PlayerConfigLabel.NewFlowerFlag, false);
  831. }
  832. }
  833. public static MiniGameType SelectMinigameType()
  834. {
  835. PunchGameOperateParent.SetActive(false);
  836. MemoryGameOperateParent.SetActive(false);
  837. FindGameOperateParent.SetActive(false);
  838. bool memoryGameAvailable = Manager.GardenLevel >= TutorialManager.MemoryMinigameTutorialLevel;
  839. bool findGameAvailable = GardenManager.TotalUnlockFlower >= TutorialManager.MinFlowerForFindGame && Manager.GardenLevel >= TutorialManager.FindMinigameTutorialLevel;
  840. float punchGameThreshold;
  841. float memoryGameThreshold;
  842. float findGameThreshold;
  843. if (memoryGameAvailable && findGameAvailable)
  844. {
  845. punchGameThreshold = 0.33f;
  846. memoryGameThreshold = 0.66f;
  847. findGameThreshold = 1f;
  848. }
  849. else if (memoryGameAvailable)
  850. {
  851. punchGameThreshold = 0.5f;
  852. memoryGameThreshold = 1;
  853. findGameThreshold = 0;
  854. }
  855. else if (findGameAvailable)
  856. {
  857. punchGameThreshold = 0.5f;
  858. memoryGameThreshold = 0;
  859. findGameThreshold = 1;
  860. }
  861. else
  862. {
  863. punchGameThreshold = 1;
  864. memoryGameThreshold = 0;
  865. findGameThreshold = 0;
  866. }
  867. float posibility = Random.Range(0f, 1f);
  868. if (posibility <= punchGameThreshold)
  869. {
  870. miniGameType = MiniGameType.Punch;
  871. }
  872. else if (posibility <= memoryGameThreshold)
  873. {
  874. miniGameType = MiniGameType.Memory;
  875. }
  876. else if (posibility <= findGameThreshold)
  877. {
  878. miniGameType = MiniGameType.Find;
  879. }
  880. else
  881. {
  882. throw new Exception();
  883. }
  884. return miniGameType;
  885. }
  886. public static void GameEnter(MiniGameType type)
  887. {
  888. miniGameType = type;
  889. TryGetNewFlower();
  890. if (miniGameType == MiniGameType.Punch)
  891. {
  892. EnterPunchGame();
  893. }
  894. if (miniGameType == MiniGameType.Memory)
  895. {
  896. EnterMemoryGame();
  897. }
  898. if (miniGameType == MiniGameType.Find)
  899. {
  900. EnterFindGame();
  901. }
  902. ScoreTextPrefix = Language.GetStr(LanguageLabel.UI__D_ScoreLab);
  903. MinigameTimerBk.fillAmount = 0;
  904. MinigameTimerText.text = GameTime.ToString("0");
  905. ResourceManager.Get(ObjectLabel.C_MiniGame).TweenBacCG();
  906. ResourceManager.Get(GardenLabel.Minigame).TweenForVec();
  907. ResourceManager.Get(ObjectLabel.D_MiniGame).TweenForCG();
  908. AudioManager.PlayClip(AudioLabel.Bubble);
  909. }
  910. public static void GameBegin()
  911. {
  912. ConfigManager.SaveBoolToConfig(PlayerConfigLabel.NewFlowerFlag, false);
  913. Game = true;
  914. MiniGameIndex++;
  915. Score = 0;
  916. CreateOperateTimer = CreateOperateTime;
  917. FlowerFadeTimer = FlowerFadeTime;
  918. DropGoldTimer = Random.Range(DropGoldMinIndex, DropGoldMaxIndex);
  919. GameTimer = 0;
  920. CurrentCreateOperateTime = CreateOperateTime;
  921. CurrentFlowerFadeTime = FlowerFadeTime;
  922. DropDiamondTimer = Random.Range(0f, GameTime - DropDiamondOffsetTime);
  923. StaticsManager.GetInstance().UseItem(StaticsManager.ItemID.开始小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None);
  924. if (miniGameType == MiniGameType.Punch)
  925. {
  926. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  927. {
  928. MinigameIdleFlowerList[i].GameBegin();
  929. }
  930. }
  931. if (miniGameType == MiniGameType.Memory)
  932. {
  933. MemoryGameRoundReset();
  934. }
  935. if (miniGameType == MiniGameType.Find)
  936. {
  937. FindGameRoundBegin(true);
  938. }
  939. if (Random.Range(DropDiamondMinIndex, DropDiamondMaxIndex) <= MiniGameIndex)
  940. {
  941. MiniGameIndex = 0;
  942. CreateDropDiamondFlag = true;
  943. }
  944. else
  945. {
  946. if (Random.Range(0, 1f) <= DropDiamondRate)
  947. {
  948. CreateDropDiamondFlag = true;
  949. }
  950. else
  951. {
  952. CreateDropDiamondFlag = false;
  953. }
  954. }
  955. }
  956. public static void GamePrepare()
  957. {
  958. IsPrepare = true;
  959. PrepareTimer = PrepareTime;
  960. ResourceManager.Get(ObjectLabel.D_Begin).SetActive(false);
  961. ResourceManager.Get(ObjectLabel.D_DescA).SetActive(false);
  962. ResourceManager.Get(ObjectLabel.D_DescB).SetActive(false);
  963. ResourceManager.Get(ObjectLabel.D_DescC).SetActive(false);
  964. if (miniGameType == MiniGameType.Punch)
  965. {
  966. ResourceManager.Get(ObjectLabel.D_Rip1).SetActive(true);
  967. ResourceManager.Get(ObjectLabel.D_Water1).SetActive(true);
  968. ResourceManager.Get(ObjectLabel.D_Fertilize1).SetActive(true);
  969. }
  970. if (miniGameType == MiniGameType.Memory)
  971. {
  972. ResourceManager.Get(ObjectLabel.D_Mask).TweenForGra();
  973. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn1, true);
  974. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn2, true);
  975. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn3, true);
  976. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn4, true);
  977. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn5, true);
  978. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn6, true);
  979. float deltaSIzeX = 1.0625f;
  980. float deltaSIzeY = 1.0625f;
  981. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon1, MinigameFlowerDictionary[0].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  982. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon2, MinigameFlowerDictionary[1].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  983. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon3, MinigameFlowerDictionary[3].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  984. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon4, MinigameFlowerDictionary[4].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  985. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon5, MinigameFlowerDictionary[6].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  986. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon6, MinigameFlowerDictionary[7].FlowerInfo.Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  987. }
  988. PrepareText.StreamForScale();
  989. }
  990. public static void GameEnd()
  991. {
  992. PrepareText.GetStreamScale().InOrigin = true;
  993. if (Game)
  994. {
  995. Manager.MinigameFlag = false;
  996. Manager.MinigameCDTimer = Mathf.Lerp(MinMinigameCD, MaxMinigameCD, Random.Range(0, 1f));
  997. ResetNewFlowerFlag();
  998. }
  999. ResourceManager.Get(ObjectLabel.C_MiniGame).TweenForCG();
  1000. if (Manager.MinigameCDTimer > 0)
  1001. {
  1002. ResourceManager.Get(ObjectLabel.C_MiniGame).TweenForRect();
  1003. }
  1004. Score = 0;
  1005. Pause = false;
  1006. Game = false;
  1007. Panalty = false;
  1008. IsPrepare = false;
  1009. GameTimer = GameTime;
  1010. for (int i = 0; i < PunchGameOperateList.Count; i++)
  1011. {
  1012. PunchGameOperateList[i].GameOver();
  1013. }
  1014. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  1015. {
  1016. MinigameIdleFlowerList[i].GameOver();
  1017. }
  1018. for (int i = 0; i < DropAwardList.Count; i++)
  1019. {
  1020. DropAwardList[i].Retrieve();
  1021. DropAwardList.RemoveAt(i--);
  1022. }
  1023. }
  1024. public static void GameOver()
  1025. {
  1026. AudioManager.PlayClip(AudioLabel.MinigameEnd);
  1027. MinigameAward.GetAward(Score);
  1028. Manager.PlayMinigameAmt++;
  1029. GameEnd();
  1030. }
  1031. public static void OnFindGameButtonClick(int id, int btnIndex)
  1032. {
  1033. if (!Game)
  1034. {
  1035. return;
  1036. }
  1037. if (Panalty)
  1038. {
  1039. return;
  1040. }
  1041. if (FindGameFlowerIDs[0] == id)
  1042. {
  1043. Flower flower = MinigameIdleFlowerList.Find(tempFlower => { return tempFlower.ID == id; });
  1044. ResourceManager.GetHudText($"+{FindCorrectScore}", Color.white, 90, flower.ChildDic[FlowerLabel.ScorePos], ResourceManager.Get(ObjectLabel.D_HudParent), true);
  1045. Score += FindCorrectScore;
  1046. flower.PlayFlashLight();
  1047. AudioManager.PlayClip(AudioLabel.ClickButton);
  1048. FindGameRoundEnd();
  1049. }
  1050. else
  1051. {
  1052. Panalty = true;
  1053. PanaltyTimer = PanaltyTime;
  1054. D_FindGameIcons[btnIndex].TweenForGra();
  1055. D_FindGameBtns[btnIndex].Shake(0.5f, 3, new Vector3(20f, 0, 0), Curve.EaseOutQuad);
  1056. AudioManager.PlayClip(AudioLabel.Error);
  1057. }
  1058. }
  1059. public static void OnMemoryGameClick(int index, int slotIndex)
  1060. {
  1061. if (Panalty || !MemoryGameFadeList.Valid())
  1062. {
  1063. return;
  1064. }
  1065. if (FindGameIndexList.Count == 0)
  1066. {
  1067. return;
  1068. }
  1069. if (slotIndex == FindGameIndexList[0])
  1070. {
  1071. D_MemoryGameBtns[index].GetComponent<Image>().material = Lib.GrayMat;
  1072. D_MemoryGameBtns[index].GetComponent<Button>().interactable = false;
  1073. D_MemoryGameIcons[index].GetComponent<Image>().material = Lib.GrayMat;
  1074. D_MemoryGameTicks[index].SetActive(true);
  1075. FindGameIndexList.RemoveAt(0);
  1076. Flower flower = MinigameFlowerDictionary[slotIndex];
  1077. ResourceManager.GetHudText($"+{MemoryCorrectScore}", Color.white, 90, flower.ChildDic[FlowerLabel.ScorePos], ResourceManager.Get(ObjectLabel.D_HudParent), true);
  1078. Score += MemoryCorrectScore;
  1079. flower.PlayFlashLight();
  1080. if (!MinigameAward.HaveNewFlowerFlag && MinigameAward.UnlockFlowerID == flower.ID && !PlayNewflowerEffectFlag)
  1081. {
  1082. flower.PlayNewFlowerEffec();
  1083. PlayNewflowerEffectFlag = true;
  1084. }
  1085. AudioManager.PlayClip(AudioLabel.ClickButton);
  1086. TweenRoot tween = flower.FlowerIcon.TweenBacSr();
  1087. if (FindGameIndexList.Count == 0)
  1088. {
  1089. tween.AddEventOnetime
  1090. (
  1091. EventType.BackwardFinish,
  1092. () =>
  1093. {
  1094. MemoryGameRoundEnd();
  1095. MemoryGameRoundReset();
  1096. MemoryGameRoundBegin();
  1097. }
  1098. );
  1099. }
  1100. }
  1101. else
  1102. {
  1103. Panalty = true;
  1104. PanaltyTimer = PanaltyTime;
  1105. D_MemoryGameIcons[index].TweenForGra();
  1106. D_MemoryGameBtns[index].Shake(0.5f, 3, new Vector3(20f, 0, 0), Curve.EaseOutQuad);
  1107. AudioManager.PlayClip(AudioLabel.Error);
  1108. }
  1109. }
  1110. public static void CreatePunchGameOperate()
  1111. {
  1112. AudioManager.PlayClip(AudioLabel.Bubble);
  1113. if (TutorialManager.NewplayerTutorial && PunchGameTutorialFlag)
  1114. {
  1115. Pause = true;
  1116. PunchGameTutorialFlag = false;
  1117. Flower flower = MinigameIdleFlowerList[4];
  1118. flower.CreateOp(PunchGameOperateList.Count, OpType.Water);
  1119. PunchGameOperateList.Add(flower);
  1120. MinigameIdleFlowerList.Remove(flower);
  1121. Tutorial.HightScreen(ResourceManager.Get(ObjectLabel.D_WaterArrow0), ResourceManager.Get(ObjectLabel.D_WaterArrow1), ResourceManager.Get(ObjectLabel.D_Water1));
  1122. Tutorial.SetArea(PunchGameOperateList[0].OperateIcon.transform, 0.1f, 0.125f);
  1123. ResourceManager.AddButtonEventOnetime
  1124. (
  1125. ObjectLabel.D_Water2,
  1126. () =>
  1127. {
  1128. Pause = false;
  1129. Tutorial.HightDisable();
  1130. }
  1131. );
  1132. }
  1133. else
  1134. {
  1135. Flower flower = MinigameIdleFlowerList[Random.Range(0, MinigameIdleFlowerList.Count)];
  1136. flower.CreateOp(PunchGameOperateList.Count);
  1137. PunchGameOperateList.Add(flower);
  1138. MinigameIdleFlowerList.Remove(flower);
  1139. }
  1140. }
  1141. public static void OnPunchGameClick(OpType opType)
  1142. {
  1143. if (Panalty || !PunchGameOperateList.Valid())
  1144. {
  1145. return;
  1146. }
  1147. if (PunchGameOperateList[0].Operate(opType))
  1148. {
  1149. MinigameIdleFlowerList.Add(PunchGameOperateList[0]);
  1150. PunchGameOperateList.Remove(PunchGameOperateList[0]);
  1151. if (PunchGameOperateList.Count >= 2)
  1152. {
  1153. PunchGameOperateList[0].SetFirstOp();
  1154. PunchGameOperateList[1].SetSecondOp();
  1155. }
  1156. else if (PunchGameOperateList.Count >= 1)
  1157. {
  1158. PunchGameOperateList[0].SetFirstOp();
  1159. }
  1160. }
  1161. else
  1162. {
  1163. Panalty = true;
  1164. PanaltyTimer = PanaltyTime;
  1165. }
  1166. }
  1167. public static void EnterPunchGame()
  1168. {
  1169. PunchGameOperateParent.SetActive(true);
  1170. MinigameTimerParent.SetParent(PunchGameStatusParent);
  1171. DisplayGrid.SetParent(PunchGameStatusParent);
  1172. MinigameBeginButtonParent.SetParent(PunchGameOperateParent);
  1173. PrepareText.SetParent(ResourceManager.Get(ObjectLabel.D_PrepareLayout1));
  1174. ResourceManager.SetActive(ObjectLabel.D_Rip1, false);
  1175. ResourceManager.SetActive(ObjectLabel.D_Water1, false);
  1176. ResourceManager.SetActive(ObjectLabel.D_Fertilize1, false);
  1177. ResourceManager.SetActive(ObjectLabel.D_Begin, true);
  1178. ResourceManager.SetActive(ObjectLabel.D_DescA, true);
  1179. if (MinigameAward.HaveNewFlowerFlag)
  1180. {
  1181. for (int i = 0; i < PunchGameSlotAmt; i++)
  1182. {
  1183. while (true)
  1184. {
  1185. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary.Random();
  1186. if (flowerInfo.Unlock)
  1187. {
  1188. MinigameIdleFlowerList.Add(ResourceManager.GetFlower(flowerInfo, MinigameSlots[i]));
  1189. break;
  1190. }
  1191. }
  1192. }
  1193. }
  1194. else
  1195. {
  1196. List<int> idList = new List<int>();
  1197. idList = new List<int>(PunchGameSlotIDs);
  1198. int specialSlotID = idList.Random(1, true, true)[0];
  1199. Flower flower = ResourceManager.GetFlower(GardenManager.FlowerInfoDictionary[MinigameAward.UnlockFlowerID], MinigameSlots[specialSlotID]);
  1200. flower.PlayNewFlowerEffec();
  1201. MinigameIdleFlowerList.Add(flower);
  1202. for (int i = 0; i < idList.Count; i++)
  1203. {
  1204. while (true)
  1205. {
  1206. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary.Random();
  1207. if (flowerInfo.Unlock)
  1208. {
  1209. flower = ResourceManager.GetFlower(flowerInfo, MinigameSlots[idList[i]]);
  1210. MinigameIdleFlowerList.Add(flower);
  1211. break;
  1212. }
  1213. }
  1214. }
  1215. }
  1216. }
  1217. public static void EnterMemoryGame()
  1218. {
  1219. MemoryGameOperateParent.SetActive(true);
  1220. MinigameTimerParent.SetParent(MemoryGameStatusParent);
  1221. DisplayGrid.SetParent(MemoryGameStatusParent);
  1222. MinigameBeginButtonParent.SetParent(MemoryGameOperateParent);
  1223. PrepareText.SetParent(ResourceManager.Get(ObjectLabel.D_PrepareLayout2));
  1224. ResetMemoryGameButtons();
  1225. ResourceManager.Get(ObjectLabel.D_Mask).TweenBacGra();
  1226. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn1, false);
  1227. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn2, false);
  1228. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn3, false);
  1229. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn4, false);
  1230. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn5, false);
  1231. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn6, false);
  1232. ResourceManager.SetActive(ObjectLabel.D_Begin, true);
  1233. ResourceManager.SetActive(ObjectLabel.D_DescB, true);
  1234. List<int> idList = new List<int>(MemoryGameSlotIDs);
  1235. MinigameFlowerDictionary = new Dictionary<int, Flower>();
  1236. Flower flower;
  1237. if (MinigameAward.HaveNewFlowerFlag)
  1238. {
  1239. for (int i = 0; i < idList.Count; i++)
  1240. {
  1241. while (true)
  1242. {
  1243. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary.Random();
  1244. if (flowerInfo.Unlock)
  1245. {
  1246. flower = ResourceManager.GetFlower(flowerInfo, MinigameSlots[idList[i]]);
  1247. MinigameIdleFlowerList.Add(flower);
  1248. MinigameFlowerDictionary.Add(idList[i], flower);
  1249. break;
  1250. }
  1251. }
  1252. }
  1253. }
  1254. else
  1255. {
  1256. int specialSlotID = idList.Random(1, true, true)[0];
  1257. flower = ResourceManager.GetFlower(GardenManager.FlowerInfoDictionary[MinigameAward.UnlockFlowerID], MinigameSlots[specialSlotID]);
  1258. flower.PlayNewFlowerEffec();
  1259. MinigameIdleFlowerList.Add(flower);
  1260. MinigameFlowerDictionary.Add(specialSlotID, flower);
  1261. for (int i = 0; i < idList.Count; i++)
  1262. {
  1263. while (true)
  1264. {
  1265. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary.Random();
  1266. if (flowerInfo.Unlock)
  1267. {
  1268. flower = ResourceManager.GetFlower(flowerInfo, MinigameSlots[idList[i]]);
  1269. MinigameIdleFlowerList.Add(flower);
  1270. MinigameFlowerDictionary.Add(idList[i], flower);
  1271. break;
  1272. }
  1273. }
  1274. }
  1275. }
  1276. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  1277. {
  1278. MinigameIdleFlowerList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true);
  1279. }
  1280. }
  1281. public static void EnterFindGame()
  1282. {
  1283. FindGameOperateParent.SetActive(true);
  1284. ResourceManager.SetActive(ObjectLabel.D_Begin, true);
  1285. ResourceManager.SetActive(ObjectLabel.D_DescC, true);
  1286. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn7, false);
  1287. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn8, false);
  1288. ResourceManager.SetActive(ObjectLabel.D_FlowerBtn9, false);
  1289. MinigameBeginButtonParent.SetParent(FindGameOperateParent);
  1290. MinigameTimerParent.SetParent(FindGameStatusParent);
  1291. DisplayGrid.SetParent(FindGameStatusParent);
  1292. PrepareText.SetParent(ResourceManager.Get(ObjectLabel.D_PrepareLayout3));
  1293. FindGameRoundReset(true);
  1294. }
  1295. public static void MemoryGameRoundEnd()
  1296. {
  1297. ResourceManager.Get(ObjectLabel.D_Mask).TweenForGra();
  1298. }
  1299. public static void MemoryGameRoundReset()
  1300. {
  1301. for (int i = 0; i < MemoryGameFadeList.Count; i++)
  1302. {
  1303. MinigameIdleFlowerList.Add(MemoryGameFadeList[i]);
  1304. }
  1305. CurrentFlowerFadeTime -= CurrentFlowerFadeTime * MemoryGameDecreaseRate;
  1306. FlowerFadeTimer = CurrentFlowerFadeTime;
  1307. MemoryGameFadeList = new List<Flower>();
  1308. FindGameIndexList = new List<int>();
  1309. List<int> randomList = new List<int>(MemoryGameSlotIDs);
  1310. for (int i = 0; i < randomList.Count; i++)
  1311. {
  1312. FindGameIndexList.Add(randomList.Random(1, true, true)[0]);
  1313. i--;
  1314. }
  1315. ResetMemoryGameButtons();
  1316. }
  1317. public static void MemoryGameRoundBegin()
  1318. {
  1319. ResourceManager.Get(ObjectLabel.D_Mask).TweenBacGra();
  1320. if (TutorialManager.MemoryMinigameTutorial)
  1321. {
  1322. TutorialManager.PlayMemoryGame();
  1323. }
  1324. }
  1325. public static void ResetMemoryGameButtons()
  1326. {
  1327. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn1).material = null;
  1328. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn2).material = null;
  1329. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn3).material = null;
  1330. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn4).material = null;
  1331. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn5).material = null;
  1332. ResourceManager.Get<Image>(ObjectLabel.D_FlowerBtn6).material = null;
  1333. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn1).interactable = true;
  1334. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn2).interactable = true;
  1335. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn3).interactable = true;
  1336. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn4).interactable = true;
  1337. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn5).interactable = true;
  1338. ResourceManager.Get<Button>(ObjectLabel.D_FlowerBtn6).interactable = true;
  1339. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon1).material = null;
  1340. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon2).material = null;
  1341. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon3).material = null;
  1342. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon4).material = null;
  1343. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon5).material = null;
  1344. ResourceManager.Get<Image>(ObjectLabel.D_FlowerIcon6).material = null;
  1345. ResourceManager.SetActive(ObjectLabel.D_FlowerTick1, false);
  1346. ResourceManager.SetActive(ObjectLabel.D_FlowerTick2, false);
  1347. ResourceManager.SetActive(ObjectLabel.D_FlowerTick3, false);
  1348. ResourceManager.SetActive(ObjectLabel.D_FlowerTick4, false);
  1349. ResourceManager.SetActive(ObjectLabel.D_FlowerTick5, false);
  1350. ResourceManager.SetActive(ObjectLabel.D_FlowerTick6, false);
  1351. }
  1352. public static void MemoryGameFadeNext()
  1353. {
  1354. for (int i = 0; i < FindGameIndexList.Count; i++)
  1355. {
  1356. Flower flower = MinigameFlowerDictionary[FindGameIndexList[i]];
  1357. if (MemoryGameFadeList.UniqueAdd(flower))
  1358. {
  1359. MinigameIdleFlowerList.Remove(flower);
  1360. flower.PlayFlashLight();
  1361. flower.StopNewFlowerEffec();
  1362. PlayNewflowerEffectFlag = false;
  1363. flower.FlowerIcon.TweenForSr();
  1364. if (MemoryGameFadeList.Count == MaxFadeAmt)
  1365. {
  1366. MemoryGameRoundBegin();
  1367. }
  1368. break;
  1369. }
  1370. }
  1371. }
  1372. public static int GetMemoryGameButtonIndex(int slotIndex)
  1373. {
  1374. if (slotIndex == 0)
  1375. {
  1376. return 0;
  1377. }
  1378. else if (slotIndex == 1)
  1379. {
  1380. return 1;
  1381. }
  1382. else if (slotIndex == 3)
  1383. {
  1384. return 2;
  1385. }
  1386. else if (slotIndex == 4)
  1387. {
  1388. return 3;
  1389. }
  1390. else if (slotIndex == 6)
  1391. {
  1392. return 4;
  1393. }
  1394. else if (slotIndex == 7)
  1395. {
  1396. return 5;
  1397. }
  1398. else
  1399. {
  1400. throw new Exception();
  1401. }
  1402. }
  1403. public static void FindGameRoundEnd()
  1404. {
  1405. if (MinigameIdleFlowerList[0].ID == MinigameAward.UnlockFlowerID)
  1406. {
  1407. MinigameIdleFlowerList[0].StopNewFlowerEffec();
  1408. }
  1409. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  1410. {
  1411. MinigameIdleFlowerList[i].FlowerIcon.TweenForSr();
  1412. }
  1413. ResourceManager.Get(ObjectLabel.D_FlowerBtn7).TweenBacCG();
  1414. ResourceManager.Get(ObjectLabel.D_FlowerBtn8).TweenBacCG();
  1415. ResourceManager.Get(ObjectLabel.D_FlowerBtn9).TweenBacCG();
  1416. Auxiliary.Instance.DelayCall
  1417. (
  1418. () =>
  1419. {
  1420. if (Game)
  1421. {
  1422. FindGameRoundReset();
  1423. FindGameRoundBegin();
  1424. }
  1425. },
  1426. 1.5f
  1427. );
  1428. }
  1429. public static void FindGameRoundReset(bool firstRound = false)
  1430. {
  1431. ExtList.ForEach(MinigameIdleFlowerList, flower => { flower.FlowerIcon.SetAlpha(1); flower.FlowerIcon.SetActive(true); flower.RetrieveFlower();});
  1432. MinigameIdleFlowerList = new List<Flower>();
  1433. FindGameFlowerIDs = new List<int>();
  1434. List<int> slotIDs = new List<int>(FindGameSlotIDs);
  1435. FlowerInfo flowerInfo;
  1436. if (firstRound && !MinigameAward.HaveNewFlowerFlag)
  1437. {
  1438. flowerInfo = GardenManager.FlowerInfoDictionary[MinigameAward.UnlockFlowerID];
  1439. }
  1440. else
  1441. {
  1442. flowerInfo = GardenManager.FlowerInfoDictionary.Random(false, flowerIndo => { return flowerIndo.Unlock; });
  1443. }
  1444. FindGameFlowerIDs.Add(flowerInfo.ID);
  1445. MinigameIdleFlowerList.Add(ResourceManager.GetFlower(flowerInfo, MinigameSlots[slotIDs.Random(1, true, true)[0]]));
  1446. while (slotIDs.Count > 0)
  1447. {
  1448. flowerInfo = GardenManager.FlowerInfoDictionary.Random(false, info => { return info.Unlock && info.ID != FindGameFlowerIDs[0]; });
  1449. if (slotIDs.Count == 1)
  1450. {
  1451. if (!FindGameFlowerIDs.Contains(flowerInfo.ID))
  1452. {
  1453. continue;
  1454. }
  1455. }
  1456. else
  1457. {
  1458. FindGameFlowerIDs.UniqueAdd(flowerInfo.ID);
  1459. }
  1460. int amt = Mathf.Min(Random.Range(2, 9), slotIDs.Count);
  1461. for (int i = 0; i < amt; i++)
  1462. {
  1463. MinigameIdleFlowerList.Add(ResourceManager.GetFlower(flowerInfo, MinigameSlots[slotIDs.Random(1, true, true)[0]]));
  1464. }
  1465. }
  1466. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  1467. {
  1468. MinigameIdleFlowerList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true).AlphaOnly = true;
  1469. MinigameIdleFlowerList[i].FlowerIcon.GetTweenSr().InDestination = true;
  1470. }
  1471. List<int> idList = new List<int>()
  1472. {
  1473. FindGameFlowerIDs[0],
  1474. };
  1475. if (FindGameFlowerIDs.Count == 2)
  1476. {
  1477. idList.Add(FindGameFlowerIDs[1]);
  1478. idList.Add(FindGameFlowerIDs[1]);
  1479. idList.RemoveAt(0);
  1480. idList.Insert(Random.Range(0, 3), FindGameFlowerIDs[0]);
  1481. }
  1482. else if (FindGameFlowerIDs.Count > 2)
  1483. {
  1484. idList.AddRange(FindGameFlowerIDs.Random(2, true, false, id => { return id != idList[0]; }));
  1485. idList = idList.Disturb();
  1486. }
  1487. else
  1488. {
  1489. throw new Exception();
  1490. }
  1491. float deltaSIzeX = 1.0625f;
  1492. float deltaSIzeY = 1.0625f;
  1493. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon7, GardenManager.FlowerInfoDictionary[idList[0]].Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  1494. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon8, GardenManager.FlowerInfoDictionary[idList[1]].Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  1495. ResourceManager.SetSprite(ObjectLabel.D_FlowerIcon9, GardenManager.FlowerInfoDictionary[idList[2]].Icon).Resize(true, deltaSIzeX, deltaSIzeY);
  1496. for (int i = 0; i < idList.Count; i++)
  1497. {
  1498. int id = idList[i];
  1499. int index = i;
  1500. if (firstRound && TutorialManager.FindMinigameTutorial && id == FindGameFlowerIDs[0])
  1501. {
  1502. FindGameCorrectButtonParent = D_FindGameBtns[i];
  1503. Button button = FindGameCorrectButtonParent.GetComponent<Button>();
  1504. button.onClick.RemoveAllListeners();
  1505. button.onClick.AddListener(() => { OnFindGameButtonClick(id, index); TutorialManager.EndClickCorrectButton(); });
  1506. }
  1507. else
  1508. {
  1509. Button button = D_FindGameBtns[i].GetComponent<Button>();
  1510. button.onClick.RemoveAllListeners();
  1511. button.onClick.AddListener(() => { OnFindGameButtonClick(id, index); });
  1512. }
  1513. }
  1514. }
  1515. public static void FindGameRoundBegin(bool firstRound = false)
  1516. {
  1517. if (firstRound && !MinigameAward.HaveNewFlowerFlag)
  1518. {
  1519. MinigameIdleFlowerList[0].PlayNewFlowerEffec();
  1520. }
  1521. ResourceManager.Get(ObjectLabel.D_FlowerBtn7).TweenReForCG();
  1522. ResourceManager.Get(ObjectLabel.D_FlowerBtn8).TweenReForCG();
  1523. ResourceManager.Get(ObjectLabel.D_FlowerBtn9).TweenReForCG();
  1524. for (int i = 0; i < MinigameIdleFlowerList.Count; i++)
  1525. {
  1526. MinigameIdleFlowerList[i].FlowerIcon.TweenBacSr();
  1527. }
  1528. if (firstRound && TutorialManager.FindMinigameTutorial)
  1529. {
  1530. TutorialManager.ShowCorrectButton(FindGameCorrectButtonParent.GetChild(1), FindGameCorrectButtonParent);
  1531. }
  1532. }
  1533. public void OnApplicationPause(bool pause)
  1534. {
  1535. if (!pause)
  1536. {
  1537. if (!TutorialManager.NewplayerTutorial)
  1538. {
  1539. if (Game || IsPrepare)
  1540. {
  1541. ResourceManager.Get<Button>(ObjectLabel.D_Quit).onClick.Invoke();
  1542. }
  1543. }
  1544. }
  1545. }
  1546. }