RechargeGiftManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using LitJson;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using Random = UnityEngine.Random;
  8. public class RechargeGiftJsonLabel
  9. {
  10. public static string PackID = "packid";
  11. public static string StartTime = "starttime";
  12. public static string EndTime = "endtime";
  13. public static string UnvalidValueStr = "0";
  14. public static Dictionary<RechargeGift.GiftType, string> TypeDictionary = new Dictionary<RechargeGift.GiftType, string>
  15. {
  16. {RechargeGift.GiftType.金币,"g"},
  17. {RechargeGift.GiftType.钻石,"d"},
  18. {RechargeGift.GiftType.礼包,"p"},
  19. {RechargeGift.GiftType.花朵,"f"},
  20. {RechargeGift.GiftType.服装,"c"},
  21. {RechargeGift.GiftType.开垦土地,"s"},
  22. {RechargeGift.GiftType.精灵,"a"},
  23. };
  24. }
  25. public class RechargeGift
  26. {
  27. public enum GiftType
  28. {
  29. 金币 = 0,
  30. 钻石 = 1,
  31. 礼包 = 2,
  32. 花朵 = 3,
  33. 服装 = 4,
  34. 开垦土地 = 5,
  35. 精灵 = 6,
  36. }
  37. public abstract class GiftAward
  38. {
  39. protected float CloseExchangeRatio = 0.25f;
  40. protected float AbilityExchangeRatio = 0.25f;
  41. protected GiftType GiftType;
  42. public GiftAward(GiftType giftType)
  43. {
  44. GiftType = giftType;
  45. }
  46. /// <returns>true-全部领完</returns>
  47. public abstract bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo);
  48. protected void GetGiftAward(GiftType type, int value, out KV<GiftType, int> giftAwardInfo)
  49. {
  50. if (type == GiftType.开垦土地)
  51. {
  52. AudioManager.PlayClip(ResourceLabel.CurrentClip);
  53. for (int i = 0; i < value; i++)
  54. {
  55. GardenManager.UnlockSlot();
  56. int extraSlot = ConfigManager.GetIntFormConfig(PlayerConfigLabel.ExtraSlot);
  57. ConfigManager.SaveIntToConfig(PlayerConfigLabel.ExtraSlot, extraSlot + 1);
  58. }
  59. giftAwardInfo.Key = type;
  60. giftAwardInfo.Value = value;
  61. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  62. }
  63. else if (type == GiftType.服装)
  64. {
  65. CloseItem closeItem = PlayerManager.CloseItemDictionary[value];
  66. if (closeItem.IsBought)
  67. {
  68. AudioManager.PlayClip(ResourceLabel.CurrentClip);
  69. ExchangeInfo info = closeItem.GetExchangeValue(CloseExchangeRatio, StaticsManager.ConsumeModule.Gift);
  70. giftAwardInfo.Key = CurrentToGiftType(info.Current);
  71. giftAwardInfo.Value = (int) info.Value;
  72. }
  73. else
  74. {
  75. closeItem.OnBuySucceed();
  76. giftAwardInfo.Key = type;
  77. giftAwardInfo.Value = value;
  78. }
  79. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  80. }
  81. else if (type == GiftType.礼包)
  82. {
  83. string packID = SkillConfigLabel.GetFullID(SkillType.Pack, value);
  84. (Manager.SkillDictionary[packID] as Pack).OnBuySucceed(false);
  85. giftAwardInfo.Key = type;
  86. giftAwardInfo.Value = value;
  87. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  88. }
  89. else if (type == GiftType.精灵)
  90. {
  91. string abilityID = SkillConfigLabel.GetFullID(SkillType.Ability, value);
  92. Ability ability = Manager.SkillDictionary[abilityID] as Ability;
  93. if (ability.ItemStatus == SkillStatus.Lock)
  94. {
  95. AudioManager.PlayClip(ResourceLabel.CurrentClip);
  96. ExchangeInfo info = ability.GetUnlockAheadExchangeValue(AbilityExchangeRatio, StaticsManager.ConsumeModule.Gift);
  97. giftAwardInfo.Key = CurrentToGiftType(info.Current);
  98. giftAwardInfo.Value = (int)info.Value;
  99. }
  100. else if (ability.ItemStatus == SkillStatus.UnLock)
  101. {
  102. ability.UnlockSucceed();
  103. giftAwardInfo.Key = type;
  104. giftAwardInfo.Value = value;
  105. }
  106. else if (ability.ItemStatus == SkillStatus.Upgrade)
  107. {
  108. ability.UpgradeSucceed();
  109. giftAwardInfo.Key = type;
  110. giftAwardInfo.Value = value;
  111. }
  112. else
  113. {
  114. throw new Exception();
  115. }
  116. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  117. }
  118. else if (type == GiftType.花朵)
  119. {
  120. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[value];
  121. flowerInfo.Add();
  122. giftAwardInfo.Key = type;
  123. giftAwardInfo.Value = value;
  124. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  125. }
  126. else if (type == GiftType.金币)
  127. {
  128. AudioManager.PlayClip(ResourceLabel.CurrentClip);
  129. Manager.AddCoin(value, StaticsManager.ItemID.获得金币, StaticsManager.ConsumeModule.Gift);
  130. giftAwardInfo.Key = type;
  131. giftAwardInfo.Value = value;
  132. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  133. }
  134. else if (type == GiftType.钻石)
  135. {
  136. AudioManager.PlayClip(ResourceLabel.CurrentClip);
  137. Manager.AddDiamond(value, StaticsManager.ItemID.获得钻石, StaticsManager.ConsumeModule.Gift);
  138. giftAwardInfo.Key = type;
  139. giftAwardInfo.Value = value;
  140. Debug.LogWarning($"{giftAwardInfo.Key} {giftAwardInfo.Value}");
  141. }
  142. else
  143. {
  144. throw new Exception();
  145. }
  146. }
  147. protected GiftType CurrentToGiftType(Current current)
  148. {
  149. if (current == Current.Coin)
  150. {
  151. return GiftType.金币;
  152. }
  153. else if (current == Current.Diamond)
  154. {
  155. return GiftType.钻石;
  156. }
  157. else
  158. {
  159. throw new Exception();
  160. }
  161. }
  162. }
  163. public class SingleGiftAward : GiftAward
  164. {
  165. protected int Value;
  166. public SingleGiftAward(GiftType giftType, int value) : base(giftType)
  167. {
  168. Value = value;
  169. //Debug.Log($"{giftType} {value}");
  170. }
  171. public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
  172. {
  173. GetGiftAward(GiftType, Value, out giftAwardInfo);
  174. return true;
  175. }
  176. }
  177. public class MultipleGiftAward : GiftAward
  178. {
  179. protected List<int> Values;
  180. public MultipleGiftAward(GiftType giftType, List<int> values) : base(giftType)
  181. {
  182. Values = values;
  183. //Debug.Log($"{giftType} {Auxiliary.IntsToString(Values)}");
  184. }
  185. public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
  186. {
  187. GetGiftAward(GiftType, Values[0], out giftAwardInfo);
  188. Values.RemoveAt(0);
  189. if (Values.Count > 0)
  190. {
  191. return false;
  192. }
  193. else
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. //随机获取区间内的一个
  200. public class RandomGiftAward : GiftAward
  201. {
  202. protected int StartIndex;
  203. protected int EndIndex;
  204. public RandomGiftAward(GiftType giftType, int startIndex, int endIndex) : base(giftType)
  205. {
  206. StartIndex = startIndex;
  207. EndIndex = endIndex;
  208. //Debug.Log($"{giftType} {StartIndex} {EndIndex}");
  209. }
  210. public override bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
  211. {
  212. int value = Random.Range(StartIndex, EndIndex + 1);
  213. GetGiftAward(GiftType, value, out giftAwardInfo);
  214. return true;
  215. }
  216. }
  217. #region Config
  218. public int RemainGiftAward
  219. {
  220. get { return GiftAwards.Count; }
  221. }
  222. private DateTime StartDate;
  223. private DateTime EndDate;
  224. private List<GiftAward> GiftAwards = new List<GiftAward>();
  225. #endregion
  226. public RechargeGift(JsonData jsonData)
  227. {
  228. //Debug.Log(jsonData.ToJson());
  229. string label = RechargeGiftJsonLabel.TypeDictionary[GiftType.金币];
  230. string valueStr = jsonData[label].ToString();
  231. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  232. {
  233. GiftAwards.AddRange(ParseAllGiftAward(GiftType.金币, valueStr));
  234. }
  235. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.钻石];
  236. valueStr = jsonData[label].ToString();
  237. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  238. {
  239. GiftAwards.AddRange(ParseAllGiftAward(GiftType.钻石, valueStr));
  240. }
  241. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.礼包];
  242. valueStr = jsonData[label].ToString();
  243. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  244. {
  245. GiftAwards.AddRange(ParseAllGiftAward(GiftType.礼包, valueStr));
  246. }
  247. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.花朵];
  248. valueStr = jsonData[label].ToString();
  249. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  250. {
  251. GiftAwards.AddRange(ParseAllGiftAward(GiftType.花朵, valueStr));
  252. }
  253. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.服装];
  254. valueStr = jsonData[label].ToString();
  255. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  256. {
  257. GiftAwards.AddRange(ParseAllGiftAward(GiftType.服装, valueStr));
  258. }
  259. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.开垦土地];
  260. valueStr = jsonData[label].ToString();
  261. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  262. {
  263. GiftAwards.AddRange(ParseAllGiftAward(GiftType.开垦土地, valueStr));
  264. }
  265. label = RechargeGiftJsonLabel.TypeDictionary[GiftType.精灵];
  266. valueStr = jsonData[label].ToString();
  267. if (valueStr != RechargeGiftJsonLabel.UnvalidValueStr)
  268. {
  269. GiftAwards.AddRange(ParseAllGiftAward(GiftType.精灵, valueStr));
  270. }
  271. StartDate = DateTime.Parse(jsonData[RechargeGiftJsonLabel.StartTime].ToString());
  272. EndDate = DateTime.Parse(jsonData[RechargeGiftJsonLabel.EndTime].ToString());
  273. //Debug.LogWarning(StartDate);
  274. //Debug.LogWarning(EndDate);
  275. }
  276. private List<GiftAward> ParseAllGiftAward(GiftType giftType, string valueStr)
  277. {
  278. List<GiftAward> giftAwards = new List<GiftAward>();
  279. string[] values = valueStr.Split('|');
  280. for (int i = 0; i < values.Length; i++)
  281. {
  282. giftAwards.Add(ParseGiftAward(giftType, values[i]));
  283. }
  284. return giftAwards;
  285. }
  286. private GiftAward ParseGiftAward(GiftType giftType, string valueStr)
  287. {
  288. if (valueStr.Contains(" "))
  289. {
  290. List<int> values = Auxiliary.StringToInts(' ', valueStr, new List<int>());
  291. return new MultipleGiftAward(giftType, values);
  292. }
  293. else if (valueStr.Contains(","))
  294. {
  295. valueStr = valueStr.TrimStart('[');
  296. valueStr = valueStr.TrimEnd(']');
  297. string[] valueStrs = valueStr.Split(',');
  298. int startIndex = int.Parse(valueStrs[0]);
  299. int endIndex = int.Parse(valueStrs[1]);
  300. return new RandomGiftAward(giftType, startIndex, endIndex);
  301. }
  302. else if (valueStr.Contains("-"))
  303. {
  304. string[] valueStrs = valueStr.Split('-');
  305. int startIndex = int.Parse(valueStrs[0]);
  306. int endIndex = int.Parse(valueStrs[1]);
  307. List<int> values = Auxiliary.StartEndIndexToInts(startIndex, endIndex);
  308. return new MultipleGiftAward(giftType, values);
  309. }
  310. else
  311. {
  312. int value = int.Parse(valueStr);
  313. return new SingleGiftAward(giftType, value);
  314. }
  315. }
  316. public bool IsAwardAvailable()
  317. {
  318. if (HttpManager.CurrentDateTime > EndDate)
  319. {
  320. //Debug.Log("has't start");
  321. return false;
  322. }
  323. if (HttpManager.CurrentDateTime < StartDate)
  324. {
  325. //Debug.Log("over");
  326. return false;
  327. }
  328. if (GiftAwards.Count == 0)
  329. {
  330. return false;
  331. }
  332. return true;
  333. }
  334. public bool GetOneGiftAward(out KV<GiftType, int> giftAwardInfo)
  335. {
  336. if (GiftAwards[0].GetOneGiftAward(out giftAwardInfo))
  337. {
  338. GiftAwards.RemoveAt(0);
  339. }
  340. if (GiftAwards.Count > 0)
  341. {
  342. return false;
  343. }
  344. else
  345. {
  346. return true;
  347. }
  348. }
  349. }
  350. public class RechargeGiftManager
  351. {
  352. #region Config
  353. public static bool Inited;
  354. private static Dictionary<int, RechargeGift> GiftDictionary = new Dictionary<int, RechargeGift>();
  355. private static string AmountTextPrefix = "x";
  356. private static RechargeGift CurrentRechargeGift;
  357. private static Text Title;
  358. private static Text Description;
  359. private static Text ConfirmButtonText;
  360. private static Image AwardImage0;
  361. private static Image AwardImage1;
  362. private static Image AwardImage2;
  363. private static Image FlowerAwardImage;
  364. private static Button ConfirmButton;
  365. private static Transform PanelBK;
  366. private static List<Image> AwardImages = new List<Image>();
  367. #endregion
  368. public static void Init(JsonData jsonData)
  369. {
  370. //Debug.LogWarning("Inited");
  371. Inited = true;
  372. for (int i = 0; i < jsonData.Count; i++)
  373. {
  374. int packID = (int) jsonData[i][RechargeGiftJsonLabel.PackID];
  375. RechargeGift rechargeGift = new RechargeGift(jsonData[i]);
  376. GiftDictionary.Add(packID, rechargeGift);
  377. }
  378. Title = ResourceManager.Get<Text>(CanvasLabel.AB_Title);
  379. Description = ResourceManager.Get<Text>(CanvasLabel.AB_Description);
  380. ConfirmButtonText = ResourceManager.Get<Text>(CanvasLabel.AB_ConfirmText);
  381. AwardImage0 = ResourceManager.Get<Image>(CanvasLabel.AB_AwardImage0);
  382. AwardImage1 = ResourceManager.Get<Image>(CanvasLabel.AB_AwardImage1);
  383. AwardImage2 = ResourceManager.Get<Image>(CanvasLabel.AB_AwardImage2);
  384. FlowerAwardImage = ResourceManager.Get<Image>(CanvasLabel.AB_FlowerAwardImage);
  385. ConfirmButton = ResourceManager.Get<Button>(CanvasLabel.AB_Confirm);
  386. PanelBK = ResourceManager.Get(CanvasLabel.AB_PanelBK);
  387. AwardImages.Add(AwardImage0);
  388. AwardImages.Add(AwardImage1);
  389. AwardImages.Add(AwardImage2);
  390. PanelBK.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  391. ConfirmButton.onClick.AddListener(() => GetNextRechargeGiftAward(CurrentRechargeGift));
  392. LanguageManager.Add(Title, new MulLanStr(LanguageLabel.UI__AB_RechargeGiftTitle));
  393. LanguageManager.Add(ConfirmButtonText, new MulLanStr(LanguageLabel.Common__Confirm));
  394. }
  395. public static void GetAllRechargeGiftAward(int packID)
  396. {
  397. if (!GiftDictionary.ContainsKey(packID))
  398. {
  399. return;
  400. }
  401. CurrentRechargeGift = GiftDictionary[packID];
  402. if (!CurrentRechargeGift.IsAwardAvailable())
  403. {
  404. return;
  405. }
  406. PanelBK.TweenForCG();
  407. GetNextRechargeGiftAward(CurrentRechargeGift);
  408. }
  409. private static void GetNextRechargeGiftAward(RechargeGift rechargeGift)
  410. {
  411. if (rechargeGift.RemainGiftAward == 0)
  412. {
  413. PanelBK.TweenBacCG();
  414. }
  415. else
  416. {
  417. KV<RechargeGift.GiftType, int> awardInfo;
  418. rechargeGift.GetOneGiftAward(out awardInfo);
  419. SetupRechargeGiftAwardUI(awardInfo);
  420. }
  421. }
  422. private static void SetupRechargeGiftAwardUI(KV<RechargeGift.GiftType, int> awardInfo)
  423. {
  424. if (awardInfo.Key == RechargeGift.GiftType.花朵)
  425. {
  426. AwardImages.Remove(FlowerAwardImage);
  427. AwardImages.Insert(0 ,FlowerAwardImage);
  428. }
  429. else
  430. {
  431. AwardImages.Remove(FlowerAwardImage);
  432. AwardImages.Add(FlowerAwardImage);
  433. }
  434. if (awardInfo.Key == RechargeGift.GiftType.金币)
  435. {
  436. SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.75f, 0.75f);
  437. Description.text = AmountTextPrefix + awardInfo.Value;
  438. }
  439. else if (awardInfo.Key == RechargeGift.GiftType.钻石)
  440. {
  441. SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.75f, 0.75f);
  442. Description.text = AmountTextPrefix + awardInfo.Value;
  443. }
  444. else if (awardInfo.Key == RechargeGift.GiftType.花朵)
  445. {
  446. FlowerInfo flowerInfo = (FlowerInfo) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.3f, 0.3f);
  447. Description.text = flowerInfo.Name;
  448. }
  449. else if (awardInfo.Key == RechargeGift.GiftType.精灵)
  450. {
  451. SkillRoot skillRoot = (SkillRoot) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
  452. Description.text = skillRoot.Name;
  453. }
  454. else if (awardInfo.Key == RechargeGift.GiftType.服装)
  455. {
  456. CloseItem closeItem = (CloseItem) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 1f, 1f);
  457. Description.text = closeItem.Name;
  458. }
  459. else if (awardInfo.Key == RechargeGift.GiftType.礼包)
  460. {
  461. SkillRoot skillRoot = (SkillRoot) SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
  462. Description.text = skillRoot.Name;
  463. }
  464. else if (awardInfo.Key == RechargeGift.GiftType.开垦土地)
  465. {
  466. SetupRechargeGiftAwardUI(awardInfo.Key, awardInfo.Value, AwardImages, 0.4f, 0.4f);
  467. Description.text = AmountTextPrefix + awardInfo.Value;
  468. }
  469. else
  470. {
  471. throw new Exception();
  472. }
  473. }
  474. private static object SetupRechargeGiftAwardUI(RechargeGift.GiftType type, int id, List<Image> images, float deltaSizeX, float deltaSizeY)
  475. {
  476. if (type == RechargeGift.GiftType.花朵)
  477. {
  478. for (int i = 1; i < images.Count; i++)
  479. {
  480. images[i].transform.localPosition = new Vector3();
  481. }
  482. }
  483. else
  484. {
  485. for (int i = 0; i < images.Count - 1; i++)
  486. {
  487. images[i].transform.localPosition = new Vector3();
  488. }
  489. }
  490. for (int i = 0; i < images.Count; i++)
  491. {
  492. images[i].transform.SetActive(false);
  493. }
  494. if (type == RechargeGift.GiftType.金币)
  495. {
  496. images[0].transform.SetActive(true);
  497. images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Gold, Folder.Atlas);
  498. images[0].SetNativeSize();
  499. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  500. return null;
  501. }
  502. else if (type == RechargeGift.GiftType.钻石)
  503. {
  504. images[0].transform.SetActive(true);
  505. images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Diamond, Folder.Atlas);
  506. images[0].SetNativeSize();
  507. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  508. return null;
  509. }
  510. else if (type == RechargeGift.GiftType.花朵)
  511. {
  512. FlowerInfo flowerInfo = GardenManager.FlowerInfoDictionary[id];
  513. images[0].transform.SetActive(true);
  514. images[0].sprite = flowerInfo.Icon;
  515. images[0].SetNativeSize();
  516. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  517. return flowerInfo;
  518. }
  519. else if (type == RechargeGift.GiftType.精灵)
  520. {
  521. string abilityFullId = SkillRoot.AbilityFullIDPrefix + id;
  522. SkillRoot skillRoot = Manager.SkillDictionary[abilityFullId];
  523. images[0].transform.SetActive(true);
  524. images[0].sprite = skillRoot.Icon;
  525. images[0].SetNativeSize();
  526. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  527. return skillRoot;
  528. }
  529. else if (type == RechargeGift.GiftType.服装)
  530. {
  531. images[0].SetNativeSize();
  532. images[1].SetNativeSize();
  533. images[2].SetNativeSize();
  534. CloseItem closeItem = PlayerManager.CloseItemDictionary[id];
  535. float newSize = closeItem.PixelSize / closeItem.Sprites[0].rect.width * deltaSizeX;
  536. closeItem.SetupUI(newSize, new Vector2(), images[0], images[1], images[2]);
  537. return closeItem;
  538. }
  539. else if (type == RechargeGift.GiftType.礼包)
  540. {
  541. string packFullId = SkillRoot.PackFullIDPrefix + id;
  542. SkillRoot skillRoot = Manager.SkillDictionary[packFullId];
  543. images[0].transform.SetActive(true);
  544. images[0].sprite = skillRoot.Icon;
  545. images[0].SetNativeSize();
  546. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  547. return skillRoot;
  548. }
  549. else if (type == RechargeGift.GiftType.开垦土地)
  550. {
  551. images[0].transform.SetActive(true);
  552. images[0].sprite = ResourceManager.LoadSprite(ResourceLabel.Slot, Folder.Scene);
  553. images[0].SetNativeSize();
  554. images[0].rectTransform.Resize(true, deltaSizeX, deltaSizeY);
  555. return null;
  556. }
  557. else
  558. {
  559. throw new Exception();
  560. }
  561. }
  562. }