ManaMiniGame.cs 25 KB

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