DaoYouLevelWidget.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Excel2Json;
  4. using Fort23.UTool;
  5. using GameLogic.Bag;
  6. namespace Fort23.Mono
  7. {
  8. [UIBinding(prefab = "DaoYouLevelWidget")]
  9. public partial class DaoYouLevelWidget : UIComponent
  10. {
  11. public DaoyouLevelupConfig _daoyouLevelupConfig;
  12. List<WidgetItem> _widgetItems = new List<WidgetItem>();
  13. private void Init()
  14. {
  15. }
  16. public override void AddEvent()
  17. {
  18. }
  19. public override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. }
  25. public async void CustomInit(AccountFileInfo.DaoYouData daoYouData, int configId)
  26. {
  27. _daoyouLevelupConfig = ConfigComponent.Instance.Get<DaoyouLevelupConfig>(configId);
  28. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  29. Text_Level.text = configId.ToString();
  30. for (var i = 0; i < _daoyouLevelupConfig.prizeID?.Length; i++)
  31. {
  32. WidgetItem widgetItem = await UIManager.Instance.CreateGComponent<WidgetItem>(null, ItemRoot);
  33. widgetItem.InitWidget(new ItemInfo(_daoyouLevelupConfig.prizeID[i], _daoyouLevelupConfig.prizeNum[i]));
  34. _widgetItems.Add(widgetItem);
  35. }
  36. if (daoyouModelConfig.EmotionLvforspecialGift.Contains(configId))
  37. {
  38. int index = daoyouModelConfig.EmotionLvforspecialGift.ToList().IndexOf(configId);
  39. WidgetItem widgetItem = await UIManager.Instance.CreateGComponent<WidgetItem>(null, ItemRoot);
  40. widgetItem.InitWidget(new ItemInfo(daoyouModelConfig.specialGiftID[index], daoyouModelConfig.specialGiftNum[index]));
  41. _widgetItems.Add(widgetItem);
  42. }
  43. if (daoYouData.awardLevels.Contains(configId))
  44. {
  45. Text_Tips.gameObject.SetActive(true);
  46. }
  47. else
  48. {
  49. Text_Tips.gameObject.SetActive(false);
  50. }
  51. }
  52. public override void DormancyObj()
  53. {
  54. foreach (var widgetItem in _widgetItems)
  55. {
  56. UIManager.Instance.DormancyGComponent(widgetItem);
  57. }
  58. _widgetItems.Clear();
  59. base.DormancyObj();
  60. }
  61. }
  62. }