DailyTaskRewardView.cs 1.7 KB

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