GardenManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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 FlowerInfoDictionary)
  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 FlowerInfoDictionary)
  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. public 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 void Update()
  216. {
  217. if (TutorialManager.NewplayerTutorial || Player.InDressRoom || SFSManager.GardenSmartFox.PlazaRoomController.JoinedPlazaRoom)
  218. {
  219. return;
  220. }
  221. CreateElfThread();
  222. CreateStarThread();
  223. CreateAwardThread();
  224. }
  225. public void CreateElfThread()
  226. {
  227. if (!InMinigameFlag)
  228. {
  229. return;
  230. }
  231. CreateElfTimer -= Time.deltaTime;
  232. if (CreateElfTimer < 0)
  233. {
  234. CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime);
  235. if (ElfList.Count > 0 && PlantSlotList.Count > 0)
  236. {
  237. PlantSlotList.Random()[0].PlantFlower.GetElf(ElfList.Random()[0]);
  238. }
  239. }
  240. }
  241. public void CreateStarThread()
  242. {
  243. if (InMinigameFlag && !Manager.MinigameFlag && !VisitManager.InVisit)
  244. {
  245. CreateStarTimer -= Time.deltaTime;
  246. if (CreateStarTimer < 0)
  247. {
  248. CreateStarTimer = Mathf.Lerp(MinCreateStarTime, MaxCreateStarTime, Random.Range(0f, 1f));
  249. StarList.Add(ResourceManager.GetStar());
  250. }
  251. }
  252. }
  253. public void CreateAwardThread()
  254. {
  255. if (InMinigameFlag)
  256. {
  257. CreateAwardTimer -= Time.deltaTime;
  258. if (CreateAwardTimer <= 0)
  259. {
  260. CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime);
  261. List<Flower> spareList = new List<Flower>();
  262. for (int i = 0; i < PlantSlotList.Count; i++)
  263. {
  264. if (PlantSlotList[i].PlantFlower.HaveAward == false)
  265. {
  266. spareList.Add(PlantSlotList[i].PlantFlower);
  267. }
  268. }
  269. if (spareList.Count > 0)
  270. {
  271. spareList.Random()[0].HaveAward = true;
  272. }
  273. }
  274. }
  275. }
  276. public override void InstantiatePrefabs()
  277. {
  278. ResourceManager.Get(ResourceLabel.Garden, Folder.Scene, true, transform, true, ObjType.Garden).AddScript<Garden>();
  279. for (int i = 0; i < DefaultSlotPage; i++)
  280. {
  281. CreatePage();
  282. }
  283. #region 生成FlowerItem
  284. List<XmlAttributeCollection> attributeList = ConfigManager.GetFlowerConfig();
  285. attributeList.AddRange(Bundle.NewFlowerConfigs);
  286. for (int i = 0; i < attributeList.Count; i++)
  287. {
  288. FlowerInfo flowerInfo = new FlowerInfo(attributeList[i]);
  289. if (flowerInfo.IsSpecial)
  290. {
  291. TotalSpecialFlower++;
  292. }
  293. else
  294. {
  295. TotalNormalFlower++;
  296. }
  297. FlowerInfoDictionary.Add(flowerInfo.ID, flowerInfo);
  298. }
  299. #endregion
  300. }
  301. public override void FirstInit()
  302. {
  303. Instance = this;
  304. CreateElfTimer = Random.Range(MinCreateElfTime, MaxCreateElfTime);
  305. CreateAwardTimer = Random.Range(MinCreateAwardTime, MaxCreateAwardTime);
  306. UnlockSlot();
  307. for (int i = 0; i < ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot); i++)
  308. {
  309. UnlockSlot();
  310. }
  311. #region 读花朵存档
  312. List<int> flowerIDList = ConfigManager.GetFlowerList();
  313. for (int i = 0; i < flowerIDList.Count; i++)
  314. {
  315. FlowerInfoDictionary[flowerIDList[i]].Unlock = true;
  316. }
  317. List<int> flowerAmountList = ConfigManager.GetIntList(' ', PlayerConfigLabel.FlowerAmtList, null);
  318. for (int i = 0; i < flowerAmountList.Count; i++)
  319. {
  320. FlowerInfoDictionary[flowerIDList[i]].Amount = flowerAmountList[i];
  321. }
  322. List<KV<int, int>> plantList = ConfigManager.GetPlantList();
  323. for (int i = 0; i < plantList.Count; i++)
  324. {
  325. PlantFlower(plantList[i].Key, plantList[i].Value);
  326. }
  327. #endregion
  328. }
  329. public override void RegistReference()
  330. {
  331. RetrieveFlowerButton = ResourceManager.Get<Button>(CanvasLabel.H_Btn);
  332. RetrieveFlowerButtonText = ResourceManager.Get<Text>(CanvasLabel.H_BtnLab);
  333. BuyFlowerButton = ResourceManager.Get<Button>(CanvasLabel.H_Btn1);
  334. BuyFlowerButtonText = ResourceManager.Get<Text>(CanvasLabel.H_BtnLab1);
  335. }
  336. private static float PageXOffset = 18.9f;
  337. public static void CreatePage()
  338. {
  339. Transform tra = ResourceManager.Get(ResourceLabel.Page, Folder.Scene, false, ResourceManager.Get(GardenLabel.SlotPage), false, ObjType.SlotPage);
  340. float offset = TotalSlotPage * PageXOffset;
  341. tra.SetLX(offset);
  342. Vector3 pos = ResourceManager.Get(GardenLabel.SlotPage).position;
  343. pos.x = -offset;
  344. Garden.PagePos.Add(pos);
  345. for (int i = 0; i < TotalSlotInOnePage; i++)
  346. {
  347. Slot slot = tra.GetChild(i).GetComponent<Slot>();
  348. if (slot == null)
  349. {
  350. slot = tra.GetChild(i).AddScript<Slot>();
  351. }
  352. slot.Index = SlotList.Count;
  353. SlotList.Add(slot);
  354. }
  355. SlotPageList.Add(tra);
  356. }
  357. public static void UnlockSlot()
  358. {
  359. for (int i = 0; i < SlotList.Count; i++)
  360. {
  361. if (SlotList[i].Lock == false)
  362. {
  363. TotalSlot++;
  364. SlotList[i].Lock = true;
  365. SlotList[i].Available = true;
  366. if (TotalSlot% TotalSlotInOnePage == CriticalSlotIndex)
  367. {
  368. if (TotalSlot/ TotalSlotInOnePage + DefaultSlotPage >= TotalSlotPage)
  369. {
  370. CreatePage();
  371. }
  372. }
  373. return;
  374. }
  375. }
  376. }
  377. public static void ShowPlantCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  378. {
  379. ShowFlowerCard(flowerInfo, null, seleSlot);
  380. RetrieveFlowerButton.SetActive(false);
  381. BuyFlowerButton.SetActive(true);
  382. }
  383. public static void PlantFlower(int id, int index)
  384. {
  385. Slot slot = SlotList[index];
  386. FlowerInfo flowerInfo = FlowerInfoDictionary[id];
  387. slot.Plant(flowerInfo, false);
  388. }
  389. public static void PlantFlower(FlowerInfo flowerInfo)
  390. {
  391. Slot slot = null;
  392. for (int i = 0; i < SlotList.Count; i++)
  393. {
  394. if (SlotList[i].Available)
  395. {
  396. slot = SlotList[i];
  397. break;
  398. }
  399. }
  400. if (slot == null)
  401. {
  402. Bubble.Show(null, Language.GetStr(LanguageLabel.Common__NoValidSlot));
  403. }
  404. else
  405. {
  406. slot.Plant(flowerInfo, true);
  407. UpdatePlantCardStatus(flowerInfo);
  408. UpdateRetrieveCardStatus(flowerInfo, RetrieveFlowerButton);
  409. AudioManager.PlayClip(AudioLabel.PlantFlower);
  410. }
  411. }
  412. private static void UpdatePlantCardStatus(FlowerInfo flowerInfo)
  413. {
  414. if (flowerInfo.RemainAmount == 0)
  415. {
  416. ResourceManager.Get<Button>(CanvasLabel.H_Icon2).interactable = false;
  417. ResourceManager.SetActive(CanvasLabel.H_AmtLab, false);
  418. ResourceManager.SetActive(CanvasLabel.H_Rotate, false);
  419. ResourceManager.SetText(CanvasLabel.H_Desc, Language.GetStr(LanguageLabel.UI__H_AllPlanted));
  420. }
  421. else
  422. {
  423. ResourceManager.Get<Button>(CanvasLabel.H_Icon2).interactable = true;
  424. ResourceManager.SetActive(CanvasLabel.H_AmtLab, true);
  425. ResourceManager.SetText(CanvasLabel.H_AmtLab, FlowerInfo.AmountTextPrefix + flowerInfo.RemainAmount);
  426. ResourceManager.SetActive(CanvasLabel.H_Rotate, true);
  427. ResourceManager.SetText(CanvasLabel.H_Desc, Language.GetStr(LanguageLabel.UI__H_PlantTip));
  428. }
  429. }
  430. private static void SetBuyFlowerButton(FlowerInfo flowerInfo, Button button, Text buttonLab)
  431. {
  432. if (flowerInfo.UnlockCur == Current.Free)
  433. {
  434. buttonLab.text = Language.GetStr(LanguageLabel.UI__H_BtnLab2);
  435. button.image.material = Lib.GrayMat;
  436. button.onClick.RemoveAllListeners();
  437. button.onClick.AddListener
  438. (
  439. () =>
  440. {
  441. Bubble.Show(null, Language.GetStr(LanguageLabel.UI__H_BtnLab3));
  442. }
  443. );
  444. }
  445. else
  446. {
  447. buttonLab.text = Auxiliary.ImageParse(flowerInfo.UnlockCur) + flowerInfo.UnlockCost;
  448. button.image.material = null;
  449. button.onClick.RemoveAllListeners();
  450. button.onClick.AddListener
  451. (
  452. () =>
  453. {
  454. Manager.Pay
  455. (
  456. "",
  457. flowerInfo.UnlockCost,
  458. flowerInfo.UnlockCur,
  459. () =>
  460. {
  461. flowerInfo.Add();
  462. UpdatePlantCardStatus(flowerInfo);
  463. ConfigManager.SaveConfigDocument();
  464. ConfigManager.SaveConfigDocumentToDisk();
  465. PlayFlowerCardMaterialTween();
  466. AudioManager.PlayClip(AudioLabel.GetCurrent);
  467. ResourceManager.Get(CanvasLabel.H_Icon1).FindChild($"{CanvasLabel.H_UIFlashLight}/{CanvasLabel.H_UIParticleSystem}").GetComponent<UIPartical>().Begin();
  468. },
  469. StaticsManager.ItemID.解锁花朵,
  470. StaticsManager.ConsumeModule.Shop,
  471. true,
  472. false,
  473. () =>
  474. {
  475. ResourceManager.Get(CanvasLabel.H_FlowerCard).TweenBacCG();
  476. TweenCG tweenCg = ResourceManager.Get(CanvasLabel.G_Flower).TweenBacCG();
  477. tweenCg.AddEventOnetime
  478. (
  479. EventType.BackwardFinish,
  480. () =>
  481. {
  482. ResourceManager.Get(CanvasLabel.F_Manage0).TweenForVec();
  483. }
  484. );
  485. }
  486. );
  487. }
  488. );
  489. }
  490. }
  491. private static void PlayFlowerCardMaterialTween()
  492. {
  493. if (ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material != Lib.GrayMat)
  494. {
  495. return;
  496. }
  497. Material material = new Material(ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material);
  498. MaterialUnit materialUnit = new MaterialUnit
  499. (
  500. material,
  501. ResourceManager.Get(CanvasLabel.H_Icon2),
  502. new List<string>()
  503. {
  504. MaterialLabel.GrayMatGrayLerp,
  505. }
  506. );
  507. FlowerCardMaterialTween = materialUnit.CreateTweenMatFloat(1, 0, 1, true, true, Curve.EaseOutQuad, false);
  508. FlowerCardMaterialTween.OnForwardStart = () =>
  509. {
  510. materialUnit.Transform.GetComponent<Image>().material = materialUnit.Material;
  511. };
  512. FlowerCardMaterialTween.OnForwardFinish = () =>
  513. {
  514. ResourceManager.Get<Image>(CanvasLabel.H_Icon2).material = null;
  515. };
  516. materialUnit.TweenForMatFloat();
  517. }
  518. public static void ShowRetrieveCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  519. {
  520. ShowFlowerCard(flowerInfo, null, seleSlot);
  521. RetrieveFlowerButton.SetActive(true);
  522. BuyFlowerButton.SetActive(true);
  523. }
  524. public static void RetriveFlower(Slot seleSlot = null)
  525. {
  526. if (seleSlot != null && seleSlot.PlantFlower == null)
  527. seleSlot = null;
  528. if (seleSlot == null)
  529. {
  530. foreach (var slot in PlantSlotList)
  531. {
  532. if (slot.PlantFlower.FlowerInfo == SelectFlowerInfo)
  533. {
  534. seleSlot = slot;
  535. break;
  536. }
  537. }
  538. }
  539. seleSlot.Retrieve();
  540. UpdatePlantCardStatus(seleSlot.PlantFlowerInfo);
  541. UpdateRetrieveCardStatus(seleSlot.PlantFlowerInfo, RetrieveFlowerButton);
  542. }
  543. public static void RetriveAllFlower()
  544. {
  545. for (int i = 0; i < PlantSlotList.Count; i++)
  546. {
  547. PlantSlotList[i--].Retrieve();
  548. }
  549. }
  550. private static void UpdateRetrieveCardStatus(FlowerInfo flowerInfo, Button button)
  551. {
  552. if (flowerInfo.PlantAmt == 0)
  553. button.SetActive(false);
  554. else
  555. button.SetActive(true);
  556. }
  557. private static void SetRetrieveFlowerButton(Button button, Text buttonLab, Slot seleSlot = null)
  558. {
  559. RetrieveFlowerButton = button;
  560. buttonLab.text = Language.GetStr(LanguageLabel.UI__H_BtnLab1);
  561. button.image.material = null;
  562. button.onClick.RemoveAllListeners();
  563. button.onClick.AddListener
  564. (
  565. () =>
  566. {
  567. AudioManager.PlayClip(AudioLabel.ClickButton);
  568. RetriveFlower(seleSlot);
  569. }
  570. );
  571. }
  572. public static void ShowUnlockCard(FlowerInfo flowerInfo, Slot seleSlot = null)
  573. {
  574. ShowFlowerCard(flowerInfo, Lib.GrayMat, seleSlot);
  575. RetrieveFlowerButton.SetActive(false);
  576. BuyFlowerButton.SetActive(true);
  577. }
  578. private static void ShowFlowerCard(FlowerInfo flowerInfo, Material material, Slot seleSlot)
  579. {
  580. SetRetrieveFlowerButton(RetrieveFlowerButton, RetrieveFlowerButtonText, seleSlot);
  581. SetBuyFlowerButton(flowerInfo, BuyFlowerButton, BuyFlowerButtonText);
  582. SelectFlowerInfo = flowerInfo;
  583. ResourceManager.Get(CanvasLabel.H_FlowerCard).TweenForCG();
  584. ResourceManager.SetText(CanvasLabel.H_Lab, flowerInfo.Name);
  585. UpdatePlantCardStatus(flowerInfo);
  586. Image image = ResourceManager.Get<Image>(CanvasLabel.H_Icon2);
  587. image.material = material;
  588. image.sprite = flowerInfo.Icon;
  589. image.Resize(true, DeltaSize.FlowerCardSpriteX, DeltaSize.FlowerCardSpriteY);
  590. }
  591. public static void RetrieveAllElf()
  592. {
  593. for (int i = 0; i < PlantSlotList.Count; i++)
  594. {
  595. PlantSlotList[i].PlantFlower.RetrieveElf();
  596. }
  597. }
  598. public static void RetrieveAllStar()
  599. {
  600. for (int i = 0; i < StarList.Count; i++)
  601. {
  602. ResourceManager.Save(StarList[i]);
  603. }
  604. }
  605. }