LuckyBoxPreShowView.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // UI_ComItem goodsItem = UI_ComItem.Proxy(item);
  47. ItemData itemData = luckyBoxBonusData.itemList[index] as ItemData;
  48. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  49. // goodsItem.m_iconOwned.visible = ItemDataManager.GetItemNum(itemData.id) > 0;
  50. // goodsItem.m_txtName.text = itemCfg.name;
  51. // goodsItem.m_iconItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  52. // RarityIconController.UpdateRarityIcon(goodsItem.m_iconItem.m_rarity, itemData.id, true);
  53. // goodsItem.target.data = itemData.id;
  54. // ItemData reward = ItemUtil.createItemData(_cfg.rewardsArr[index]);
  55. if (item.data == null)
  56. {
  57. item.data = new ItemView(item as GComponent);
  58. }
  59. (item.data as ItemView).SetData(itemData);
  60. (item.data as ItemView).TxtHasCountVisble = false;
  61. };
  62. // listItem.m_list.onClickItem.Add((EventContext context) =>
  63. // {
  64. // GComponent item = context.data as GComponent;
  65. // int itemID = (int)item.data;
  66. // GoodsItemTipsController.ShowItemTips(itemID);
  67. // });
  68. listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
  69. listItem.m_list.ResizeToFit();
  70. // listItem.m_list.columnGap = 50;
  71. listItem.target.height = listItem.m_list.y + listItem.m_list.height;
  72. }
  73. }
  74. }