MatchingCompetitionWorksView.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MatchingCompetition;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. class MatchingCompetitionWorksView : BaseWindow
  10. {
  11. private UI_MatchingCompetitionWorksUI _ui;
  12. private int _currentIndex = 0;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. }
  19. _ui = null;
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_MatchingCompetitionWorksUI.PACKAGE_NAME;
  26. _ui = UI_MatchingCompetitionWorksUI.Create();
  27. this.viewCom = _ui.target;
  28. isReturnView = true;
  29. isfullScreen = true;
  30. _ui.m_worksList.itemRenderer = RenderRankList;
  31. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  32. }
  33. protected override void AddEventListener()
  34. {
  35. base.AddEventListener();
  36. }
  37. protected override void OnShown()
  38. {
  39. base.OnShown();
  40. _ui.m_bg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
  41. UpdateView();
  42. }
  43. protected override void OnHide()
  44. {
  45. base.OnHide();
  46. }
  47. protected override void RemoveEventListener()
  48. {
  49. base.RemoveEventListener();
  50. }
  51. private void UpdateView()
  52. {
  53. _ui.m_worksList.numItems = MatchingCompetitionDataManager.Instance._BeforeWorksList.Count;
  54. }
  55. private void RenderRankList(int index, GObject obj)
  56. {
  57. UI_Component5 item = UI_Component5.Proxy(obj);
  58. if (item.target.data == null)
  59. {
  60. item.target.onClick.Add(OnClickBtnItem);
  61. }
  62. item.target.data = index;
  63. UI_Component5.ProxyEnd();
  64. }
  65. private void OnClickBtnItem(EventContext context)
  66. {
  67. GObject item = context.sender as GObject;
  68. int index = (int)item.data +1;
  69. ViewManager.Show<MatchingCompetitionWorksListView>(index);
  70. }
  71. private void OnClickBtnBack()
  72. {
  73. ViewManager.GoBackFrom(typeof(MatchingCompetitionWorksView).FullName);
  74. }
  75. }
  76. }