GardenManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Events;
  4. using UnityEngine.EventSystems;
  5. using System;
  6. using System.Xml;
  7. using System.Linq;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using Random = UnityEngine.Random;
  11. public class GardenLabel
  12. {
  13. public static string GardenBK2 = "GardenBK2";
  14. public static string GardenBK3 = "GardenBK3";
  15. public static string GardenBK4 = "GardenBK4";
  16. public static string BK2RightPos = "BK2RightPos";
  17. public static string BK2LeftPos = "BK2LeftPos";
  18. public static string BK3RightPos = "BK3RightPos";
  19. public static string BK3LeftPos = "BK3LeftPos";
  20. public static string BK4RightPos = "BK4RightPos";
  21. public static string BK4LeftPos = "BK4LeftPos";
  22. public static string MinigameLeftPos = "MinigameLeftPos";
  23. public static string GardenCloud1 = "GardenCloud1";
  24. public static string GardenCloud2 = "GardenCloud2";
  25. public static string GardenCloud3 = "GardenCloud3";
  26. public static string BirdPivot = "BirdPivot";
  27. public static string GardenLeftTree = "GardenLeftTree";
  28. public static string GardenRightTree = "GardenRightTree";
  29. public static string GardenRainbow = "GardenRainbow";
  30. public static string Minigame = "Minigame";
  31. public static string SlotPage = "SlotPage";
  32. public static string GardenPivot = "GardenPivot";
  33. public static string GardenPlayerPos = "GardenPlayerPos";
  34. public static string Minigame_DropAward_LeftBorder = "Minigame_DropAward_LeftBorder";
  35. public static string FindMinigame_DropAward_RightBorder = "FindMinigame_DropAward_RightBorder";
  36. public static string MemoryMinigame_DropAward_RightBorder = "MemoryMinigame_DropAward_RightBorder";
  37. public static string MinigameSlot1 = "MinigameSlot1";
  38. public static string MinigameSlot2 = "MinigameSlot2";
  39. public static string MinigameSlot3 = "MinigameSlot3";
  40. public static string MinigameSlot4 = "MinigameSlot4";
  41. public static string MinigameSlot5 = "MinigameSlot5";
  42. public static string MinigameSlot6 = "MinigameSlot6";
  43. public static string MinigameSlot7 = "MinigameSlot7";
  44. public static string MinigameSlot8 = "MinigameSlot8";
  45. public static string MinigameSlot9 = "MinigameSlot9";
  46. }
  47. public enum ElfType
  48. {
  49. Bee_Red,
  50. Bee_Blue,
  51. Bee_White,
  52. Bee_Purple,
  53. Bee_Yellow,
  54. Beetle_Red,
  55. Beetle_Blue,
  56. Beetle_White,
  57. Beetle_Purple,
  58. Beetle_Yellow,
  59. Butterfly_Red,
  60. Butterfly_Blue,
  61. Butterfly_White,
  62. Butterfly_Purple,
  63. Butterfly_Yellow,
  64. Dragonfly_Red,
  65. Dragonfly_Blue,
  66. Dragonfly_White,
  67. Dragonfly_Purple,
  68. Dragonfly_Yellow,
  69. }
  70. public class GardenManager : Regist
  71. {
  72. #region Config
  73. public static int TotalSlot
  74. {
  75. get { return totalSlot; }
  76. set
  77. {
  78. totalSlot = value;
  79. ResourceManager.SetText(CanvasLabel.G_CollectLab2, string.Format("{0}/{1}", totalSlot, TotalSlotPage * TotalSlotInOnePage));
  80. }
  81. }
  82. public static int totalSlot;
  83. public static int TotalSlotPage
  84. {
  85. get { return SlotPageList.Count; }
  86. }
  87. public static int TotalUnlockFlower
  88. {
  89. get { return totalUnlockFlower; }
  90. set
  91. {
  92. totalUnlockFlower = value;
  93. AchieveManager.UpdateStatus(AchieveType.UnlockFlowerAmt, totalUnlockFlower);
  94. ResourceManager.SetText(CanvasLabel.F_FlowerLab, string.Format("{0}", TotalUnlockFlower));
  95. ResourceManager.SetText(CanvasLabel.G_CollectLab1, string.Format("{0}/{1}", TotalUnlockFlower, TotalFlower));
  96. if (totalUnlockFlower >= TutorialManager.MinFlowerForFindSoloGame && Manager.GardenLevel >= TutorialManager.FindSoloMinigameTutorialLevel)
  97. {
  98. if (TutorialManager.findSoloMinigameTutorial)
  99. {
  100. TutorialManager.PlayFindSoloGame();
  101. }
  102. }
  103. if (totalUnlockFlower >= TutorialManager.MinFlowerForFindMissingGame && Manager.GardenLevel >= TutorialManager.FindMissingMinigameTutorialLevel)
  104. {
  105. if (TutorialManager.findMissingMinigameTutorial)
  106. {
  107. TutorialManager.PlayFindMissingGame();
  108. }
  109. }
  110. }
  111. }
  112. private static int totalUnlockFlower;
  113. public static int TotalUnlockSpecialFlower
  114. {
  115. get { return totalUnlockSpecialFlower; }
  116. set
  117. {
  118. totalUnlockSpecialFlower = value;
  119. TotalUnlockFlower = totalUnlockSpecialFlower + totalUnlockNormalFlower;
  120. }
  121. }
  122. private static int totalUnlockSpecialFlower;
  123. public static int TotalUnlockNormalFlower
  124. {
  125. get { return totalUnlockNormalFlower; }
  126. set
  127. {
  128. totalUnlockNormalFlower = value;
  129. TotalUnlockFlower = totalUnlockSpecialFlower + totalUnlockNormalFlower;
  130. }
  131. }
  132. private static int totalUnlockNormalFlower;
  133. public static int TotalFlower;
  134. public static int TotalSpecialFlower
  135. {
  136. get { return totalSpecialFlower; }
  137. set
  138. {
  139. totalSpecialFlower = value;
  140. TotalFlower = totalSpecialFlower + totalNormalFlower;
  141. }
  142. }
  143. private static int totalSpecialFlower;
  144. public static int TotalNormalFlower
  145. {
  146. get { return totalNormalFlower; }
  147. set
  148. {
  149. totalNormalFlower = value;
  150. TotalFlower = totalSpecialFlower + totalNormalFlower;
  151. }
  152. }
  153. private static int totalNormalFlower;
  154. public static int FirstUnlockFlowerID
  155. {
  156. get
  157. {
  158. foreach (var kv in GetFlowerInfoDict())
  159. {
  160. if (!kv.Value.Unlock)
  161. {
  162. return kv.Key;
  163. }
  164. }
  165. return -1;
  166. }
  167. }
  168. public static List<int> UnlockedFlowerIDList
  169. {
  170. get
  171. {
  172. List<int> unlockedFlowerIDList = new List<int>();
  173. foreach (var kv in GetFlowerInfoDict())
  174. {
  175. if (kv.Value.Unlock)
  176. {
  177. unlockedFlowerIDList.Add(kv.Key);
  178. }
  179. }
  180. return unlockedFlowerIDList;
  181. }
  182. }
  183. public static int DefaultUnlockSlot = 1;
  184. public static bool InMinigameFlag = true;
  185. public static float MinCreateElfTime = 5;
  186. public static float MaxCreateElfTime = 30;
  187. public static float CreateElfTimer;
  188. public static float MinCreateStarTime;
  189. public static float MaxCreateStarTime;
  190. public static float CreateStarTimer;
  191. public static float MinCreateAwardTime = 5;
  192. public static float MaxCreateAwardTime = 15;
  193. public static float CreateAwardTimer;
  194. public static Text BuyFlowerButtonText;
  195. public static Text RetrieveFlowerButtonText;
  196. public static Button BuyFlowerButton;
  197. public static Button RetrieveFlowerButton;
  198. public static FlowerInfo SelectFlowerInfo;
  199. public static TweenMatFloat FlowerCardMaterialTween;
  200. public static GardenManager Instance;
  201. public static List<Slot> SlotList = new List<Slot>();
  202. public static List<Slot> PlantSlotList = new List<Slot>();
  203. public static List<Star> StarList = new List<Star>();
  204. public static List<ElfType> ElfList = new List<ElfType>();
  205. public static List<Transform> SlotPageList = new List<Transform>();
  206. private static Dictionary<int, FlowerInfo> FlowerInfoDictionary = new Dictionary<int, FlowerInfo>();
  207. public static int DefaultSlotPage = 2;
  208. public static int CriticalSlotIndex = 7;
  209. public static int TotalSlotInOnePage = 9;
  210. public static int LeftTopSlotIndex = 0;
  211. public static int RightTopSlotIndex = 3;
  212. public static int RightDownSlotIndex = 8;
  213. public static int LeftDownSlotIndex = 4;
  214. #endregion
  215. public static FlowerInfo GetFlowerInfo(int id)
  216. {
  217. if (FlowerInfoDictionary.ContainsKey(id) == false)
  218. {
  219. id = 0;
  220. Debug.LogError("no such flower");
  221. }
  222. return FlowerInfoDictionary[id];
  223. }
  224. public static Dictionary<int, FlowerInfo> GetFlowerInfoDict()
  225. {
  226. return FlowerInfoDictionary;
  227. }
  228. public void Update()
  229. {
  230. if (TutorialManager.NewplayerTutorial || Player.InDressRoom || SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom)
  231. {
  232. return;
  233. }
  234. CreateElfThread();
  235. CreateStarThread();
  236. CreateAwardThread();
  237. }
  238. public void CreateElfThread()
  239. {
  240. if (!InMinigameFlag)
  241. {
  242. return;
  243. }
  244. CreateElfTimer -= Time.deltaTime;
  245. if (CreateElfTimer < 0)
  246. {
  247. CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime);
  248. if (ElfList.Count > 0 && PlantSlotList.Count > 0)
  249. {
  250. PlantSlotList.Random()[0].PlantFlower.GetElf(ElfList.Random()[0]);
  251. }
  252. }
  253. }
  254. public void CreateStarThread()
  255. {
  256. if (InMinigameFlag && !Manager.MinigameFlag && !VisitManager.InVisit)
  257. {
  258. CreateStarTimer -= Time.deltaTime;
  259. if (CreateStarTimer < 0)
  260. {
  261. CreateStarTimer = Mathf.Lerp(MinCreateStarTime, MaxCreateStarTime, Random.Range(0f, 1f));
  262. StarList.Add(ResourceManager.GetStar());
  263. }
  264. }
  265. }
  266. public void CreateAwardThread()
  267. {
  268. if (InMinigameFlag)
  269. {
  270. CreateAwardTimer -= Time.deltaTime;
  271. if (CreateAwardTimer <= 0)
  272. {
  273. CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime);
  274. List<Flower> spareList = new List<Flower>();
  275. for (int i = 0; i < PlantSlotList.Count; i++)
  276. {
  277. if (PlantSlotList[i].PlantFlower.HaveAward == false)
  278. {
  279. spareList.Add(PlantSlotList[i].PlantFlower);
  280. }
  281. }
  282. if (spareList.Count > 0)
  283. {
  284. spareList.Random()[0].HaveAward = true;
  285. }
  286. }
  287. }
  288. }
  289. public override void InstantiatePrefabs()
  290. {
  291. ResourceManager.Get(ResourceLabel.Garden, Folder.Scene, true, transform, true, ObjType.Garden).AddScript<Garden>();
  292. for (int i = 0; i < DefaultSlotPage; i++)
  293. {
  294. CreatePage();
  295. }
  296. #region 生成FlowerItem
  297. List<XmlAttributeCollection> attributeList = ConfigManager.GetFlowerConfig();
  298. //attributeList.AddRange(Bundle.NewFlowerConfigs);
  299. for (int i = 0; i < attributeList.Count; i++)
  300. {
  301. FlowerInfo flowerInfo = new FlowerInfo(attributeList[i]);
  302. if (flowerInfo.IsSpecial)
  303. {
  304. TotalSpecialFlower++;
  305. }
  306. else
  307. {
  308. TotalNormalFlower++;
  309. }
  310. GetFlowerInfoDict().Add(flowerInfo.ID, flowerInfo);
  311. }
  312. #endregion
  313. }
  314. public override void FirstInit()
  315. {
  316. Instance = this;
  317. CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime);
  318. CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime);
  319. UnlockSlot();
  320. for (int i = 0; i < ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot); i++)
  321. {
  322. UnlockSlot();
  323. }
  324. #region 读花朵存档
  325. List<int> flowerIDList = ConfigManager.GetFlowerList();
  326. for (int i = 0; i < flowerIDList.Count; i++)
  327. {
  328. GetFlowerInfo(flowerIDList[i]).Unlock = true;
  329. }
  330. List<int> flowerAmountList = ConfigManager.GetIntList(' ', PlayerConfigLabel.FlowerAmtList, null);
  331. for (int i = 0; i < flowerAmountList.Count; i++)
  332. {
  333. GetFlowerInfo(flowerIDList[i]).Amount = flowerAmountList[i];
  334. }
  335. List<KV<int, int>> plantList = ConfigManager.GetPlantList();
  336. for (int i = 0; i < plantList.Count; i++)
  337. {
  338. PlantFlower(plantList[i].Key, plantList[i].Value);
  339. }
  340. #endregion
  341. }
  342. public override void RegistReference()
  343. {
  344. RetrieveFlowerButton = ResourceManager.Get<Button>(CanvasLabel.H_Btn);
  345. RetrieveFlowerButtonText = ResourceManager.Get<Text>(CanvasLabel.H_BtnLab);
  346. BuyFlowerButton = ResourceManager.Get<Button>(CanvasLabel.H_Btn1);
  347. BuyFlowerButtonText = ResourceManager.Get<Text>(CanvasLabel.H_BtnLab1);
  348. }
  349. private static float PageXOffset = 18.9f;
  350. public static void CreatePage()
  351. {
  352. Transform tra = ResourceManager.Get(ResourceLabel.Page, Folder.Scene, false, ResourceManager.Get(GardenLabel.SlotPage), false, ObjType.SlotPage);
  353. float offset = TotalSlotPage * PageXOffset;
  354. tra.SetLX(offset);
  355. Vector3 pos = ResourceManager.Get(GardenLabel.SlotPage).position;
  356. pos.x = -offset;
  357. Garden.PagePos.Add(pos);
  358. for (int i = 0; i < TotalSlotInOnePage; i++)
  359. {
  360. Slot slot = tra.GetChild(i).GetComponent<Slot>();
  361. if (slot == null)
  362. {
  363. slot = tra.GetChild(i).AddScript<Slot>();
  364. }
  365. slot.Index = SlotList.Count;
  366. SlotList.Add(slot);
  367. }
  368. SlotPageList.Add(tra);
  369. }
  370. public static void UnlockSlot()
  371. {
  372. for (int i = 0; i < SlotList.Count; i++)
  373. {
  374. if (SlotList[i].Lock == false)
  375. {
  376. TotalSlot++;
  377. SlotList[i].Lock = true;
  378. SlotList[i].Available = true;
  379. if (TotalSlot% TotalSlotInOnePage == CriticalSlotIndex)
  380. {
  381. if (TotalSlot/ TotalSlotInOnePage + DefaultSlotPage >= TotalSlotPage)
  382. {
  383. CreatePage();
  384. }
  385. }
  386. return;
  387. }
  388. }
  389. }
  390. public static void ShowPlantCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  391. {
  392. ShowFlowerCard(flowerInfo, null, seleSlot);
  393. RetrieveFlowerButton.SetActive(false);
  394. BuyFlowerButton.SetActive(true);
  395. }
  396. public static void PlantFlower(int id, int index)
  397. {
  398. Slot slot = SlotList[index];
  399. FlowerInfo flowerInfo = GetFlowerInfo(id);
  400. slot.Plant(flowerInfo, false);
  401. }
  402. public static void PlantFlower(FlowerInfo flowerInfo)
  403. {
  404. Slot slot = null;
  405. for (int i = 0; i < SlotList.Count; i++)
  406. {
  407. if (SlotList[i].Available)
  408. {
  409. slot = SlotList[i];
  410. break;
  411. }
  412. }
  413. if (slot == null)
  414. {
  415. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__NoValidSlot));
  416. }
  417. else
  418. {
  419. slot.Plant(flowerInfo, true);
  420. UpdatePlantCardStatus(flowerInfo);
  421. UpdateRetrieveCardStatus(flowerInfo, RetrieveFlowerButton);
  422. AudioManager.PlayClip(AudioLabel.PlantFlower);
  423. }
  424. }
  425. private static void UpdatePlantCardStatus(FlowerInfo flowerInfo)
  426. {
  427. if (flowerInfo.RemainAmount == 0)
  428. {
  429. ResourceManager.Get<Button>(CanvasLabel.H_Icon2).interactable = false;
  430. ResourceManager.SetActive(CanvasLabel.H_AmtLab, false);
  431. ResourceManager.SetActive(CanvasLabel.H_Rotate, false);
  432. ResourceManager.SetActive(CanvasLabel.H_ArrowParent, false);
  433. ResourceManager.SetText(CanvasLabel.H_Desc, Language.GetStr(LanguageLabel.UI__H_AllPlanted));
  434. }
  435. else
  436. {
  437. ResourceManager.Get<Button>(CanvasLabel.H_Icon2).interactable = true;
  438. ResourceManager.SetActive(CanvasLabel.H_AmtLab, true);
  439. ResourceManager.SetText(CanvasLabel.H_AmtLab, FlowerInfo.AmountTextPrefix + flowerInfo.RemainAmount);
  440. ResourceManager.SetActive(CanvasLabel.H_Rotate, true);
  441. ResourceManager.SetActive(CanvasLabel.H_ArrowParent, true);
  442. ResourceManager.SetText(CanvasLabel.H_Desc, Language.GetStr(LanguageLabel.UI__H_PlantTip));
  443. }
  444. }
  445. private static void SetBuyFlowerButton(FlowerInfo flowerInfo, Button button, Text buttonLab)
  446. {
  447. if (flowerInfo.UnlockCur == Current.Free)
  448. {
  449. buttonLab.text = Language.GetStr(LanguageLabel.UI__H_BtnLab2);
  450. button.image.material = Lib.GrayMat;
  451. button.onClick.RemoveAllListeners();
  452. button.onClick.AddListener
  453. (
  454. () =>
  455. {
  456. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__H_BtnLab3));
  457. }
  458. );
  459. }
  460. else
  461. {
  462. buttonLab.text = Auxiliary.ImageParse(flowerInfo.UnlockCur) + flowerInfo.UnlockCost;
  463. button.image.material = null;
  464. button.onClick.RemoveAllListeners();
  465. button.onClick.AddListener
  466. (
  467. () =>
  468. {
  469. Manager.Pay
  470. (
  471. "",
  472. flowerInfo.UnlockCost,
  473. flowerInfo.UnlockCur,
  474. () =>
  475. {
  476. flowerInfo.Add();
  477. UpdatePlantCardStatus(flowerInfo);
  478. ConfigManager.SaveConfigDocument();
  479. ConfigManager.SaveConfigDocumentToDisk();
  480. PlayFlowerCardMaterialTween();
  481. AudioManager.PlayClip(AudioLabel.GetCurrent);
  482. ResourceManager.Get(CanvasLabel.H_Icon1).Find(string.Format("{0}/{1}", CanvasLabel.H_UIFlashLight, CanvasLabel.H_UIParticleSystem)).GetComponent<UIPartical>().Begin();
  483. },
  484. StaticsManager.ItemID.解锁花朵,
  485. StaticsManager.ConsumeModule.Shop,
  486. true,
  487. false,
  488. () =>
  489. {
  490. ResourceManager.Get(CanvasLabel.H_FlowerCard).TweenBacCG();
  491. TweenCG tweenCg = ResourceManager.Get(CanvasLabel.G_Flower).TweenBacCG();
  492. tweenCg.AddEventOnetime
  493. (
  494. EventType.BackwardFinish,
  495. () =>
  496. {
  497. ResourceManager.Get(CanvasLabel.F_Manage0).TweenForVec();
  498. }
  499. );
  500. }
  501. );
  502. }
  503. );
  504. }
  505. }
  506. private static void PlayFlowerCardMaterialTween()
  507. {
  508. if (ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material != Lib.GrayMat)
  509. {
  510. return;
  511. }
  512. Material material = new Material(ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material);
  513. MaterialUnit materialUnit = new MaterialUnit
  514. (
  515. material,
  516. ResourceManager.Get(CanvasLabel.H_Icon2),
  517. new List<string>()
  518. {
  519. MaterialLabel.GrayMatGrayLerp,
  520. }
  521. );
  522. FlowerCardMaterialTween = materialUnit.CreateTweenMatFloat(1, 0, 1, true, true, Curve.EaseOutQuad, false);
  523. FlowerCardMaterialTween.OnForwardStart = () =>
  524. {
  525. materialUnit.Transform.GetComponent<Image>().material = materialUnit.Material;
  526. };
  527. FlowerCardMaterialTween.OnForwardFinish = () =>
  528. {
  529. ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material = null;
  530. };
  531. materialUnit.TweenForMatFloat();
  532. }
  533. public static void ShowRetrieveCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  534. {
  535. ShowFlowerCard(flowerInfo, null, seleSlot);
  536. RetrieveFlowerButton.SetActive(true);
  537. BuyFlowerButton.SetActive(true);
  538. }
  539. public static void RetriveFlower(Slot seleSlot = null)
  540. {
  541. if (seleSlot != null && seleSlot.PlantFlower == null)
  542. seleSlot = null;
  543. if (seleSlot == null)
  544. {
  545. foreach (var slot in PlantSlotList)
  546. {
  547. if (slot.PlantFlower.FlowerInfo == SelectFlowerInfo)
  548. {
  549. seleSlot = slot;
  550. break;
  551. }
  552. }
  553. }
  554. seleSlot.Retrieve();
  555. UpdatePlantCardStatus(seleSlot.PlantFlowerInfo);
  556. UpdateRetrieveCardStatus(seleSlot.PlantFlowerInfo, RetrieveFlowerButton);
  557. }
  558. public static void RetriveAllFlower()
  559. {
  560. for (int i = 0; i < PlantSlotList.Count; i++)
  561. {
  562. PlantSlotList[i--].Retrieve();
  563. }
  564. }
  565. private static void UpdateRetrieveCardStatus(FlowerInfo flowerInfo, Button button)
  566. {
  567. if (flowerInfo.PlantAmt == 0)
  568. button.SetActive(false);
  569. else
  570. button.SetActive(true);
  571. }
  572. private static void SetRetrieveFlowerButton(Button button, Text buttonLab, Slot seleSlot = null)
  573. {
  574. RetrieveFlowerButton = button;
  575. buttonLab.text = Language.GetStr(LanguageLabel.UI__H_BtnLab1);
  576. button.image.material = null;
  577. button.onClick.RemoveAllListeners();
  578. button.onClick.AddListener
  579. (
  580. () =>
  581. {
  582. AudioManager.PlayClip(AudioLabel.ClickButton);
  583. RetriveFlower(seleSlot);
  584. }
  585. );
  586. }
  587. public static void ShowUnlockCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  588. {
  589. ShowFlowerCard(flowerInfo, Lib.GrayMat, seleSlot);
  590. RetrieveFlowerButton.SetActive(false);
  591. BuyFlowerButton.SetActive(true);
  592. }
  593. private static void ShowFlowerCard(FlowerInfo flowerInfo, Material material, Slot seleSlot)
  594. {
  595. SetRetrieveFlowerButton(RetrieveFlowerButton, RetrieveFlowerButtonText, seleSlot);
  596. SetBuyFlowerButton(flowerInfo, BuyFlowerButton, BuyFlowerButtonText);
  597. SelectFlowerInfo = flowerInfo;
  598. ResourceManager.Get(CanvasLabel.H_FlowerCard).TweenForCG();
  599. ResourceManager.SetText(CanvasLabel.H_Lab, flowerInfo.Name);
  600. UpdatePlantCardStatus(flowerInfo);
  601. Image image = ResourceManager.Get<Image>(CanvasLabel.H_Icon2);
  602. image.material = material;
  603. image.sprite = flowerInfo.Icon;
  604. image.Resize(true, flowerInfo.flowerCardSize, flowerInfo.flowerCardSize);
  605. }
  606. public static void RetrieveAllElf()
  607. {
  608. for (int i = 0; i < PlantSlotList.Count; i++)
  609. {
  610. PlantSlotList[i].PlantFlower.RetrieveElf();
  611. }
  612. }
  613. public static void RetrieveAllStar()
  614. {
  615. for (int i = 0; i < StarList.Count; i++)
  616. {
  617. ResourceManager.Save(StarList[i]);
  618. }
  619. }
  620. }