OpenBattlePassView.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.Task;
  5. namespace GFGGame
  6. {
  7. public class OpenBattlePassView : BaseWindow
  8. {
  9. private UI_OpenBattlePassUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_OpenBattlePassUI.PACKAGE_NAME;
  23. _ui = UI_OpenBattlePassUI.Create();
  24. viewCom = _ui.target;
  25. viewCom.Center();
  26. _ui.m_CloseBtn.onClick.Add(Hide);
  27. // clickBlankToClose = false;
  28. _ui.m_Rewards.itemRenderer = SpecialRewardRender;
  29. _ui.m_OpenBtn.onClick.Add(OnBtnOpenClick);
  30. }
  31. private void OnBtnOpenClick(EventContext context)
  32. {
  33. //TODO:打开购买界面
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. SetPrizeData();
  39. }
  40. private static void SpecialRewardRender(int index, GObject obj)
  41. {
  42. var item = UI_RewardIconYellow.Proxy(obj);
  43. var itemInfos = (List<KeyValuePair<int, long>>)obj.parent.data;
  44. // if (!(obj.parent.data is int[][] parentData))
  45. // {
  46. // UI_RewardIconYellow.ClearProxy();
  47. // return;
  48. // }
  49. var itemInfo = itemInfos[index];
  50. var itemId = itemInfo.Key;
  51. var num = itemInfo.Value;
  52. var itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  53. if (itemCfg != null)
  54. {
  55. item.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(itemCfg.res);
  56. item.m_num.text = num.ToString();
  57. }
  58. UI_RewardIconYellow.ProxyEnd();
  59. }
  60. private void SetPrizeData()
  61. {
  62. //获取所有特别奖励数据
  63. var dataManager = BattlePassTaskDataManager.Instance;
  64. var allSpecialCfg = dataManager.GetAllSpecialCfg();
  65. _ui.m_Rewards.data = allSpecialCfg;
  66. _ui.m_Rewards.numItems = allSpecialCfg.Count;
  67. }
  68. }
  69. }