ManaMiniGame.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863
  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.25f, 0.25f);
  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.25f, 0.25f);
  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 List<int> IndexList = new List<int>();
  531. public static List<int> FlowerIDListC = new List<int>();
  532. public static List<Drop> DropList = new List<Drop>();
  533. public static List<Flower> OpList = new List<Flower>();
  534. public static List<Flower> IdleList = new List<Flower>();
  535. public static List<Flower> FadeList = new List<Flower>();
  536. public static Dictionary<int, Flower> FlowerDic = new Dictionary<int, Flower>();
  537. public static int MiniGameIndex;
  538. public static string ScoreLab;
  539. public static bool GameA;
  540. public static bool GameB;
  541. public static bool GameC;
  542. public static bool Prepare;
  543. public static bool FlowerLock;
  544. public static bool TutorialLock = true;
  545. public static bool DropDiamond;
  546. public static float OpTimer;
  547. public static float FadeTimer;
  548. public static float GoldTimer;
  549. public static float PanaltyTimer;
  550. public static float PrepareTimer;
  551. public static float DiamondTimer;
  552. public static float OpTime = 1.5f;
  553. public static float FadeTime = 2f;
  554. public static float GameTime = 45f;
  555. public static float PanaltyTime = 1f;
  556. public static float NewOpTime;
  557. public static float NewFadeTime;
  558. #endregion
  559. private void FixedUpdate()
  560. {
  561. if (Pause)
  562. {
  563. return;
  564. }
  565. if (Game)
  566. {
  567. GameThreadA();
  568. GameThreadB();
  569. GameThreadC();
  570. }
  571. if (Prepare)
  572. {
  573. PrepareThread();
  574. }
  575. }
  576. private void GameThreadA()
  577. {
  578. if (!GameA)
  579. {
  580. return;
  581. }
  582. GameTimer += Time.fixedDeltaTime;
  583. if (GameTimer >= GameTime)
  584. {
  585. GameOver();
  586. return;
  587. }
  588. if (Panalty)
  589. {
  590. PanaltyTimer -= Time.fixedDeltaTime;
  591. if (PanaltyTimer <= 0)
  592. {
  593. Panalty = false;
  594. }
  595. }
  596. if (IdleList.Count > 0)
  597. {
  598. OpTimer -= Time.fixedDeltaTime;
  599. if (OpTimer <= 0)
  600. {
  601. NewOpTime -= NewOpTime * 0.03f;
  602. OpTimer = NewOpTime;
  603. CreateOperate();
  604. }
  605. }
  606. BonusThread();
  607. }
  608. private void GameThreadB()
  609. {
  610. if (!GameB)
  611. {
  612. return;
  613. }
  614. GameTimer += Time.fixedDeltaTime;
  615. if (GameTimer >= GameTime)
  616. {
  617. GameOver();
  618. return;
  619. }
  620. if (Panalty)
  621. {
  622. PanaltyTimer -= Time.fixedDeltaTime;
  623. if (PanaltyTimer <= 0)
  624. {
  625. Panalty = false;
  626. }
  627. }
  628. if (FadeList.Count < 6)
  629. {
  630. FadeTimer -= Time.fixedDeltaTime;
  631. if (FadeTimer <= 0)
  632. {
  633. FadeTimer = NewFadeTime;
  634. Fade();
  635. }
  636. }
  637. BonusThread();
  638. }
  639. private void GameThreadC()
  640. {
  641. if (!GameC)
  642. {
  643. return;
  644. }
  645. GameTimer += Time.fixedDeltaTime;
  646. if (GameTimer >= GameTime)
  647. {
  648. GameOver();
  649. return;
  650. }
  651. if (Panalty)
  652. {
  653. PanaltyTimer -= Time.fixedDeltaTime;
  654. if (PanaltyTimer <= 0)
  655. {
  656. Panalty = false;
  657. }
  658. }
  659. BonusThread();
  660. }
  661. private void BonusThread()
  662. {
  663. GoldTimer -= Time.fixedDeltaTime;
  664. if (GoldTimer < 0)
  665. {
  666. GoldTimer = Random.Range(3f, 6f);
  667. DropList.Add(ManaReso.GetDrop(ObjType.DropGold));
  668. }
  669. if (DropDiamond)
  670. {
  671. DiamondTimer -= Time.fixedDeltaTime;
  672. if (DiamondTimer < 0)
  673. {
  674. DropDiamond = false;
  675. DropList.Add(ManaReso.GetDrop(ObjType.DropDiamond));
  676. }
  677. }
  678. }
  679. private void PrepareThread()
  680. {
  681. PrepareTimer -= Time.fixedDeltaTime;
  682. if (PrepareTimer <= 0)
  683. {
  684. Prepare = false;
  685. GameBegin();
  686. }
  687. }
  688. public override void RegistValueA()
  689. {
  690. Award = new Award(ManaData.GetAwardConfig());
  691. MiniGameIndex = ManaData.GetPlayerInt("MiniGameIndex");
  692. }
  693. public override void RegistReference()
  694. {
  695. D_Grid = ManaReso.Get("D_Grid");
  696. D_Begin = ManaReso.Get("D_Begin");
  697. D_Timer = ManaReso.Get("D_Timer");
  698. D_Status1 = ManaReso.Get("D_Status1");
  699. D_Status2 = ManaReso.Get("D_Status2");
  700. D_Status3 = ManaReso.Get("D_Status3");
  701. D_Operate1 = ManaReso.Get("D_Operate1");
  702. D_Operate2 = ManaReso.Get("D_Operate2");
  703. D_Operate3 = ManaReso.Get("D_Operate3");
  704. TimerLab = ManaReso.Get<Text>("D_TimerLab");
  705. PrepareLab = ManaReso.Get<Text>("D_PrepareLab");
  706. TimerBk = ManaReso.Get<Image>("D_TimerIcon");
  707. }
  708. public static void OperateC(int id, int btnIndex)
  709. {
  710. if (!Game)
  711. {
  712. return;
  713. }
  714. if (Panalty)
  715. {
  716. return;
  717. }
  718. if (FlowerIDListC[0] == id)
  719. {
  720. Flower flower = IdleList.Find(tempFlower => { return tempFlower.ID == id; });
  721. ManaReso.GetHudText("+50", Color.white, 90, flower.ChildDic["ScorePosTra"], ManaReso.Get("D_HudParent"), true);
  722. Score += 50;
  723. flower.PlayParticle();
  724. ManaAudio.PlayClip(Clip.BtnClip);
  725. RoundEndC();
  726. }
  727. else
  728. {
  729. Panalty = true;
  730. PanaltyTimer = PanaltyTime;
  731. ManaReso.Get("D_FlowerIcon" + btnIndex).TweenForGra();
  732. ManaReso.Get("D_FlowerBtn" + btnIndex).Shake(0.5f, 3, new Vector3(20f, 0, 0), Curve.EaseOutQuad);
  733. ManaAudio.PlayClip(Clip.ErrorClip);
  734. }
  735. }
  736. public static void OperateB(int index, int slotIndex)
  737. {
  738. if (Panalty || !FadeList.Valid())
  739. {
  740. return;
  741. }
  742. if (IndexList.Count == 0)
  743. {
  744. return;
  745. }
  746. if (slotIndex == IndexList[0])
  747. {
  748. int uiIndex = IndexMap(IndexList[0]);
  749. ManaReso.Get<Image>("D_FlowerBtn" + uiIndex).material = Lib.GrayMat;
  750. ManaReso.Get<Button>("D_FlowerBtn" + uiIndex).interactable = false;
  751. ManaReso.Get<Image>("D_FlowerIcon" + uiIndex).material = Lib.GrayMat;
  752. ManaReso.SetActive("D_FlowerTick" + uiIndex, true);
  753. IndexList.RemoveAt(0);
  754. Flower flower = FlowerDic[slotIndex];
  755. ManaReso.GetHudText("+30", Color.white, 90, flower.ChildDic["ScorePosTra"], ManaReso.Get("D_HudParent"), true);
  756. Score += 30;
  757. flower.PlayParticle();
  758. TweenRoot tween = flower.FlowerIcon.TweenBacSr();
  759. ManaAudio.PlayClip(Clip.BtnClip);
  760. if (IndexList.Count == 0)
  761. {
  762. tween.AddEventOnetime
  763. (
  764. EventType.BackwardFinish,
  765. () =>
  766. {
  767. RoundEndB();
  768. RoundResetB();
  769. RoundBeginB();
  770. }
  771. );
  772. }
  773. }
  774. else
  775. {
  776. Panalty = true;
  777. PanaltyTimer = PanaltyTime;
  778. ManaReso.Get("D_FlowerIcon" + index).TweenForGra();
  779. ManaReso.Get("D_FlowerBtn" + index).Shake(0.5f, 3, new Vector3(20f, 0, 0), Curve.EaseOutQuad);
  780. ManaAudio.PlayClip(Clip.ErrorClip);
  781. }
  782. }
  783. public static void OperateA(OpType opType)
  784. {
  785. if (Panalty || !OpList.Valid())
  786. {
  787. return;
  788. }
  789. if (OpList[0].Operate(opType))
  790. {
  791. IdleList.Add(OpList[0]);
  792. OpList.Remove(OpList[0]);
  793. if (OpList.Count >= 2)
  794. {
  795. OpList[0].SetFirstOp();
  796. OpList[1].SetSecondOp();
  797. }
  798. else if (OpList.Count >= 1)
  799. {
  800. OpList[0].SetFirstOp();
  801. }
  802. }
  803. else
  804. {
  805. Panalty = true;
  806. PanaltyTimer = PanaltyTime;
  807. }
  808. }
  809. public static void ResetOprerate()
  810. {
  811. ManaReso.Get<Image>("D_FlowerBtn1").material = null;
  812. ManaReso.Get<Image>("D_FlowerBtn2").material = null;
  813. ManaReso.Get<Image>("D_FlowerBtn3").material = null;
  814. ManaReso.Get<Image>("D_FlowerBtn4").material = null;
  815. ManaReso.Get<Image>("D_FlowerBtn5").material = null;
  816. ManaReso.Get<Image>("D_FlowerBtn6").material = null;
  817. ManaReso.Get<Button>("D_FlowerBtn1").interactable = true;
  818. ManaReso.Get<Button>("D_FlowerBtn2").interactable = true;
  819. ManaReso.Get<Button>("D_FlowerBtn3").interactable = true;
  820. ManaReso.Get<Button>("D_FlowerBtn4").interactable = true;
  821. ManaReso.Get<Button>("D_FlowerBtn5").interactable = true;
  822. ManaReso.Get<Button>("D_FlowerBtn6").interactable = true;
  823. ManaReso.Get<Image>("D_FlowerIcon1").material = null;
  824. ManaReso.Get<Image>("D_FlowerIcon2").material = null;
  825. ManaReso.Get<Image>("D_FlowerIcon3").material = null;
  826. ManaReso.Get<Image>("D_FlowerIcon4").material = null;
  827. ManaReso.Get<Image>("D_FlowerIcon5").material = null;
  828. ManaReso.Get<Image>("D_FlowerIcon6").material = null;
  829. ManaReso.SetActive("D_FlowerTick1", false);
  830. ManaReso.SetActive("D_FlowerTick2", false);
  831. ManaReso.SetActive("D_FlowerTick3", false);
  832. ManaReso.SetActive("D_FlowerTick4", false);
  833. ManaReso.SetActive("D_FlowerTick5", false);
  834. ManaReso.SetActive("D_FlowerTick6", false);
  835. }
  836. public static void CreateOperate()
  837. {
  838. ManaAudio.PlayClip(Clip.BubbleClip);
  839. if (ManaTutorial.TutorialA && TutorialLock)
  840. {
  841. Pause = true;
  842. TutorialLock = false;
  843. Flower flower = IdleList[4];
  844. flower.CreateOp(OpList.Count, OpType.Water);
  845. OpList.Add(flower);
  846. IdleList.Remove(flower);
  847. Tutorial.HightScreen(ManaReso.Get("D_WaterArrow0"), ManaReso.Get("D_WaterArrow1"), ManaReso.Get("D_Water1"));
  848. Tutorial.SetArea(OpList[0].OperateIcon.transform, 0.1f, 0.125f);
  849. ManaReso.AddButtonEventOnetime
  850. (
  851. "D_Water2",
  852. () =>
  853. {
  854. Pause = false;
  855. Tutorial.HightDisable();
  856. }
  857. );
  858. }
  859. else
  860. {
  861. Flower flower = IdleList[Random.Range(0, IdleList.Count)];
  862. flower.CreateOp(OpList.Count);
  863. OpList.Add(flower);
  864. IdleList.Remove(flower);
  865. }
  866. }
  867. public static void Fade()
  868. {
  869. for (int i = 0; i < IndexList.Count; i++)
  870. {
  871. Flower flower = FlowerDic[IndexList[i]];
  872. if (FadeList.UniqueAdd(flower))
  873. {
  874. IdleList.Remove(flower);
  875. flower.PlayParticle();
  876. flower.FlowerIcon.TweenForSr();
  877. if (FadeList.Count == 6)
  878. {
  879. RoundBeginB();
  880. }
  881. break;
  882. }
  883. }
  884. }
  885. public static void InitializeMode()
  886. {
  887. GameA = false;
  888. GameB = false;
  889. GameC = false;
  890. D_Operate1.SetActive(false);
  891. D_Operate2.SetActive(false);
  892. D_Operate3.SetActive(false);
  893. bool gameAvailibleB = ManaCenter.Level >= 18;
  894. bool gameAvailibleC = ManaGarden.MyFlower >= 2;
  895. float thresholdA;
  896. float thresholdB;
  897. float thresholdC;
  898. if (gameAvailibleB && gameAvailibleC)
  899. {
  900. thresholdA = 0.33f;
  901. thresholdB = 0.66f;
  902. thresholdC = 1f;
  903. }
  904. else if (gameAvailibleB)
  905. {
  906. thresholdA = 0.5f;
  907. thresholdB = 1;
  908. thresholdC = 0;
  909. }
  910. else if (gameAvailibleC)
  911. {
  912. thresholdA = 0.5f;
  913. thresholdB = 0;
  914. thresholdC = 1;
  915. }
  916. else
  917. {
  918. thresholdA = 1;
  919. thresholdB = 0;
  920. thresholdC = 0;
  921. }
  922. float posibility = Random.Range(0f, 1f);
  923. if (posibility <= thresholdA)
  924. {
  925. GameA = true;
  926. }
  927. else if (posibility <= thresholdB)
  928. {
  929. GameB = true;
  930. }
  931. else if (posibility <= thresholdC)
  932. {
  933. GameC = true;
  934. }
  935. if (ManaTutorial.TutorialB)
  936. {
  937. GameA = false;
  938. GameB = true;
  939. GameC = false;
  940. }
  941. if (ManaTutorial.TutorialE)
  942. {
  943. GameA = false;
  944. GameB = false;
  945. GameC = true;
  946. }
  947. }
  948. public static void InitializeAward()
  949. {
  950. float flowerRate = (float)Auxiliary.FmlParse(Award.FlowerFml, "l", ManaCenter.Level.ToString(), "f", ManaGarden.MyFlower.ToString());
  951. if (Random.Range(0, 1f) <= flowerRate)
  952. {
  953. if (ManaGarden.MyFlower < ManaGarden.TotalFlower)
  954. {
  955. foreach (var kv in ManaGarden.FlowerInfoDic)
  956. {
  957. if (kv.Value.Unlock == false)
  958. {
  959. Award.FlowerID = kv.Value.ID_;
  960. Award.FlowerLock = false;
  961. break;
  962. }
  963. }
  964. }
  965. else
  966. {
  967. Award.FlowerLock = true;
  968. }
  969. }
  970. else
  971. {
  972. Award.FlowerLock = true;
  973. }
  974. }
  975. public static void GameEnd()
  976. {
  977. PrepareLab.GetStreamScale().InOrigin = true;
  978. if (Game)
  979. {
  980. ManaCenter.MiniLock = false;
  981. ManaCenter.MiniTimer = Mathf.Lerp(180, 300, Random.Range(0, 1f));
  982. }
  983. ManaReso.Get("C_MiniGame").TweenForCG();
  984. if (ManaCenter.MiniTimer > 0)
  985. {
  986. ManaReso.Get("C_MiniGame").TweenForRect();
  987. }
  988. Score = 0;
  989. Pause = false;
  990. Game = false;
  991. Panalty = false;
  992. Prepare = false;
  993. GameTimer = GameTime;
  994. for (int i = 0; i < OpList.Count; i++)
  995. {
  996. OpList[i].GameOver();
  997. }
  998. for (int i = 0; i < IdleList.Count; i++)
  999. {
  1000. IdleList[i].GameOver();
  1001. }
  1002. for (int i = 0; i < DropList.Count; i++)
  1003. {
  1004. DropList[i].Retrieve();
  1005. DropList.RemoveAt(i--);
  1006. }
  1007. }
  1008. public static void GameOver()
  1009. {
  1010. ManaAudio.PlayClip(Clip.MiniEndClip);
  1011. Award.GetAward(Score);
  1012. ManaCenter.MiniGameAmt++;
  1013. FlowerLock = false;
  1014. GameEnd();
  1015. }
  1016. public static void GameEnter()
  1017. {
  1018. if (ManaTutorial.TutorialA)
  1019. {
  1020. Award.FlowerID = 1;
  1021. Award.FlowerLock = true;
  1022. InitializeMode();
  1023. }
  1024. else
  1025. {
  1026. if (!FlowerLock)
  1027. {
  1028. InitializeMode();
  1029. InitializeAward();
  1030. FlowerLock = true;
  1031. }
  1032. }
  1033. if (ManaTutorial.TutorialB)
  1034. {
  1035. InitializeMode();
  1036. }
  1037. if (GameA)
  1038. {
  1039. GameEnterA();
  1040. }
  1041. if (GameB)
  1042. {
  1043. GameEnterB();
  1044. }
  1045. if (GameC)
  1046. {
  1047. GameEnterC();
  1048. }
  1049. ScoreLab = Language.GetStr("UI", "D_ScoreLab");
  1050. TimerBk.fillAmount = 0;
  1051. TimerLab.text = GameTime.ToString("0");
  1052. ManaReso.Get("C_MiniGame").TweenBacCG();
  1053. }
  1054. public static void GameEnterA()
  1055. {
  1056. D_Operate1.SetActive(true);
  1057. D_Timer.SetParent(D_Status1);
  1058. D_Grid.SetParent(D_Status1);
  1059. D_Begin.SetParent(D_Operate1);
  1060. PrepareLab.SetParent(ManaReso.Get("D_PrepareLayout1"));
  1061. ManaReso.SetActive("D_Rip1", false);
  1062. ManaReso.SetActive("D_Water1", false);
  1063. ManaReso.SetActive("D_Fertilize1", false);
  1064. ManaReso.SetActive("D_Begin", true);
  1065. ManaReso.SetActive("D_DescA", true);
  1066. if (Award.FlowerLock)
  1067. {
  1068. for (int i = 1; i < 10; i++)
  1069. {
  1070. while (true)
  1071. {
  1072. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  1073. if (flowerInfo.Unlock)
  1074. {
  1075. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + i)));
  1076. break;
  1077. }
  1078. }
  1079. }
  1080. }
  1081. else
  1082. {
  1083. List<int> idList = new List<int>();
  1084. idList = new List<int>() {1, 2, 3, 4, 5, 6, 7, 8, 9};
  1085. int special = idList.Random(1, true, true)[0];
  1086. Flower flower = ManaReso.GetFlower(ManaGarden.FlowerInfoDic[Award.FlowerID], ManaReso.Get("SlotMini" + special));
  1087. IdleList.Add(flower);
  1088. for (int i = 0; i < idList.Count; i++)
  1089. {
  1090. while (true)
  1091. {
  1092. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  1093. if (flowerInfo.Unlock)
  1094. {
  1095. flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
  1096. IdleList.Add(flower);
  1097. break;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. }
  1103. public static void GameEnterB()
  1104. {
  1105. D_Operate2.SetActive(true);
  1106. D_Timer.SetParent(D_Status2);
  1107. D_Grid.SetParent(D_Status2);
  1108. D_Begin.SetParent(D_Operate2);
  1109. PrepareLab.SetParent(ManaReso.Get("D_PrepareLayout2"));
  1110. ResetOprerate();
  1111. ManaReso.Get("D_Mask").TweenBacGra();
  1112. ManaReso.SetActive("D_FlowerBtn1", false);
  1113. ManaReso.SetActive("D_FlowerBtn2", false);
  1114. ManaReso.SetActive("D_FlowerBtn3", false);
  1115. ManaReso.SetActive("D_FlowerBtn4", false);
  1116. ManaReso.SetActive("D_FlowerBtn5", false);
  1117. ManaReso.SetActive("D_FlowerBtn6", false);
  1118. ManaReso.SetActive("D_Begin", true);
  1119. ManaReso.SetActive("D_DescB", true);
  1120. List<int> idList = new List<int>() {1, 2, 4, 5, 7, 8};
  1121. FlowerDic = new Dictionary<int, Flower>();
  1122. Flower flower;
  1123. if (Award.FlowerLock)
  1124. {
  1125. for (int i = 0; i < idList.Count; i++)
  1126. {
  1127. while (true)
  1128. {
  1129. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  1130. if (flowerInfo.Unlock)
  1131. {
  1132. flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
  1133. IdleList.Add(flower);
  1134. FlowerDic.Add(idList[i], flower);
  1135. break;
  1136. }
  1137. }
  1138. }
  1139. }
  1140. else
  1141. {
  1142. int special = idList.Random(1, true, true)[0];
  1143. flower = ManaReso.GetFlower(ManaGarden.FlowerInfoDic[Award.FlowerID], ManaReso.Get("SlotMini" + special));
  1144. IdleList.Add(flower);
  1145. FlowerDic.Add(special, flower);
  1146. for (int i = 0; i < idList.Count; i++)
  1147. {
  1148. while (true)
  1149. {
  1150. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  1151. if (flowerInfo.Unlock)
  1152. {
  1153. flower = ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + idList[i]));
  1154. IdleList.Add(flower);
  1155. FlowerDic.Add(idList[i], flower);
  1156. break;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. for (int i = 0; i < IdleList.Count; i++)
  1162. {
  1163. IdleList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true);
  1164. }
  1165. }
  1166. public static void GameEnterC()
  1167. {
  1168. D_Operate3.SetActive(true);
  1169. ManaReso.SetActive("D_Begin", true);
  1170. ManaReso.SetActive("D_DescB", true);
  1171. ManaReso.SetActive("D_FlowerBtn7", false);
  1172. ManaReso.SetActive("D_FlowerBtn8", false);
  1173. ManaReso.SetActive("D_FlowerBtn9", false);
  1174. D_Begin.SetParent(D_Operate3);
  1175. D_Timer.SetParent(D_Status3);
  1176. D_Grid.SetParent(D_Status3);
  1177. PrepareLab.SetParent(ManaReso.Get("D_PrepareLayout3"));
  1178. RoundResetC(true);
  1179. }
  1180. public static void GameBegin()
  1181. {
  1182. Game = true;
  1183. MiniGameIndex++;
  1184. Score = 0;
  1185. OpTimer = OpTime;
  1186. FadeTimer = FadeTime;
  1187. GoldTimer = Random.Range(3f, 6f);
  1188. GameTimer = 0;
  1189. NewOpTime = OpTime;
  1190. NewFadeTime = FadeTime;
  1191. DiamondTimer = Random.Range(0f, GameTime - 5);
  1192. if (GameA)
  1193. {
  1194. for (int i = 0; i < IdleList.Count; i++)
  1195. {
  1196. IdleList[i].GameBegin();
  1197. }
  1198. }
  1199. if (GameB)
  1200. {
  1201. RoundResetB();
  1202. }
  1203. if (GameC)
  1204. {
  1205. RoundBeginC(true);
  1206. }
  1207. if (Random.Range(5, 9) <= MiniGameIndex)
  1208. {
  1209. MiniGameIndex = 0;
  1210. DropDiamond = true;
  1211. }
  1212. else
  1213. {
  1214. if (Random.Range(0, 1f) <= 0.01f)
  1215. {
  1216. DropDiamond = true;
  1217. }
  1218. else
  1219. {
  1220. DropDiamond = false;
  1221. }
  1222. }
  1223. }
  1224. public static void GamePrepare()
  1225. {
  1226. Prepare = true;
  1227. PrepareTimer = 3;
  1228. ManaReso.Get("D_Begin").SetActive(false);
  1229. ManaReso.Get("D_DescA").SetActive(false);
  1230. ManaReso.Get("D_DescB").SetActive(false);
  1231. ManaReso.Get("D_DescC").SetActive(false);
  1232. if (GameA)
  1233. {
  1234. ManaReso.Get("D_Rip1").SetActive(true);
  1235. ManaReso.Get("D_Water1").SetActive(true);
  1236. ManaReso.Get("D_Fertilize1").SetActive(true);
  1237. }
  1238. if (GameB)
  1239. {
  1240. ManaReso.Get("D_Mask").TweenForGra();
  1241. ManaReso.SetActive("D_FlowerBtn1", true);
  1242. ManaReso.SetActive("D_FlowerBtn2", true);
  1243. ManaReso.SetActive("D_FlowerBtn3", true);
  1244. ManaReso.SetActive("D_FlowerBtn4", true);
  1245. ManaReso.SetActive("D_FlowerBtn5", true);
  1246. ManaReso.SetActive("D_FlowerBtn6", true);
  1247. ManaReso.SetSprite("D_FlowerIcon1", FlowerDic[1].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1248. ManaReso.SetSprite("D_FlowerIcon2", FlowerDic[2].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1249. ManaReso.SetSprite("D_FlowerIcon3", FlowerDic[4].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1250. ManaReso.SetSprite("D_FlowerIcon4", FlowerDic[5].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1251. ManaReso.SetSprite("D_FlowerIcon5", FlowerDic[7].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1252. ManaReso.SetSprite("D_FlowerIcon6", FlowerDic[8].FlowerInfo.Icon).Resize(true, 1f, 1f);
  1253. }
  1254. PrepareLab.StreamForScale();
  1255. }
  1256. public static void RoundEndB()
  1257. {
  1258. ManaReso.Get("D_Mask").TweenForGra();
  1259. }
  1260. public static void RoundResetB()
  1261. {
  1262. for (int i = 0; i < FadeList.Count; i++)
  1263. {
  1264. IdleList.Add(FadeList[i]);
  1265. }
  1266. NewFadeTime -= NewFadeTime * 0.3f;
  1267. FadeTimer = NewFadeTime;
  1268. FadeList = new List<Flower>();
  1269. IndexList = new List<int>();
  1270. List<int> randomList = new List<int>() { 1, 2, 4, 5, 7, 8 };
  1271. for (int i = 0; i < randomList.Count; i++)
  1272. {
  1273. IndexList.Add(randomList.Random(1, true, true)[0]);
  1274. i--;
  1275. }
  1276. ResetOprerate();
  1277. }
  1278. public static void RoundBeginB()
  1279. {
  1280. ManaReso.Get("D_Mask").TweenBacGra();
  1281. if (ManaTutorial.TutorialB)
  1282. {
  1283. ManaTutorial.EnterB1();
  1284. }
  1285. }
  1286. public static void RoundEndC()
  1287. {
  1288. for (int i = 0; i < IdleList.Count; i++)
  1289. {
  1290. IdleList[i].FlowerIcon.TweenForSr();
  1291. }
  1292. ManaReso.Get("D_FlowerBtn7").TweenBacCG();
  1293. ManaReso.Get("D_FlowerBtn8").TweenBacCG();
  1294. ManaReso.Get("D_FlowerBtn9").TweenBacCG();
  1295. Auxiliary.Instance.DelayCall
  1296. (
  1297. () =>
  1298. {
  1299. if (Game)
  1300. {
  1301. RoundResetC();
  1302. RoundBeginC();
  1303. }
  1304. },
  1305. 1.5f
  1306. );
  1307. }
  1308. public static void RoundResetC(bool firstRound = false)
  1309. {
  1310. ExtList.ForEach(IdleList, flower => { flower.Retrieve(); });
  1311. IdleList = new List<Flower>();
  1312. FlowerIDListC = new List<int>();
  1313. List<int> slotList = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  1314. FlowerInfo flowerInfo;
  1315. if (firstRound && !Award.FlowerLock)
  1316. {
  1317. flowerInfo = ManaGarden.FlowerInfoDic[Award.FlowerID];
  1318. }
  1319. else
  1320. {
  1321. flowerInfo = ManaGarden.FlowerInfoDic.Random(false, flowerIndo => { return flowerIndo.Unlock; });
  1322. }
  1323. FlowerIDListC.Add(flowerInfo.ID_);
  1324. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + slotList.Random(1, true, true)[0])));
  1325. while (slotList.Count > 0)
  1326. {
  1327. flowerInfo = ManaGarden.FlowerInfoDic.Random(false, info => { return info.Unlock && info.ID_ != FlowerIDListC[0]; });
  1328. if (slotList.Count == 1)
  1329. {
  1330. if (!FlowerIDListC.Contains(flowerInfo.ID_))
  1331. {
  1332. continue;
  1333. }
  1334. }
  1335. else
  1336. {
  1337. FlowerIDListC.UniqueAdd(flowerInfo.ID_);
  1338. }
  1339. int amt = Mathf.Min(Random.Range(2, 9), slotList.Count);
  1340. for (int i = 0; i < amt; i++)
  1341. {
  1342. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + slotList.Random(1, true, true)[0])));
  1343. }
  1344. }
  1345. for (int i = 0; i < IdleList.Count; i++)
  1346. {
  1347. IdleList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true);
  1348. IdleList[i].FlowerIcon.GetTweenSr().InDestination = true;
  1349. }
  1350. List<int> idList = new List<int>()
  1351. {
  1352. FlowerIDListC[0],
  1353. };
  1354. if (FlowerIDListC.Count == 2)
  1355. {
  1356. idList.Add(FlowerIDListC[1]);
  1357. idList.Add(FlowerIDListC[1]);
  1358. }
  1359. else if (FlowerIDListC.Count > 2)
  1360. {
  1361. idList.AddRange(FlowerIDListC.Random(2, true, false, id => { return id != idList[0]; }));
  1362. }
  1363. else
  1364. {
  1365. throw new Exception();
  1366. }
  1367. idList = idList.Disturb();
  1368. ManaReso.SetSprite("D_FlowerIcon7", ManaGarden.FlowerInfoDic[idList[0]].Icon).Resize(true, 1f, 1f);
  1369. ManaReso.SetSprite("D_FlowerIcon8", ManaGarden.FlowerInfoDic[idList[1]].Icon).Resize(true, 1f, 1f);
  1370. ManaReso.SetSprite("D_FlowerIcon9", ManaGarden.FlowerInfoDic[idList[2]].Icon).Resize(true, 1f, 1f);
  1371. ManaReso.SetButtonEvent("D_FlowerBtn7", () => { OperateC(idList[0], 7); });
  1372. ManaReso.SetButtonEvent("D_FlowerBtn8", () => { OperateC(idList[1], 8); });
  1373. ManaReso.SetButtonEvent("D_FlowerBtn9", () => { OperateC(idList[2], 9); });
  1374. }
  1375. public static void RoundBeginC(bool firstRound = false)
  1376. {
  1377. if (firstRound && !Award.FlowerLock)
  1378. {
  1379. IdleList[0].NewFlowerEffect.SetActive(true);
  1380. }
  1381. ManaReso.Get("D_FlowerBtn7").TweenReForCG();
  1382. ManaReso.Get("D_FlowerBtn8").TweenReForCG();
  1383. ManaReso.Get("D_FlowerBtn9").TweenReForCG();
  1384. for (int i = 0; i < IdleList.Count; i++)
  1385. {
  1386. IdleList[i].FlowerIcon.TweenBacSr();
  1387. }
  1388. }
  1389. public static int IndexMap(int slotIndex)
  1390. {
  1391. if (slotIndex == 1)
  1392. {
  1393. return 1;
  1394. }
  1395. else if (slotIndex == 2)
  1396. {
  1397. return 2;
  1398. }
  1399. else if (slotIndex == 4)
  1400. {
  1401. return 3;
  1402. }
  1403. else if (slotIndex == 5)
  1404. {
  1405. return 4;
  1406. }
  1407. else if (slotIndex == 7)
  1408. {
  1409. return 5;
  1410. }
  1411. else if (slotIndex == 8)
  1412. {
  1413. return 6;
  1414. }
  1415. else
  1416. {
  1417. throw new Exception();
  1418. }
  1419. }
  1420. public void OnApplicationPause(bool pause)
  1421. {
  1422. if (!pause)
  1423. {
  1424. if (!ManaTutorial.TutorialA)
  1425. {
  1426. if (Game || Prepare)
  1427. {
  1428. ManaReso.Get<Button>("D_Quit").onClick.Invoke();
  1429. }
  1430. }
  1431. }
  1432. }
  1433. }