OpenBattlePassView.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 itemInfos = (List<KeyValuePair<int, int>>)obj.parent.data;
  43. var itemInfo = itemInfos[index];
  44. ItemUtil.CreateItemView(new[]{itemInfo.Key,itemInfo.Value}, obj as GComponent);
  45. }
  46. private void SetPrizeData()
  47. {
  48. //获取所有特别奖励数据
  49. var dataManager = BattlePassTaskDataManager.Instance;
  50. var allSpecialCfg = dataManager.GetAllSpecialCfg();
  51. _ui.m_Rewards.data = allSpecialCfg;
  52. _ui.m_Rewards.numItems = allSpecialCfg.Count;
  53. }
  54. }
  55. }