RechargeGiftManager.cs 22 KB

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