MatchingCompetitionUpLoadView.cs 10 KB

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