LuckyBoxPreShowView.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. (item.data as ItemView).ImgHasVisible = ItemDataManager.GetItemNum(itemData.id) > 0;
  54. };
  55. listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
  56. listItem.m_list.ResizeToFit();
  57. listItem.target.height = listItem.m_list.y + listItem.m_list.height;
  58. }
  59. }
  60. }