ManaMiniGame.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Serialization;
  4. using System;
  5. using System.Xml;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using Random = UnityEngine.Random;
  9. public class Award
  10. {
  11. #region 变量
  12. public static int BonusCoin;
  13. public static int BonusDiamond;
  14. public int DiamondMin;
  15. public int DiamondMax;
  16. public string CoinFml;
  17. public string FlowerFml;
  18. public string DiamondFml;
  19. public List<float> Odds = new List<float>();
  20. public List<float> Standard = new List<float>();
  21. #endregion
  22. public Award(XmlAttributeCollection attribute)
  23. {
  24. CoinFml = attribute[1].Value;
  25. FlowerFml = attribute[4].Value;
  26. DiamondFml = attribute[3].Value;
  27. string[] strings = attribute[2].Value.Split(',');
  28. DiamondMin = int.Parse(strings[0]);
  29. DiamondMax = int.Parse(strings[1]);
  30. strings = attribute[5].Value.Split(',');
  31. Odds = new List<float>()
  32. {
  33. float.Parse(strings[0]),
  34. float.Parse(strings[1]),
  35. float.Parse(strings[2]),
  36. };
  37. strings = attribute[6].Value.Split(',');
  38. Standard = new List<float>()
  39. {
  40. float.Parse(strings[0]),
  41. float.Parse(strings[1]),
  42. float.Parse(strings[2]),
  43. };
  44. }
  45. public void GetAward(int score)
  46. {
  47. #region 获得奖励
  48. #region Reset
  49. ManaReso.Get("Da_Info").TweenForCG();
  50. ManaReso.SetActive("Da_Lab", false);
  51. ManaReso.SetActive("Da_Quit", false);
  52. ManaReso.SetActive("Da_Cancel", false);
  53. ManaReso.SetActive("Da_VGroup", false);
  54. ManaReso.SetActive("Da_HGroup", false);
  55. ManaReso.SetActive("Da_ScoreTit", false);
  56. ManaReso.SetActive("Da_GetAward", false);
  57. ManaReso.SetActive("Da_FlowerGroup", false);
  58. ManaReso.SetActive("Da_DiamondGroup", false);
  59. bool flowerFlag = false;
  60. bool diamondFlag = false;
  61. #endregion
  62. #region Coin
  63. int coin = (int)Auxiliary.FmlParse(CoinFml, "s", score.ToString());
  64. coin = Mathf.FloorToInt(coin * (1 + ManaData.SkillPlus)) + BonusCoin;
  65. ManaData.Coin += coin;
  66. #endregion
  67. #region Diamond
  68. int diamond = 0;
  69. float diamondRate = (float)Auxiliary.FmlParse(DiamondFml, "l", Mathf.Clamp(ManaData.Level, 1, 1000).ToString());
  70. if (Random.Range(0, 1f) <= diamondRate)
  71. {
  72. diamondFlag = true;
  73. diamond = Mathf.FloorToInt(Mathf.Lerp(DiamondMin, DiamondMax, Random.Range(0, 1f)) + BonusDiamond);
  74. ManaData.Diamond += diamond;
  75. ManaReso.SetActive("Da_Diamond", true);
  76. }
  77. else
  78. {
  79. if (BonusDiamond > 0)
  80. {
  81. diamondFlag = true;
  82. ManaData.Diamond += BonusDiamond;
  83. ManaReso.SetActive("Da_Diamond", true);
  84. }
  85. }
  86. #endregion
  87. #region Rate
  88. int rate;
  89. if (score < Standard[1])
  90. {
  91. rate = 0;
  92. }
  93. else if (score < Standard[2])
  94. {
  95. rate = 1;
  96. }
  97. else
  98. {
  99. rate = 2;
  100. }
  101. #endregion
  102. #region Flower
  103. if (ManaTutorial.TutorialA)
  104. {
  105. flowerFlag = true;
  106. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic[1];
  107. Vector2 newSize = flowerInfo.Icon.rect.size;
  108. newSize.x *= 0.2f;
  109. newSize.y *= 0.2f;
  110. ManaReso.Get<Image>("Da_FlowerIcon").sprite = flowerInfo.Icon;
  111. ManaReso.Get<Image>("Da_FlowerIcon").rectTransform.sizeDelta = newSize;
  112. ManaReso.SetText("Da_FlowerLab", Language.GetStr("FlowerName", "Flower" + flowerInfo.ID_));
  113. }
  114. else
  115. {
  116. float flowerRate = (float)Auxiliary.FmlParse(DiamondFml, "l", ManaData.Level.ToString(), "f", ManaGarden.MyFlower.ToString());
  117. if (Random.Range(0, 1f) <= flowerRate)
  118. {
  119. if (Random.Range(0, 1f) <= Odds[rate])
  120. {
  121. while (true)
  122. {
  123. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  124. if (flowerInfo.Unlock)
  125. {
  126. flowerFlag = true;
  127. Vector2 newSize = flowerInfo.Icon.rect.size;
  128. newSize.x *= 0.2f;
  129. newSize.y *= 0.2f;
  130. ManaReso.Get<Image>("Da_FlowerIcon").sprite = flowerInfo.Icon;
  131. ManaReso.Get<Image>("Da_FlowerIcon").rectTransform.sizeDelta = newSize;
  132. ManaReso.SetText("Da_FlowerLab", Language.GetStr("FlowerName", "Flower" + flowerInfo.ID_));
  133. break;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. BonusCoin = 0;
  140. BonusDiamond = 0;
  141. #endregion
  142. #endregion
  143. #region 构造动画
  144. #region Reset
  145. ManaReso.SetText("Da_CoinLab", "");
  146. ManaReso.SetText("Da_ScoreLab", "");
  147. ManaReso.SetText("Da_DiamondLab", "");
  148. ManaReso.SetActive("Da_VGroup", true);
  149. ManaReso.SetActive("Da_CoinGroup", true);
  150. ManaReso.SetActive("Da_FlowerGroup", true);
  151. if (diamondFlag)
  152. {
  153. ManaReso.SetActive("Da_DiamondGroup", true);
  154. }
  155. Auxiliary.Instance.DelayCall
  156. (
  157. () =>
  158. {
  159. ManaReso.SetActive("Da_FlowerGroup", false);
  160. ManaReso.SetActive("Da_DiamondGroup", false);
  161. ManaReso.Get<VerticalLayoutGroup>("Da_VGroup").enabled = false;
  162. },
  163. 1
  164. );
  165. float timeCoin = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(coin / 15f));
  166. float timeScore = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(score/50f));
  167. float timeDiamond = Mathf.Lerp(0, 1.5f, Mathf.Clamp01(diamond / 15f));
  168. float time = Mathf.Max(timeCoin, timeDiamond);
  169. ManaReso.Get("Da_CoinLab").CreateTweenNumber(0, coin, time, true, true, Curve.EaseOutQuad);
  170. ManaReso.Get("Da_ScoreLab").CreateTweenNumber(0, score, timeScore, true, true, Curve.EaseOutQuad);
  171. ManaReso.Get("Da_DiamondLab").CreateTweenNumber(0, diamond, time, true, true, Curve.EaseOutQuad);
  172. #endregion
  173. #region 五角星
  174. Tween tween = ManaReso.Get("Da_Info").GetTweenCG();
  175. tween.OnForwardFinish = () =>
  176. {
  177. ManaReso.Get("Da_Star1").TweenForScale();
  178. ManaReso.SetActive("Da_HGroup", true);
  179. };
  180. tween = ManaReso.Get("Da_ScoreTit").GetTweenText();
  181. tween.InOrigin = true;
  182. tween = ManaReso.Get("Da_Star3").GetTweenScale();
  183. tween.InOrigin = true;
  184. tween = ManaReso.Get("Da_Star2").GetTweenScale();
  185. tween.InOrigin = true;
  186. tween = ManaReso.Get("Da_Star1").GetTweenScale();
  187. tween.InOrigin = true;
  188. if (rate == 0)
  189. {
  190. ManaReso.SetActive("Da_Star2", false);
  191. ManaReso.SetActive("Da_Star3", false);
  192. }
  193. else if (rate == 1)
  194. {
  195. ManaReso.SetActive("Da_Star2", true);
  196. ManaReso.SetActive("Da_Star3", false);
  197. tween = ManaReso.Get("Da_Star1").GetTweenScale();
  198. tween.AddEventOnetime
  199. (
  200. EventType.ForwardFinish,
  201. () =>
  202. {
  203. ManaReso.Get("Da_Star2").TweenForScale();
  204. }
  205. );
  206. tween = ManaReso.Get("Da_Star2").GetTweenScale();
  207. }
  208. else if (rate == 2)
  209. {
  210. ManaReso.SetActive("Da_Star2", true);
  211. ManaReso.SetActive("Da_Star3", true);
  212. tween = ManaReso.Get("Da_Star1").GetTweenScale();
  213. tween.AddEventOnetime
  214. (
  215. EventType.ForwardFinish,
  216. () =>
  217. {
  218. ManaReso.Get("Da_Star2").TweenForScale();
  219. }
  220. );
  221. tween = ManaReso.Get("Da_Star2").GetTweenScale();
  222. tween.AddEventOnetime
  223. (
  224. EventType.ForwardFinish,
  225. () =>
  226. {
  227. ManaReso.Get("Da_Star3").TweenForScale();
  228. }
  229. );
  230. tween = ManaReso.Get("Da_Star3").GetTweenScale();
  231. }
  232. #endregion
  233. #region 得分
  234. tween.AddEventOnetime
  235. (
  236. EventType.ForwardFinish,
  237. () =>
  238. {
  239. ManaReso.Get("Da_ScoreTit").TweenForText();
  240. }
  241. );
  242. tween = ManaReso.Get("Da_ScoreTit").GetTweenText();
  243. tween.AddEventOnetime
  244. (
  245. EventType.ForwardFinish,
  246. () =>
  247. {
  248. ManaReso.Get("Da_ScoreLab").TweenForNumber();
  249. }
  250. );
  251. #endregion
  252. #region 金币钻石
  253. tween = ManaReso.Get("Da_ScoreLab").GetTweenNumber();
  254. tween.AddEventOnetime
  255. (
  256. EventType.ForwardFinish,
  257. () =>
  258. {
  259. ManaReso.Get<CanvasGroup>("Da_VGroup").alpha = 1;
  260. ManaReso.SetActive("Da_VGroup", true);
  261. ManaReso.Get("Da_CoinGroup").TweenForScale();
  262. if (diamondFlag)
  263. {
  264. ManaReso.Get("Da_DiamondGroup").TweenForScale();
  265. }
  266. }
  267. );
  268. tween = ManaReso.Get("Da_CoinGroup").GetTweenScale();
  269. tween.AddEventOnetime
  270. (
  271. EventType.ForwardFinish,
  272. () =>
  273. {
  274. ManaReso.Get("Da_CoinLab").TweenForNumber();
  275. }
  276. );
  277. if (diamondFlag)
  278. {
  279. tween = ManaReso.Get("Da_DiamondGroup").GetTweenScale();
  280. tween.AddEventOnetime
  281. (
  282. EventType.ForwardFinish,
  283. () =>
  284. {
  285. ManaReso.Get("Da_DiamondLab").TweenForNumber();
  286. }
  287. );
  288. }
  289. #endregion
  290. #region 花
  291. if (flowerFlag)
  292. {
  293. tween = ManaReso.Get("Da_CoinLab").GetTweenNumber();
  294. tween.AddEventOnetime
  295. (
  296. EventType.ForwardFinish,
  297. () =>
  298. {
  299. ManaReso.Get("Da_FlowerGroup").TweenForScale();
  300. ManaReso.SetActive("Da_FlowerGroup", true);
  301. }
  302. );
  303. }
  304. #endregion
  305. #region 按钮
  306. if (flowerFlag)
  307. {
  308. tween = ManaReso.Get("Da_FlowerGroup").GetTweenScale();
  309. tween.AddEventOnetime
  310. (
  311. EventType.ForwardFinish,
  312. () =>
  313. {
  314. ManaReso.Get("Da_GetAward").TweenForCG();
  315. }
  316. );
  317. }
  318. else
  319. {
  320. tween = ManaReso.Get("Da_CoinLab").GetTweenNumber();
  321. tween.AddEventOnetime
  322. (
  323. EventType.ForwardFinish,
  324. () =>
  325. {
  326. ManaReso.Get("Da_GetAward").TweenForCG();
  327. }
  328. );
  329. }
  330. if (ManaTutorial.TutorialA)
  331. {
  332. tween = ManaReso.Get("Da_GetAward").GetTweenCG();
  333. tween.AddEventOnetime
  334. (
  335. EventType.ForwardFinish,
  336. () =>
  337. {
  338. Tutorial.HightScreen(ManaReso.Get("Da_GetAwardArrow0"), ManaReso.Get("Da_GetAwardArrow1"), ManaReso.Get("Da_GetAward"));
  339. }
  340. );
  341. }
  342. #endregion
  343. #endregion
  344. }
  345. }
  346. public class ManaMiniGame : Regist
  347. {
  348. #region 变量
  349. public static int Score
  350. {
  351. get { return _Score; }
  352. set
  353. {
  354. _Score = value;
  355. ManaReso.SetText("D_ScoreLab", _Score.ToString());
  356. }
  357. }
  358. public static bool Game
  359. {
  360. get { return _Game; }
  361. set
  362. {
  363. _Game = value;
  364. if (_Game)
  365. {
  366. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
  367. }
  368. else
  369. {
  370. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab0"));
  371. }
  372. }
  373. }
  374. public static bool Pause
  375. {
  376. get { return _Pause; }
  377. set
  378. {
  379. _Pause = value;
  380. if (Game)
  381. {
  382. if (_Pause)
  383. {
  384. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab2"));
  385. }
  386. else
  387. {
  388. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
  389. }
  390. }
  391. }
  392. }
  393. public static bool Panalty
  394. {
  395. get { return _Panalty; }
  396. set
  397. {
  398. _Panalty = value;
  399. if (_Panalty)
  400. {
  401. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab3"));
  402. }
  403. else
  404. {
  405. ManaReso.SetText("D_StatusLab", Language.GetStr("UI", "D_StatusLab1"));
  406. }
  407. }
  408. }
  409. public static bool Prepare
  410. {
  411. get { return _Prepare; }
  412. set
  413. {
  414. _Prepare = value;
  415. if (Prepare)
  416. {
  417. PrepareTimer = 3;
  418. ManaReso.Get("D_Rip1").SetActive(true);
  419. ManaReso.Get("D_Water1").SetActive(true);
  420. ManaReso.Get("D_Fertilize1").SetActive(true);
  421. ManaReso.Get("D_Begin").SetActive(false);
  422. PrepareLab.SetActive(true);
  423. }
  424. }
  425. }
  426. public static float GameTimer
  427. {
  428. get { return _GameTimer; }
  429. set
  430. {
  431. _GameTimer = value;
  432. TimerLab.text = _GameTimer.ToString("0.0");
  433. TimerBk.fillAmount = _GameTimer / GameTime;
  434. }
  435. }
  436. public static float PrepareTimer
  437. {
  438. get { return _PrepareTimer; }
  439. set
  440. {
  441. _PrepareTimer = value;
  442. PrepareLab.text = Mathf.CeilToInt(_PrepareTimer).ToString();
  443. }
  444. }
  445. private static int _Score;
  446. private static bool _Game;
  447. private static bool _Pause;
  448. private static bool _Panalty;
  449. private static bool _Prepare;
  450. private static float _GameTimer;
  451. private static float _PrepareTimer;
  452. public static Text BtnLab;
  453. public static Text TimerLab;
  454. public static Text PrepareLab;
  455. public static Image TimerBk;
  456. public static Award Award;
  457. public static List<Flower> OpList = new List<Flower>();
  458. public static List<Flower> IdleList = new List<Flower>();
  459. public static List<DropGold> GoldList = new List<DropGold>();
  460. public static List<DropDiamond> DiamondList = new List<DropDiamond>();
  461. public static int MiniGameIndex;
  462. public static bool TutorialValidA = true;
  463. public static bool DropDiamond;
  464. public static float OpTime = 1.5f;
  465. public static float OpTimer;
  466. public static float GoldTimer;
  467. public static float GameTime = 5;
  468. public static float PanaltyTime = 1;
  469. public static float PanaltyTimer;
  470. public static float DiamondTimer;
  471. #endregion
  472. private void FixedUpdate()
  473. {
  474. if (Game)
  475. {
  476. GameThread();
  477. }
  478. if (Prepare)
  479. {
  480. PrepareThread();
  481. }
  482. }
  483. private void GameThread()
  484. {
  485. if (Pause)
  486. {
  487. return;
  488. }
  489. GameTimer -= Time.fixedDeltaTime;
  490. if (GameTimer <= 0)
  491. {
  492. GameOver();
  493. return;
  494. }
  495. if (Panalty)
  496. {
  497. PanaltyTimer -= Time.fixedDeltaTime;
  498. if (PanaltyTimer <= 0)
  499. {
  500. Panalty = false;
  501. }
  502. }
  503. if (IdleList.Count > 0)
  504. {
  505. OpTimer -= Time.fixedDeltaTime;
  506. if (OpTimer <= 0)
  507. {
  508. OpTime -= OpTime * 0.03f;
  509. OpTimer = OpTime;
  510. CreateOperate();
  511. }
  512. }
  513. BonusThread();
  514. }
  515. private void BonusThread()
  516. {
  517. if (Pause)
  518. {
  519. return;
  520. }
  521. GoldTimer -= Time.fixedDeltaTime;
  522. if (GoldTimer < 0)
  523. {
  524. GoldTimer = Random.Range(3f, 6f);
  525. GoldList.Add(ManaReso.GetGold());
  526. }
  527. if (DropDiamond)
  528. {
  529. DiamondTimer -= Time.fixedDeltaTime;
  530. if (DiamondTimer < 0)
  531. {
  532. DropDiamond = false;
  533. DiamondList.Add(ManaReso.GetDiamond());
  534. }
  535. }
  536. }
  537. private void PrepareThread()
  538. {
  539. PrepareTimer -= Time.fixedDeltaTime;
  540. if (PrepareTimer <= 0)
  541. {
  542. Prepare = false;
  543. GameBegin();
  544. PrepareLab.text = Language.GetStr("UI", "D_PrepareLab");
  545. PrepareLab.TweenForGra();
  546. PrepareLab.TweenForText();
  547. }
  548. }
  549. private void CreateOperate()
  550. {
  551. if (ManaTutorial.TutorialA && TutorialValidA)
  552. {
  553. Pause = true;
  554. TutorialValidA = false;
  555. Flower flower = IdleList[4];
  556. flower.CreateOp(OpList.Count, OpType.Water);
  557. OpList.Add(flower);
  558. IdleList.Remove(flower);
  559. Tutorial.HightScreen(ManaReso.Get("D_WaterArrow0"), ManaReso.Get("D_WaterArrow1"), ManaReso.Get("D_Water1"));
  560. SceneMask.SetArea(OpList[0].OperateIcon.transform, 0.1f, 0.125f);
  561. ManaReso.AddButtonEventOnetime
  562. (
  563. "D_Water2",
  564. () =>
  565. {
  566. Pause = false;
  567. Tutorial.HightDisable();
  568. }
  569. );
  570. }
  571. else
  572. {
  573. Flower flower = IdleList[Random.Range(0, IdleList.Count)];
  574. flower.CreateOp(OpList.Count);
  575. OpList.Add(flower);
  576. IdleList.Remove(flower);
  577. }
  578. }
  579. public override void RegistValueA()
  580. {
  581. OpTimer = OpTime;
  582. GameTimer = GameTime;
  583. MiniGameIndex = Data.GetPlayerInt("MiniGameIndex");
  584. Award = new Award(Data.GetAwardConfig());
  585. PrepareLab.CreateTweenGra(1, 0, 0.25f, true, false, Curve.EaseOutQuad);
  586. Tween tween = PrepareLab.CreateTweenText(90, 100, 0.25f, true, false, Curve.EaseOutQuad);
  587. tween.OnForwardFinish += () =>
  588. {
  589. PrepareLab.SetAlpha(1);
  590. PrepareLab.fontSize = 90;
  591. };
  592. }
  593. public override void RegistReference()
  594. {
  595. BtnLab = ManaReso.Get<Text>("D_BeginLab");
  596. TimerLab = ManaReso.Get<Text>("D_TimerLab");
  597. PrepareLab = ManaReso.Get<Text>("D_PrepareLab");
  598. TimerBk = ManaReso.Get<Image>("D_TimerIcon");
  599. }
  600. #region MiniGame
  601. public static void Operate(OpType opType)
  602. {
  603. if (Panalty || !OpList.Valid())
  604. {
  605. return;
  606. }
  607. if (OpList[0].Operate(opType))
  608. {
  609. IdleList.Add(OpList[0]);
  610. OpList.Remove(OpList[0]);
  611. if (OpList.Count >= 2)
  612. {
  613. OpList[0].FirstOp();
  614. OpList[1].SecondOp();
  615. }
  616. else if (OpList.Count >= 1)
  617. {
  618. OpList[0].FirstOp();
  619. }
  620. }
  621. else
  622. {
  623. Panalty = true;
  624. PanaltyTimer = PanaltyTime;
  625. }
  626. }
  627. public static void GameEnd()
  628. {
  629. Pause = false;
  630. Game = false;
  631. Panalty = false;
  632. Prepare = false;
  633. Score = 0;
  634. OpTimer = OpTime;
  635. GameTimer = GameTime;
  636. ManaReso.SetText("Da_Tit", string.Format(Language.GetStr("UI", "Da_Tit1")));
  637. ManaGarden.AwardValid = true;
  638. for (int i = 0; i < OpList.Count; i++)
  639. {
  640. OpList[i].GameOver();
  641. OpList.RemoveAt(i--);
  642. }
  643. for (int i = 0; i < IdleList.Count; i++)
  644. {
  645. IdleList[i].GameOver();
  646. IdleList.RemoveAt(i--);
  647. }
  648. for (int i = 0; i < GoldList.Count; i++)
  649. {
  650. GoldList[i].Retrieve();
  651. GoldList.RemoveAt(i--);
  652. }
  653. for (int i = 0; i < DiamondList.Count; i++)
  654. {
  655. DiamondList[i].Retrieve();
  656. DiamondList.RemoveAt(i--);
  657. }
  658. if (Game)
  659. {
  660. ManaReso.Get("C_MiniGame").TweenBacCG();
  661. ManaData.MiniValid = false;
  662. ManaData.MiniTimer = Mathf.Lerp(180, 300, Random.Range(0, 1f));
  663. ManaDebug.Log(string.Format("<color=red>{0:0}</color>秒后激活小游戏", ManaData.MiniTimer));
  664. }
  665. }
  666. public static void GameOver()
  667. {
  668. GameEnd();
  669. Award.GetAward(Score);
  670. ManaData.MiniGameAmt++;
  671. }
  672. public static void GameEnter()
  673. {
  674. int flowerAmt = 1;
  675. while (true)
  676. {
  677. FlowerInfo flowerInfo = ManaGarden.FlowerInfoDic.Random();
  678. if (flowerInfo.Unlock)
  679. {
  680. IdleList.Add(ManaReso.GetFlower(flowerInfo, ManaReso.Get("SlotMini" + flowerAmt)));
  681. flowerAmt++;
  682. if (flowerAmt == 10)
  683. {
  684. break;
  685. }
  686. }
  687. }
  688. ManaGarden.AwardValid = false;
  689. ManaReso.SetText("Da_CoinLab", "");
  690. ManaReso.SetText("Da_FlowerLab", "");
  691. ManaReso.SetText("Da_DiamondLab", "");
  692. ManaReso.SetActive("Da_Coin", true);
  693. ManaReso.SetActive("Da_Flower", true);
  694. ManaReso.SetActive("Da_Diamond", true);
  695. ManaReso.SetActive("D_Rip1", false);
  696. ManaReso.SetActive("D_Begin", true);
  697. ManaReso.SetActive("D_Water1", false);
  698. ManaReso.SetActive("D_Fertilize1", false);
  699. }
  700. public static void GameBegin()
  701. {
  702. Game = true;
  703. OpTimer = OpTime;
  704. MiniGameIndex++;
  705. GoldTimer = Random.Range(3f, 6f);
  706. GameTimer = GameTime;
  707. DiamondTimer = Random.Range(0f, 40f);
  708. ManaDebug.Log(string.Format("第<color=red>{0}</color>次小游戏", MiniGameIndex));
  709. for (int i = 0; i < IdleList.Count; i++)
  710. {
  711. IdleList[i].GameBegin();
  712. }
  713. if (Random.Range(5, 9) <= MiniGameIndex)
  714. {
  715. MiniGameIndex = 0;
  716. DropDiamond = true;
  717. }
  718. else
  719. {
  720. if (Random.Range(0, 1f) <= 0.01f)
  721. {
  722. DropDiamond = true;
  723. }
  724. else
  725. {
  726. DropDiamond = false;
  727. }
  728. }
  729. }
  730. #endregion
  731. }