LuckyBoxPreShowView.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UI.LuckyBox;
  2. using UI.CommonGame;
  3. using System.Collections.Generic;
  4. using FairyGUI;
  5. namespace GFGGame
  6. {
  7. public class LuckyBoxPreShowView : BaseWindow
  8. {
  9. private UI_LuckyBoxPreShowUI _ui;
  10. private List<LuckyBoxBonusData> _bonusList;
  11. public override void Dispose()
  12. {
  13. base.Dispose();
  14. }
  15. protected override void OnInit()
  16. {
  17. base.OnInit();
  18. _ui = UI_LuckyBoxPreShowUI.Create();
  19. this.viewCom = _ui.target;
  20. this.viewCom.Center();
  21. this.modal = true;
  22. }
  23. protected override void OnShown()
  24. {
  25. base.OnShown();
  26. string probShow = LuckyBoxDataManager.Instance.probShow;
  27. probShow = probShow.Replace("\\n", "\n");
  28. _ui.m_compText.m_txtShow.text = probShow;
  29. _bonusList = LuckyBoxDataManager.Instance.GetCurrentShowList();
  30. _ui.m_list.RemoveChildrenToPool();
  31. _ui.m_list.itemRenderer = ListItemRenderer;
  32. _ui.m_list.numItems = _bonusList.Count;
  33. }
  34. protected override void OnHide()
  35. {
  36. base.OnHide();
  37. _ui.m_list.RemoveChildrenToPool();
  38. }
  39. private void ListItemRenderer(int index, GObject item)
  40. {
  41. UI_CompLuckyBoxBonusListItem listItem = UI_CompLuckyBoxBonusListItem.Proxy(item);
  42. LuckyBoxBonusData luckyBoxBonusData = _bonusList[index];
  43. listItem.m_txtName.text = luckyBoxBonusData.name;
  44. listItem.m_list.itemRenderer = (int index, GObject item) =>
  45. {
  46. ItemData itemData = luckyBoxBonusData.itemList[index] as ItemData;
  47. if (item.data == null)
  48. {
  49. item.data = new ItemView(item as GComponent);
  50. }
  51. (item.data as ItemView).SetData(itemData);
  52. (item.data as ItemView).TxtHasCountVisble = false;
  53. };
  54. listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
  55. listItem.m_list.ResizeToFit();
  56. listItem.target.height = listItem.m_list.y + listItem.m_list.height;
  57. }
  58. }
  59. }