ManaMiniGame.cs 49 KB

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