ManaMiniGame.cs 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907
  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.AddCoin(Coin, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.MiniGame);
  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.AddDiamond(Diamond, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.MiniGame);
  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.AddDiamond(Diamond, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.MiniGame);
  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. StaticsManager.GetInstance().UseItem(StaticsManager.ItemID.开始小游戏, StaticsManager.ItemType.小游戏, "1", StaticsManager.ConsumeModule.None);
  1201. if (GameA)
  1202. {
  1203. for (int i = 0; i < IdleList.Count; i++)
  1204. {
  1205. IdleList[i].GameBegin();
  1206. }
  1207. }
  1208. if (GameB)
  1209. {
  1210. RoundResetB();
  1211. }
  1212. if (GameC)
  1213. {
  1214. RoundBeginC(true);
  1215. }
  1216. if (Random.Range(5, 9) <= MiniGameIndex)
  1217. {
  1218. MiniGameIndex = 0;
  1219. DropDiamond = true;
  1220. }
  1221. else
  1222. {
  1223. if (Random.Range(0, 1f) <= 0.01f)
  1224. {
  1225. DropDiamond = true;
  1226. }
  1227. else
  1228. {
  1229. DropDiamond = false;
  1230. }
  1231. }
  1232. }
  1233. public static void GamePrepare()
  1234. {
  1235. Prepare = true;
  1236. PrepareTimer = 3;
  1237. ManaReso.Get("D_Begin").SetActive(false);
  1238. ManaReso.Get("D_DescA").SetActive(false);
  1239. ManaReso.Get("D_DescB").SetActive(false);
  1240. ManaReso.Get("D_DescC").SetActive(false);
  1241. if (GameA)
  1242. {
  1243. ManaReso.Get("D_Rip1").SetActive(true);
  1244. ManaReso.Get("D_Water1").SetActive(true);
  1245. ManaReso.Get("D_Fertilize1").SetActive(true);
  1246. }
  1247. if (GameB)
  1248. {
  1249. ManaReso.Get("D_Mask").TweenForGra();
  1250. ManaReso.SetActive("D_FlowerBtn1", true);
  1251. ManaReso.SetActive("D_FlowerBtn2", true);
  1252. ManaReso.SetActive("D_FlowerBtn3", true);
  1253. ManaReso.SetActive("D_FlowerBtn4", true);
  1254. ManaReso.SetActive("D_FlowerBtn5", true);
  1255. ManaReso.SetActive("D_FlowerBtn6", true);
  1256. ManaReso.SetSprite("D_FlowerIcon1", FlowerDic[1].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1257. ManaReso.SetSprite("D_FlowerIcon2", FlowerDic[2].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1258. ManaReso.SetSprite("D_FlowerIcon3", FlowerDic[4].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1259. ManaReso.SetSprite("D_FlowerIcon4", FlowerDic[5].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1260. ManaReso.SetSprite("D_FlowerIcon5", FlowerDic[7].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1261. ManaReso.SetSprite("D_FlowerIcon6", FlowerDic[8].FlowerInfo.Icon).Resize(true, 0.85f, 0.85f);
  1262. }
  1263. PrepareLab.StreamForScale();
  1264. }
  1265. public static void RoundEndB()
  1266. {
  1267. ManaReso.Get("D_Mask").TweenForGra();
  1268. }
  1269. public static void RoundResetB()
  1270. {
  1271. for (int i = 0; i < FadeList.Count; i++)
  1272. {
  1273. IdleList.Add(FadeList[i]);
  1274. }
  1275. NewFadeTime -= NewFadeTime * 0.3f;
  1276. FadeTimer = NewFadeTime;
  1277. FadeList = new List<Flower>();
  1278. IndexList = new List<int>();
  1279. List<int> randomList = new List<int>() { 1, 2, 4, 5, 7, 8 };
  1280. for (int i = 0; i < randomList.Count; i++)
  1281. {
  1282. IndexList.Add(randomList.Random(1, true, true)[0]);
  1283. i--;
  1284. }
  1285. ResetOprerate();
  1286. }
  1287. public static void RoundBeginB()
  1288. {
  1289. ManaReso.Get("D_Mask").TweenBacGra();
  1290. if (ManaTutorial.TutorialB)
  1291. {
  1292. ManaTutorial.EnterB1();
  1293. }
  1294. }
  1295. public static void RoundEndC()
  1296. {
  1297. if (IdleList[0].ID == Award.FlowerID)
  1298. {
  1299. IdleList[0].StopNewFlowerEffec();
  1300. }
  1301. for (int i = 0; i < IdleList.Count; i++)
  1302. {
  1303. IdleList[i].FlowerIcon.TweenForSr();
  1304. }
  1305. ManaReso.Get("D_FlowerBtn7").TweenBacCG();
  1306. ManaReso.Get("D_FlowerBtn8").TweenBacCG();
  1307. ManaReso.Get("D_FlowerBtn9").TweenBacCG();
  1308. Auxiliary.Instance.DelayCall
  1309. (
  1310. () =>
  1311. {
  1312. if (Game)
  1313. {
  1314. RoundResetC();
  1315. RoundBeginC();
  1316. }
  1317. },
  1318. 1.5f
  1319. );
  1320. }
  1321. public static void RoundResetC(bool firstRound = false)
  1322. {
  1323. ExtList.ForEach(IdleList, flower => { flower.Retrieve(); });
  1324. IdleList = new List<Flower>();
  1325. FlowerIDListC = new List<int>();
  1326. List<int> slotList = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  1327. FlowerInfo flowerInfo;
  1328. if (firstRound && !Award.FlowerLock)
  1329. {
  1330. flowerInfo = ManaGarden.FlowerInfoDic[Award.FlowerID];
  1331. }
  1332. else
  1333. {
  1334. flowerInfo = ManaGarden.FlowerInfoDic.Random(false, flowerIndo => { return flowerIndo.Unlock; });
  1335. }
  1336. FlowerIDListC.Add(flowerInfo.ID_);
  1337. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + slotList.Random(1, true, true)[0])));
  1338. while (slotList.Count > 0)
  1339. {
  1340. flowerInfo = ManaGarden.FlowerInfoDic.Random(false, info => { return info.Unlock && info.ID_ != FlowerIDListC[0]; });
  1341. if (slotList.Count == 1)
  1342. {
  1343. if (!FlowerIDListC.Contains(flowerInfo.ID_))
  1344. {
  1345. continue;
  1346. }
  1347. }
  1348. else
  1349. {
  1350. FlowerIDListC.UniqueAdd(flowerInfo.ID_);
  1351. }
  1352. int amt = Mathf.Min(Random.Range(2, 9), slotList.Count);
  1353. for (int i = 0; i < amt; i++)
  1354. {
  1355. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + slotList.Random(1, true, true)[0])));
  1356. }
  1357. }
  1358. for (int i = 0; i < IdleList.Count; i++)
  1359. {
  1360. IdleList[i].FlowerIcon.CreateTweenSr(1, 0, 0.25f, true, false, Curve.EaseOutQuad, false, true);
  1361. IdleList[i].FlowerIcon.GetTweenSr().InDestination = true;
  1362. }
  1363. List<int> idList = new List<int>()
  1364. {
  1365. FlowerIDListC[0],
  1366. };
  1367. if (FlowerIDListC.Count == 2)
  1368. {
  1369. idList.Add(FlowerIDListC[1]);
  1370. idList.Add(FlowerIDListC[1]);
  1371. idList.RemoveAt(0);
  1372. idList.Insert(Random.Range(0, 3), FlowerIDListC[0]);
  1373. }
  1374. else if (FlowerIDListC.Count > 2)
  1375. {
  1376. idList.AddRange(FlowerIDListC.Random(2, true, false, id => { return id != idList[0]; }));
  1377. idList = idList.Disturb();
  1378. }
  1379. else
  1380. {
  1381. throw new Exception();
  1382. }
  1383. ManaReso.SetSprite("D_FlowerIcon7", ManaGarden.FlowerInfoDic[idList[0]].Icon).Resize(true, 0.85f, 0.85f);
  1384. ManaReso.SetSprite("D_FlowerIcon8", ManaGarden.FlowerInfoDic[idList[1]].Icon).Resize(true, 0.85f, 0.85f);
  1385. ManaReso.SetSprite("D_FlowerIcon9", ManaGarden.FlowerInfoDic[idList[2]].Icon).Resize(true, 0.85f, 0.85f);
  1386. for (int i = 0; i < idList.Count; i++)
  1387. {
  1388. int id = idList[i];
  1389. int index = i;
  1390. if (firstRound && ManaTutorial.TutorialE && id == FlowerIDListC[0])
  1391. {
  1392. CorrectBtnC = ManaReso.Get("D_FlowerBtn" + (7 + i));
  1393. ManaReso.SetButtonEvent("D_FlowerBtn" + (7 + i), () => { OperateC(id, (7 + index)); ManaTutorial.EndE(); });
  1394. }
  1395. else
  1396. {
  1397. ManaReso.SetButtonEvent("D_FlowerBtn" + (7 + i), () => { OperateC(id, (7 + index)); });
  1398. }
  1399. }
  1400. }
  1401. public static void RoundBeginC(bool firstRound = false)
  1402. {
  1403. if (firstRound && !Award.FlowerLock)
  1404. {
  1405. IdleList[0].PlayNewFlowerEffec();
  1406. }
  1407. ManaReso.Get("D_FlowerBtn7").TweenReForCG();
  1408. ManaReso.Get("D_FlowerBtn8").TweenReForCG();
  1409. ManaReso.Get("D_FlowerBtn9").TweenReForCG();
  1410. for (int i = 0; i < IdleList.Count; i++)
  1411. {
  1412. IdleList[i].FlowerIcon.TweenBacSr();
  1413. }
  1414. if (firstRound && ManaTutorial.TutorialE)
  1415. {
  1416. ManaTutorial.EnterE2(CorrectBtnC.GetChild(1), CorrectBtnC);
  1417. }
  1418. }
  1419. public static int IndexMap(int slotIndex)
  1420. {
  1421. if (slotIndex == 1)
  1422. {
  1423. return 1;
  1424. }
  1425. else if (slotIndex == 2)
  1426. {
  1427. return 2;
  1428. }
  1429. else if (slotIndex == 4)
  1430. {
  1431. return 3;
  1432. }
  1433. else if (slotIndex == 5)
  1434. {
  1435. return 4;
  1436. }
  1437. else if (slotIndex == 7)
  1438. {
  1439. return 5;
  1440. }
  1441. else if (slotIndex == 8)
  1442. {
  1443. return 6;
  1444. }
  1445. else
  1446. {
  1447. throw new Exception();
  1448. }
  1449. }
  1450. public void OnApplicationPause(bool pause)
  1451. {
  1452. if (!pause)
  1453. {
  1454. if (!ManaTutorial.TutorialA)
  1455. {
  1456. if (Game || Prepare)
  1457. {
  1458. ManaReso.Get<Button>("D_Quit").onClick.Invoke();
  1459. }
  1460. }
  1461. }
  1462. }
  1463. }