MatchingCompetitionGatheringView.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. _ui.m_playerImage.texture = null;
  84. DressUpObjUI dressUpObjUI;
  85. if (_ui.m_suitShow.data == null)
  86. {
  87. _ui.m_suitShow.data = new DressUpObjUI("SceneSuitFoster");
  88. }
  89. bool showAction = SuitCfgArray.Instance.CheckSuitHasAction(SuitID) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(SuitID);
  90. dressUpObjUI = _ui.m_suitShow.data as DressUpObjUI;
  91. dressUpObjUI.ResetSceneObj(100, false, true, null, false);
  92. dressUpObjUI.dressUpObj.PutOnSuitCfg(SuitID, showAction, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
  93. dressUpObjUI.UpdateWrapper(_ui.m_suitShow);
  94. }
  95. else
  96. {
  97. DressUpObjUI dressUpObjUI = _ui.m_suitShow.data as DressUpObjUI;
  98. if (dressUpObjUI != null)
  99. {
  100. dressUpObjUI.Dispose();
  101. }
  102. _ui.m_suitShow.data = null;
  103. _ui.m_playerImage.texture = MatchingCompetitionDataManager.Instance.MyNtextture;
  104. }
  105. }
  106. private void UpdateTime(object param = null)
  107. {
  108. long endTime = MatchingCompetitionDataManager.Instance.MatchingEndTimes;
  109. long curTime = TimeHelper.ServerNow();
  110. if (MatchingCompetitionDataManager.Instance.MatchingState != 1)
  111. {
  112. Timers.inst.Remove(UpdateTime);
  113. PromptController.Instance.ShowFloatTextPrompt("投稿时间已到!");
  114. ViewManager.GoBackFrom(typeof(MatchingCompetitionGatheringView).FullName);
  115. return;
  116. }
  117. if (endTime < curTime + 1)
  118. {
  119. Timers.inst.Remove(UpdateTime);
  120. return;
  121. }
  122. TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
  123. _ui.m_timeText.text = "投稿剩余时间:" + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
  124. }
  125. private void OnClickBtnBack()
  126. {
  127. ViewManager.GoBackFrom(typeof(MatchingCompetitionGatheringView).FullName);
  128. }
  129. private void OnClickBtnUpload()
  130. {
  131. ViewManager.Show<DressUpView>(2, false);
  132. }
  133. private void OnClickBtnShop()
  134. {
  135. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, 3 });
  136. }
  137. }
  138. }