ManaMiniGame.cs 47 KB

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