DailyTaskRewardView.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.DailyTask;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class DailyTaskRewardView : BaseWindow
  8. {
  9. private UI_DailyTaskRewardUI _ui;
  10. private DailyActiveRewardCfg _cfg;
  11. public override void Dispose()
  12. {
  13. base.Dispose();
  14. }
  15. protected override void OnInit()
  16. {
  17. base.OnInit();
  18. _ui = UI_DailyTaskRewardUI.Create();
  19. this.viewCom = _ui.target;
  20. this.viewCom.Center();
  21. this.modal = true;
  22. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  23. _ui.m_list.itemRenderer = ListItemRender;
  24. _ui.m_list.onClickItem.Add(OnClickListReward);
  25. }
  26. protected override void OnShown()
  27. {
  28. base.OnShown();
  29. _cfg = this.viewData as DailyActiveRewardCfg;
  30. _ui.m_list.numItems = _cfg.rewardsArr.Length;
  31. }
  32. protected override void OnHide()
  33. {
  34. base.OnHide();
  35. }
  36. private void ListItemRender(int index, GObject obj)
  37. {
  38. UI_ListItem item = UI_ListItem.Proxy(obj);
  39. item.target.data = _cfg.rewardsArr[index];
  40. ItemData reward = new ItemData();
  41. if (obj.data == null)
  42. {
  43. obj.data = new ItemView(obj as GComponent);
  44. }
  45. (obj.data as ItemView).SetData(reward);
  46. UI_ListItem.ClearProxy();
  47. }
  48. private void OnClickListReward(EventContext context)
  49. {
  50. ItemData data = (context.data as GObject).data as ItemData;
  51. GoodsItemTipsController.ShowItemTips(data.id);
  52. }
  53. }
  54. }