MatchingCompetitionWorksView.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. _ui.m_titleText.text = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason].Name;
  42. UpdateView();
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. }
  48. protected override void RemoveEventListener()
  49. {
  50. base.RemoveEventListener();
  51. }
  52. private void UpdateView()
  53. {
  54. _ui.m_worksList.numItems = MatchingCompetitionDataManager.Instance._BeforeWorksList.Count;
  55. }
  56. private void RenderRankList(int index, GObject obj)
  57. {
  58. UI_Component5 item = UI_Component5.Proxy(obj);
  59. if (item.target.data == null)
  60. {
  61. item.target.onClick.Add(OnClickBtnItem);
  62. }
  63. item.target.data = index;
  64. UI_Component5.ProxyEnd();
  65. }
  66. private async void OnClickBtnItem(EventContext context)
  67. {
  68. GObject item = context.sender as GObject;
  69. int index = (int)item.data +1;
  70. bool result = await MatchingCompetitionSproxy.ReqBeforeRank(index);
  71. if(result)
  72. {
  73. ViewManager.Show<MatchingCompetitionWorksListView>(index);
  74. }
  75. }
  76. private void OnClickBtnBack()
  77. {
  78. ViewManager.GoBackFrom(typeof(MatchingCompetitionWorksView).FullName);
  79. }
  80. }
  81. }