MatchingCompetitionWorksView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using cfg.GfgCfg;
  4. using ET;
  5. using FairyGUI;
  6. using UI.MatchingCompetition;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. class MatchingCompetitionWorksView : BaseWindow
  11. {
  12. private UI_MatchingCompetitionWorksUI _ui;
  13. private int _currentIndex = 0;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. }
  20. _ui = null;
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_MatchingCompetitionWorksUI.PACKAGE_NAME;
  27. _ui = UI_MatchingCompetitionWorksUI.Create();
  28. this.viewCom = _ui.target;
  29. isReturnView = true;
  30. isfullScreen = true;
  31. _ui.m_worksList.itemRenderer = RenderRankList;
  32. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  38. }
  39. protected override void RemoveEventListener()
  40. {
  41. base.RemoveEventListener();
  42. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. _ui.m_bg.url = ResPathUtil.GetBgImgPath("pxs_bj");
  48. _ui.m_titleText.text = CommonDataManager.Tables.TblJudgingRoundOpenCfg.DataList[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1].Name;
  49. UpdateView();
  50. }
  51. protected override void OnHide()
  52. {
  53. base.OnHide();
  54. }
  55. private void UpdateView()
  56. {
  57. if(MatchingCompetitionDataManager.Instance._BeforeWorksList.Count == 0)
  58. {
  59. _ui.m_descText.visible = true;
  60. }
  61. else
  62. {
  63. _ui.m_descText.visible = false;
  64. }
  65. _ui.m_worksList.numItems = MatchingCompetitionDataManager.Instance._BeforeWorksList.Count;
  66. }
  67. private void RenderRankList(int index, GObject obj)
  68. {
  69. UI_Component5 item = UI_Component5.Proxy(obj);
  70. JudgingRoundOpenCfg judingCfg = CommonDataManager.Tables.TblJudgingRoundOpenCfg.GetOrDefault(MatchingCompetitionDataManager.Instance._BeforeWorksList[index].WorksInfo.OldJudgingRoundOpenId);
  71. item.m_seasonText.text = string.Format("第{0}期",MatchingCompetitionDataManager.Instance._BeforeWorksList[index].WorksInfo.OldJudgingRoundOpenId.ToString());
  72. item.m_seasonName.text = judingCfg.Name;
  73. item.m_openTime.visible = false;
  74. //string themeTime = TimeUtil.FormattingTimeTo_yyyMMdd2(MatchingCompetitionDataManager.Instance._BeforeWorksList[index]);
  75. item.m_playerImage.texture = MatchingCompetitionDataManager.Instance._BeforeWorksList[index].Ntexture;
  76. if (item.target.data == null)
  77. {
  78. item.target.onClick.Add(OnClickBtnItem);
  79. }
  80. item.target.data = index;
  81. UI_Component5.ProxyEnd();
  82. }
  83. private async void OnClickBtnItem(EventContext context)
  84. {
  85. GObject item = context.sender as GObject;
  86. int index = (int)item.data +1;
  87. bool result = await MatchingCompetitionSproxy.ReqBeforeRank(index);
  88. if(result)
  89. {
  90. ViewManager.Show<MatchingCompetitionWorksListView>(index);
  91. }
  92. }
  93. private void OnClickBtnBack()
  94. {
  95. ViewManager.GoBackFrom(typeof(MatchingCompetitionWorksView).FullName);
  96. }
  97. }
  98. }