LuckyBoxPreShowView.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_BonusItem1 goodsItem = UI_BonusItem1.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. };
  55. listItem.m_list.onClickItem.Add((EventContext context) =>
  56. {
  57. GComponent item = context.data as GComponent;
  58. int itemID = (int)item.data;
  59. GoodsItemTipsController.ShowItemTips(itemID);
  60. });
  61. listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
  62. listItem.m_list.ResizeToFit();
  63. listItem.target.height = listItem.m_list.y + listItem.m_list.height;
  64. }
  65. }
  66. }