MatchingCompetitionGatheringView.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. //搭配赛集合期间
  10. class MatchingCompetitionGatheringView : BaseWindow
  11. {
  12. private UI_MatchingCompetitionGatheringUI _ui;
  13. private ValueBarController _valueBarController;
  14. private int SuitID;
  15. private EffectUI _effectUI1;
  16. public override void Dispose()
  17. {
  18. EffectUIPool.Recycle(_effectUI1);
  19. _effectUI1 = null;
  20. if (_valueBarController != null)
  21. {
  22. _valueBarController.Dispose();
  23. _valueBarController = null;
  24. }
  25. if (_ui != null)
  26. {
  27. _ui.Dispose();
  28. }
  29. _ui = null;
  30. base.Dispose();
  31. }
  32. protected override void OnInit()
  33. {
  34. base.OnInit();
  35. packageName = UI_MatchingCompetitionGatheringUI.PACKAGE_NAME;
  36. _ui = UI_MatchingCompetitionGatheringUI.Create();
  37. this.viewCom = _ui.target;
  38. isReturnView = true;
  39. isfullScreen = true;
  40. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  41. _ui.m_btnUploadWorks.onClick.Add(OnClickBtnUpload);
  42. _ui.m_btnShop.onClick.Add(OnClickBtnShop);
  43. _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
  44. }
  45. protected override void AddEventListener()
  46. {
  47. base.AddEventListener();
  48. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  49. }
  50. protected override void RemoveEventListener()
  51. {
  52. base.RemoveEventListener();
  53. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView);
  54. }
  55. protected override void OnShown()
  56. {
  57. base.OnShown();
  58. _ui.m_bg.url = ResPathUtil.GetBgImgPath("pxs_bj");
  59. _ui.m_c1.selectedIndex = 1;
  60. JudgingRoundOpenCfg judgingCfg = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1];
  61. SuitID = judgingCfg.ShowSuit;
  62. _ui.m_titleText.text = judgingCfg.Name;
  63. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(SuitID);
  64. _ui.m_suitName.text = suitCfg.name;
  65. UpdateView();
  66. Timers.inst.AddUpdate(UpdateTime);
  67. }
  68. protected override void OnHide()
  69. {
  70. DressUpObjUI dressUpObjUI = _ui.m_suitShow.data as DressUpObjUI;
  71. if (dressUpObjUI != null)
  72. {
  73. dressUpObjUI.Dispose();
  74. }
  75. _ui.m_suitShow.data = null;
  76. base.OnHide();
  77. Timers.inst.Remove(UpdateTime);
  78. }
  79. private void UpdateView()
  80. {
  81. if (MatchingCompetitionDataManager.Instance.MyNtextture == null)
  82. {
  83. DressUpObjUI dressUpObjUI;
  84. if (_ui.m_suitShow.data == null)
  85. {
  86. _ui.m_suitShow.data = new DressUpObjUI("SceneSuitFoster");
  87. }
  88. bool showAction = SuitCfgArray.Instance.CheckSuitHasAction(SuitID) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(SuitID);
  89. dressUpObjUI = _ui.m_suitShow.data as DressUpObjUI;
  90. dressUpObjUI.ResetSceneObj(100, false, true, null, false);
  91. dressUpObjUI.dressUpObj.PutOnSuitCfg(SuitID, showAction, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
  92. dressUpObjUI.UpdateWrapper(_ui.m_suitShow);
  93. }
  94. else
  95. {
  96. DressUpObjUI dressUpObjUI = _ui.m_suitShow.data as DressUpObjUI;
  97. if (dressUpObjUI != null)
  98. {
  99. dressUpObjUI.Dispose();
  100. }
  101. _ui.m_suitShow.data = null;
  102. _ui.m_playerImage.texture = MatchingCompetitionDataManager.Instance.MyNtextture;
  103. }
  104. }
  105. private void UpdateTime(object param = null)
  106. {
  107. long endTime = MatchingCompetitionDataManager.Instance.MatchingEndTimes;
  108. long curTime = TimeHelper.ServerNow();
  109. if (MatchingCompetitionDataManager.Instance.MatchingState != 1)
  110. {
  111. Timers.inst.Remove(UpdateTime);
  112. PromptController.Instance.ShowFloatTextPrompt("投稿时间已到!");
  113. ViewManager.GoBackFrom(typeof(MatchingCompetitionGatheringView).FullName);
  114. return;
  115. }
  116. if (endTime < curTime + 1)
  117. {
  118. Timers.inst.Remove(UpdateTime);
  119. return;
  120. }
  121. TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
  122. _ui.m_timeText.text = "投稿剩余时间:" + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
  123. }
  124. private void OnClickBtnBack()
  125. {
  126. ViewManager.GoBackFrom(typeof(MatchingCompetitionGatheringView).FullName);
  127. }
  128. private void OnClickBtnUpload()
  129. {
  130. ViewManager.Show<DressUpView>(2, false);
  131. }
  132. private void OnClickBtnShop()
  133. {
  134. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, 3 });
  135. }
  136. }
  137. }