MatchingCompetitionWorksView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  37. }
  38. protected override void RemoveEventListener()
  39. {
  40. base.RemoveEventListener();
  41. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. _ui.m_bg.url = ResPathUtil.GetBgImgPath("pxs_bj");
  47. _ui.m_titleText.text = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1].Name;
  48. UpdateView();
  49. }
  50. protected override void OnHide()
  51. {
  52. base.OnHide();
  53. }
  54. private void UpdateView()
  55. {
  56. if(MatchingCompetitionDataManager.Instance._BeforeWorksList.Count == 0)
  57. {
  58. _ui.m_descText.visible = true;
  59. }
  60. else
  61. {
  62. _ui.m_descText.visible = false;
  63. }
  64. _ui.m_worksList.numItems = MatchingCompetitionDataManager.Instance._BeforeWorksList.Count;
  65. }
  66. private void RenderRankList(int index, GObject obj)
  67. {
  68. UI_Component5 item = UI_Component5.Proxy(obj);
  69. JudgingRoundOpenCfg judingCfg = JudgingRoundOpenCfgArray.Instance.GetCfg(MatchingCompetitionDataManager.Instance._BeforeWorksList[index].WorksInfo.OldJudgingRoundOpenId);
  70. item.m_seasonText.text = string.Format("第{0}期",MatchingCompetitionDataManager.Instance._BeforeWorksList[index].WorksInfo.OldJudgingRoundOpenId.ToString());
  71. item.m_seasonName.text = judingCfg.Name;
  72. item.m_openTime.visible = false;
  73. //string themeTime = TimeUtil.FormattingTimeTo_yyyMMdd2(MatchingCompetitionDataManager.Instance._BeforeWorksList[index]);
  74. item.m_playerImage.texture = MatchingCompetitionDataManager.Instance._BeforeWorksList[index].Ntexture;
  75. if (item.target.data == null)
  76. {
  77. item.target.onClick.Add(OnClickBtnItem);
  78. }
  79. item.target.data = index;
  80. UI_Component5.ProxyEnd();
  81. }
  82. private async void OnClickBtnItem(EventContext context)
  83. {
  84. GObject item = context.sender as GObject;
  85. int index = (int)item.data +1;
  86. bool result = await MatchingCompetitionSproxy.ReqBeforeRank(index);
  87. if(result)
  88. {
  89. ViewManager.Show<MatchingCompetitionWorksListView>(index);
  90. }
  91. }
  92. private void OnClickBtnBack()
  93. {
  94. ViewManager.GoBackFrom(typeof(MatchingCompetitionWorksView).FullName);
  95. }
  96. }
  97. }