MatchingCompetitionUpLoadView.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using ET;
  5. using FairyGUI;
  6. using UI.MatchingCompetition;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. //搭配赛评选期间
  11. class MatchingCompetitionUpLoadView : BaseWindow
  12. {
  13. private UI_MatchingCompetitionUpLoadUI _ui;
  14. private GameObject _sceneObject;
  15. private float countTimeSpeed = 0.001f;
  16. private bool isCountTime = false;
  17. public override void Dispose()
  18. {
  19. if (_sceneObject != null)
  20. {
  21. PrefabManager.Instance.Restore(_sceneObject);
  22. _sceneObject = null;
  23. }
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. }
  28. _ui = null;
  29. base.Dispose();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. packageName = UI_MatchingCompetitionUpLoadUI.PACKAGE_NAME;
  35. _ui = UI_MatchingCompetitionUpLoadUI.Create();
  36. this.viewCom = _ui.target;
  37. isReturnView = true;
  38. isfullScreen = true;
  39. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  40. _ui.m_btnUploadWorks.onClick.Add(OnClickBtnUpload);
  41. _ui.m_btnShop.onClick.Add(OnClickBtnShop);
  42. _ui.m_btnMyWorks.onClick.Add(OnClickBtnMyWorks);
  43. _ui.m_btnRank.onClick.Add(OnClickBtnRank);
  44. _ui.m_btnLook.onClick.Add(OnClickBtnLook);
  45. _ui.m_btnExchage.onClick.Add(OnClickBtnExchange);
  46. _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. _ui.m_bg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
  52. _ui.m_c1.selectedIndex = MatchingCompetitionDataManager.Instance.MatchingState;
  53. _ui.m_titleText.text = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason].Name;
  54. isCountTime = false;
  55. UpdateView();
  56. UpdateHead();
  57. UpdateDress();
  58. Timers.inst.AddUpdate(UpdateTime);
  59. }
  60. protected override void OnHide()
  61. {
  62. if (_sceneObject != null)
  63. {
  64. PrefabManager.Instance.Restore(_sceneObject);
  65. _sceneObject = null;
  66. }
  67. Timers.inst.Remove(UpdateTime);
  68. Timers.inst.Remove(UpdateCountTime);
  69. base.OnHide();
  70. }
  71. protected override void AddEventListener()
  72. {
  73. base.AddEventListener();
  74. EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH,UpdateDress);
  75. }
  76. protected override void RemoveEventListener()
  77. {
  78. base.RemoveEventListener();
  79. EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateDress);
  80. }
  81. private async void UpdateDress()
  82. {
  83. if (MatchingOneDataManager.Instance.MathingDressDate.actionId != 0)
  84. {
  85. _ui.m_bg.visible = false;
  86. _ui.m_playerImage.visible = false;
  87. MatchingOneDataManager.Instance.itemGameObjs.Clear();
  88. PhotographDataManager.Instance.itemGameObjs.Clear();
  89. PhotographDataManager.Instance.dressUpObj?.Dispose();
  90. PhotographDataManager.Instance.dressUpObj = new DressUpObj();
  91. if (_sceneObject == null)
  92. {
  93. _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("ScenePhotograph"));
  94. }
  95. PhotographSceneManager.Instance.sceneObject = _sceneObject;
  96. if(MatchingOneDataManager.Instance.DressUpBgID == 0)
  97. {
  98. PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(180001));
  99. }
  100. else
  101. {
  102. PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(MatchingOneDataManager.Instance.DressUpBgID));
  103. }
  104. PhotographSceneManager.Instance.AddBodyItem();
  105. GameObject bodyParent = _sceneObject.transform.Find("Scene/Role").gameObject;
  106. PhotographDataManager.Instance.dressUpObj.setSceneObj(_sceneObject, false, true, bodyParent, false, null);
  107. PhotographDataManager.Instance.dressUpObj.PutOnDressUpData(MatchingOneDataManager.Instance.MathingDressDate);
  108. //对搭配赛特殊处理
  109. for (int i = 0; i < MatchingOneDataManager.Instance.DressPropIdList.Count; i++)
  110. {
  111. if (MatchingOneDataManager.Instance.DressPropIdList[i] == MatchingOneDataManager.Instance.roleID)
  112. {
  113. continue;
  114. }
  115. else
  116. {
  117. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(MatchingCompetitionDataManager.Instance.DressPropIdList[i]);
  118. MatchingCompetitionDataManager.Instance.AddSceneItem(itemCfg, true);
  119. }
  120. }
  121. await Task.Delay(100);
  122. MatchingOneDataManager.Instance.InsertGameObjectList();
  123. for (int i = 0; i < MatchingOneDataManager.Instance.TransformDataList.Count; i++)
  124. {
  125. TransformData itemdata = MatchingOneDataManager.Instance.TransformDataList[i];
  126. GameObject itemGObj = MatchingOneDataManager.Instance.itemGameObjs[i];
  127. MatchingOneDataManager.Instance.itemGameObjs[i].transform.position = itemdata.position;
  128. MatchingOneDataManager.Instance.itemGameObjs[i].transform.Rotate(itemGObj.transform.eulerAngles.x, itemGObj.transform.eulerAngles.y, itemdata.rotationZ);
  129. MatchingOneDataManager.Instance.itemGameObjs[i].transform.localScale = itemdata.scale;
  130. PhotographUtil.Instance.ChangeLayer(MatchingOneDataManager.Instance.itemGameObjs[i], i * PhotographDataManager.layerCount, "up");
  131. }
  132. }
  133. else
  134. {
  135. _ui.m_bg.visible = true;
  136. _ui.m_playerImage.visible = true;
  137. _ui.m_playerImage.texture = MatchingOneDataManager.Instance.OneRoleInfo.Ntexture;
  138. }
  139. }
  140. private void UpdateView()
  141. {
  142. _ui.m_countTime.fillAmount = 0;
  143. _ui.m_countTime.visible = false;
  144. }
  145. private void UpdateHead()
  146. {
  147. RoleInfoManager.Instance.UpdateHead(_ui.m_playerHead.m_head, MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo.HeadItemId, MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo.HeadBorderItemId);
  148. _ui.m_playerHead.m_nameText.text = MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo.RoleName.ToString();
  149. _ui.m_playerHead.m_countText.text = MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo.Score.ToString();
  150. }
  151. private void UpdateTime(object param = null)
  152. {
  153. long endTime = MatchingCompetitionDataManager.Instance.MatchingEndTimes;
  154. long curTime = TimeHelper.ServerNow();
  155. if (endTime < curTime + 1)
  156. {
  157. Timers.inst.Remove(UpdateTime);
  158. return;
  159. }
  160. TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
  161. _ui.m_timeText.text = "评选剩余时间:" + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
  162. }
  163. private void UpdateCountTime(object param = null)
  164. {
  165. if(_ui.m_countTime.fillAmount <=0)
  166. {
  167. _ui.m_countTime.fillAmount = 0;
  168. _ui.m_countTime.visible = false;
  169. isCountTime = false;
  170. Timers.inst.Remove(UpdateCountTime);
  171. }
  172. _ui.m_countTime.fillAmount -= countTimeSpeed;
  173. }
  174. private void OnClickBtnBack()
  175. {
  176. ViewManager.GoBackFrom(typeof(MatchingCompetitionUpLoadView).FullName);
  177. }
  178. private async void OnClickBtnUpload()
  179. {
  180. if(MatchingCompetitionDataManager.Instance.MatchingState == 3)
  181. {
  182. PromptController.Instance.ShowFloatTextPrompt("结算期间无法选择!");
  183. return;
  184. }
  185. //先获取两个玩家信息
  186. bool resulst = await MatchingCompetitionSproxy.ReqGetTwoPlayers();
  187. if(resulst)
  188. {
  189. ViewManager.Show<MatchingCompetitionSelectView>();
  190. }
  191. }
  192. private void OnClickBtnShop()
  193. {
  194. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_GIFT_BAG, ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY });
  195. }
  196. private void OnClickBtnMyWorks()
  197. {
  198. ViewManager.Show<PoemPhotoView>(2);
  199. }
  200. private async void OnClickBtnRank()
  201. {
  202. bool result = await MatchingCompetitionSproxy.ReqCurrentRank();
  203. if(result)
  204. {
  205. ViewManager.Show<MatchingCompetitionRankView>();
  206. }
  207. else
  208. {
  209. PromptController.Instance.ShowFloatTextPrompt("暂无玩家上榜!");
  210. }
  211. }
  212. private async void OnClickBtnExchange()
  213. {
  214. if (isCountTime)
  215. {
  216. PromptController.Instance.ShowFloatTextPrompt("刷新冷却中,请耐心等待!");
  217. return;
  218. }
  219. isCountTime = true;
  220. _ui.m_countTime.visible = true;
  221. _ui.m_countTime.fillAmount = 1.0f;
  222. Timers.inst.AddUpdate(UpdateCountTime);
  223. ViewManager.Show<ModalStatusView>("刷新中...");
  224. bool result = await MatchingCompetitionSproxy.ReqGetOnePlayers();
  225. if (result)
  226. {
  227. //UpdateView();
  228. UpdateHead();
  229. UpdateDress();
  230. ViewManager.Hide<ModalStatusView>();
  231. }
  232. ViewManager.Hide<ModalStatusView>();
  233. }
  234. private void OnClickBtnLook()
  235. {
  236. List<int> AllIdList = new List<int>();
  237. foreach (var info in MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo.CollocationInfoList)
  238. {
  239. AllIdList.Add(info.ItemId);
  240. }
  241. MatchingCompetitionDataManager.Instance.DetailNtexture = MatchingOneDataManager.Instance.OneRoleInfo.Ntexture;
  242. ViewManager.Show<MatchingCompetitionDetailView>(AllIdList);
  243. }
  244. }
  245. }