LuckyBoxPreShowView.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. _ui = UI_LuckyBoxPreShowUI.Create();
  24. this.viewCom = _ui.target;
  25. this.viewCom.Center();
  26. this.modal = true;
  27. }
  28. protected override void OnShown()
  29. {
  30. base.OnShown();
  31. string probShow = LuckyBoxDataManager.Instance.probShow;
  32. probShow = probShow.Replace("\\n", "\n");
  33. _ui.m_compText.m_txtShow.text = probShow;
  34. _bonusList = LuckyBoxDataManager.Instance.GetCurrentShowList();
  35. _ui.m_list.RemoveChildrenToPool();
  36. _ui.m_list.itemRenderer = ListItemRenderer;
  37. _ui.m_list.numItems = _bonusList.Count;
  38. }
  39. protected override void OnHide()
  40. {
  41. base.OnHide();
  42. _ui.m_list.RemoveChildrenToPool();
  43. }
  44. private void ListItemRenderer(int index, GObject item)
  45. {
  46. UI_CompLuckyBoxBonusListItem listItem = UI_CompLuckyBoxBonusListItem.Proxy(item);
  47. LuckyBoxBonusData luckyBoxBonusData = _bonusList[index];
  48. listItem.m_txtName.text = luckyBoxBonusData.name;
  49. listItem.m_list.itemRenderer = (int index, GObject item) =>
  50. {
  51. ItemData itemData = luckyBoxBonusData.itemList[index] as ItemData;
  52. if (item.data == null)
  53. {
  54. item.data = new ItemView(item as GComponent);
  55. }
  56. (item.data as ItemView).SetData(itemData);
  57. (item.data as ItemView).ShowHasCount = false;
  58. (item.data as ItemView).ImgHasVisible = ItemDataManager.GetItemNum(itemData.id) > 0;
  59. };
  60. listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
  61. listItem.m_list.ResizeToFit();
  62. listItem.target.height = listItem.m_list.y + listItem.m_list.height;
  63. UI_CompLuckyBoxBonusListItem.ProxyEnd();
  64. }
  65. }
  66. }