ManaMiniGame.cs 22 KB

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