MatchingCompetitionSproxy.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using ET;
  2. using GFGGame;
  3. using FairyGUI;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6. using System.Collections.Generic;
  7. namespace ET
  8. {
  9. public class M2C_NoticeMatchingStateHandler : AMHandler<S2C_PushJudgingRoundInfo>
  10. {
  11. protected override async ETTask Run(Session session, S2C_PushJudgingRoundInfo message)
  12. {
  13. MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason = message.JudgingRoundOpenId;
  14. MatchingCompetitionDataManager.Instance.MatchingEndTimes = message.PhaseEndTime;
  15. MatchingCompetitionDataManager.Instance.MatchingState = message.PhaseType;
  16. //await MatchingCompetitionSproxy.ReqMatchingCompetitionInfo();
  17. await ETTask.CompletedTask;
  18. }
  19. }
  20. }
  21. namespace GFGGame
  22. {
  23. public class MatchingCompetitionSproxy
  24. {
  25. //获取搭配评选赛信息
  26. public static async ETTask<bool> ReqMatchingCompetitionInfo()
  27. {
  28. S2C_GetJudgingRoundInfo response = (S2C_GetJudgingRoundInfo)await MessageHelper.SendToServer(new C2S_GetJudgingRoundInfo { });
  29. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  30. MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason = response.JudgingRoundOpenId;
  31. MatchingCompetitionDataManager.Instance.MatchingState = response.PhaseType;
  32. MatchingCompetitionDataManager.Instance.MatchingEndTimes = response.PhaseEndTime;
  33. MatchingCompetitionDataManager.Instance.MatchingRemainingTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.JudgingRoundSelNum);
  34. MatchingCompetitionDataManager.Instance.myWorks = response.MyWorks;
  35. if(response.MyWorks != null)
  36. {
  37. MatchingCompetitionDataManager.Instance.AllDressIDInfoList = response.MyWorks.CollocationInfoList;
  38. }
  39. else
  40. {
  41. MatchingCompetitionDataManager.Instance.AllDressIDInfoList = new List<CollocationInfo>();
  42. }
  43. MatchingCompetitionDataManager.Instance.AnalysisInfoToList();
  44. return true;
  45. }
  46. //获取搭配作品信息
  47. //public static async ETTask<bool> ReqMatchingCompetitionDressData()
  48. //{
  49. // var response = (S2C_RequestUpLoadJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RequestUpLoadJudgingRoundWorks {});
  50. // if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  51. // return true;
  52. //}
  53. //获取一个热门推荐的玩家
  54. public static async ETTask<bool> ReqGetOnePlayers()
  55. {
  56. var response = (S2C_GetOnePlayers)await MessageHelper.SendToServer(new C2S_GetOnePlayers { });
  57. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  58. MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo = response.JudgingRoundRole;
  59. if (response.JudgingRoundRole == null)
  60. {
  61. return false;
  62. }
  63. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingOneDataManager.Instance.OneRoleInfo));
  64. MatchingOneDataManager.Instance.AnalysisInfoToList();
  65. return true;
  66. }
  67. //上传作品信息
  68. public static async ETTask<object[]> UpLoadMatchingCompetitionDressData()
  69. {
  70. MatchingCompetitionDataManager.Instance.ConvertInfoToList();
  71. var response = (S2C_RequestUpLoadJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RequestUpLoadJudgingRoundWorks
  72. {
  73. PictureType = 1,
  74. BagId = MatchingCompetitionDataManager.Instance.DressUpBgID,
  75. ActionId = MatchingCompetitionDataManager.Instance.MathingDressDate.actionId,
  76. CollocationInfoList = MatchingCompetitionDataManager.Instance.AllDressIDInfoList
  77. });
  78. if (!(response is { Error: ErrorCode.ERR_Success })) return null;
  79. MatchingCompetitionDataManager.Instance.WorksID = response.WorksId;
  80. MatchingCompetitionDataManager.Instance.TempPictureUrl = response.TempPictureUrl;
  81. return new object[] { response.TempPictureUrl, response.WorksId };
  82. }
  83. //通知服务端上传成功
  84. public static async ETTask<bool> UploadSuccess()
  85. {
  86. var response = (S2C_NoticeJudgingRoundWorksUploaded)await MessageHelper.SendToServer(new C2S_NoticeJudgingRoundWorksUploaded
  87. {
  88. WorksId = MatchingCompetitionDataManager.Instance.WorksID
  89. }) ;
  90. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  91. return true;
  92. }
  93. //获取两个评选推荐的玩家
  94. public static async ETTask<bool> ReqGetTwoPlayers()
  95. {
  96. var response = (S2C_GetTwoPlayers)await MessageHelper.SendToServer(new C2S_GetTwoPlayers { });
  97. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  98. if(response.JudgingRoundRoleInfoList == null || response.JudgingRoundRoleInfoList.Count < 2)
  99. {
  100. return false;
  101. }
  102. MatchingCompetitionDataManager.Instance.MatchingRemainingTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.JudgingRoundSelNum);
  103. MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];
  104. if(response.JudgingRoundRoleInfoList[0] != null)
  105. {
  106. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingLeftDataManager.Instance.LeftRoleInfo));
  107. }
  108. MatchingLeftDataManager.Instance.AnalysisInfoToList();
  109. MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];
  110. if (response.JudgingRoundRoleInfoList[1] != null)
  111. {
  112. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingRightDataManager.Instance.RightRoleInfo));
  113. }
  114. MatchingRightDataManager.Instance.AnalysisInfoToList();
  115. return true;
  116. }
  117. //选择搭配作品
  118. public static async ETTask<bool> ReqCheckMatchingCompetitionWork(long workID,long anotherWorkId )
  119. {
  120. var response = (S2C_SelFavoriteWorks)await MessageHelper.SendToServer(new C2S_SelFavoriteWorks
  121. {
  122. WorksId = workID,
  123. AnotherWorksId = anotherWorkId
  124. }) ;
  125. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  126. if (response.JudgingRoundRoleInfoList == null || response.JudgingRoundRoleInfoList.Count < 2)
  127. {
  128. return false;
  129. }
  130. MatchingCompetitionDataManager.Instance.MatchingRemainingTimes = GameGlobal.myNumericComponent.GetAsInt(NumericType.JudgingRoundSelNum);
  131. if (MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId == workID)
  132. {
  133. MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];
  134. MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];
  135. }
  136. else
  137. {
  138. MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];
  139. MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];
  140. }
  141. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  142. return true;
  143. }
  144. //获取当前排行榜
  145. public static async ETTask<bool> ReqCurrentRank()
  146. {
  147. var response = (S2C_GetCurJudgingRoundRankList)await MessageHelper.SendToServer(new C2S_GetCurJudgingRoundRankList { });
  148. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  149. MatchingCompetitionDataManager.Instance._currentRankList.Clear();
  150. foreach (var item in response.JudgingRoundRoleInfoList)
  151. {
  152. MatchingPhotoWorksData data = new MatchingPhotoWorksData();
  153. data.JudgingInfo = item;
  154. MatchingCompetitionDataManager.Instance._currentRankList.Add(data);
  155. }
  156. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingCompetitionDataManager.Instance._currentRankList));
  157. return true;
  158. }
  159. //获取往期作品集
  160. public static async ETTask<bool> ReqBeforeWorks()
  161. {
  162. var response = (S2C_GetPreviousWorksCollection)await MessageHelper.SendToServer(new C2S_GetPreviousWorksCollection { });
  163. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  164. MatchingCompetitionDataManager.Instance._BeforeWorksList.Clear();
  165. foreach (var item in response.WorksCollectionList)
  166. {
  167. MatchingWorksData data = new MatchingWorksData();
  168. data.WorksInfo = item;
  169. MatchingCompetitionDataManager.Instance._BeforeWorksList.Add(data);
  170. }
  171. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingCompetitionDataManager.Instance._BeforeWorksList));
  172. return true;
  173. }
  174. //获取往期作品排行榜
  175. public static async ETTask<bool> ReqBeforeRank(int id)
  176. {
  177. var response = (S2C_GetOldJudgingRoundRankList)await MessageHelper.SendToServer(new C2S_GetOldJudgingRoundRankList { JudgingRoundOpenId = id});
  178. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  179. MatchingCompetitionDataManager.Instance._BeforeRankList.Clear();
  180. foreach (var item in response.JudgingRoundRoleInfoList)
  181. {
  182. MatchingPhotoWorksData data = new MatchingPhotoWorksData();
  183. data.JudgingInfo = item;
  184. MatchingCompetitionDataManager.Instance._BeforeRankList.Add(data);
  185. }
  186. Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingCompetitionDataManager.Instance._BeforeRankList));
  187. return true;
  188. }
  189. //搭配赛相册系协议
  190. public static async ETTask<bool> ReqMatchingPhotoData()
  191. {
  192. var response = (S2C_GetJudgingRoundWorksList)await MessageHelper.SendToServer(new C2S_GetJudgingRoundWorksList { });
  193. if (!(response is { Error: ErrorCode.ERR_Success })) return false;
  194. MatchingCompetitionDataManager.Instance.MatchingPhotoInfos.Clear();
  195. foreach (var item in response.JudgingRoundRoleInfoList)
  196. {
  197. PoemPhotoData photoData = new PoemPhotoData();
  198. photoData.PictureId = item.WorksId;
  199. photoData.CreationTime = item.CreationTime;
  200. photoData.ToppingStatus = item.ToppingStatus;
  201. photoData.PictureTempUrl = item.PictureTempUrl;
  202. MatchingCompetitionDataManager.Instance.MatchingPhotoInfos.Add(photoData);
  203. }
  204. Timers.inst.StartCoroutine(PictureStorageHelper.Download(MatchingCompetitionDataManager.Instance.MatchingPhotoInfos));
  205. return true;
  206. }
  207. //修改图片锁定状态
  208. public static async ETTask<bool> ReqChangeLockingState(long pictureId, bool state, int sourceType)
  209. {
  210. S2C_UpJudgingRoundWorksLockingStatus response = null;
  211. response = (S2C_UpJudgingRoundWorksLockingStatus)await MessageHelper.SendToServer(new C2S_UpJudgingRoundWorksLockingStatus() { WorksId = pictureId, Status = state });
  212. if (response != null)
  213. {
  214. if (response.Error == ErrorCode.ERR_Success)
  215. {
  216. PoemPhotoDataManager.Instance.ChangeLockingState(response.WorksId, response.Status, sourceType);
  217. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223. //修改图片置顶状态
  224. public static async ETTask<bool> ReqChangeToppingState(long pictureId, bool state, int sourceType)
  225. {
  226. S2C_UpJudgingRoundWorksToppingStatus response = null;
  227. response = (S2C_UpJudgingRoundWorksToppingStatus)await MessageHelper.SendToServer(new C2S_UpJudgingRoundWorksToppingStatus() { WorksId = pictureId, Status = state });
  228. if (response != null)
  229. {
  230. if (response.Error == ErrorCode.ERR_Success)
  231. {
  232. PoemPhotoDataManager.Instance.ChangeToppingState(response.WorksId, response.Status, sourceType);
  233. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  234. return true;
  235. }
  236. }
  237. return false;
  238. }
  239. //批量删除玩家相册
  240. public static async ETTask<bool> ReqRemovedPhoto(List<long> pictureIds, int sourceType)
  241. {
  242. S2C_RemovedJudgingRoundWorks response = null;
  243. response = (S2C_RemovedJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RemovedJudgingRoundWorks() { WorksIds = pictureIds });
  244. if (response != null)
  245. {
  246. if (response.Error == ErrorCode.ERR_Success)
  247. {
  248. PoemPhotoDataManager.Instance.Remove(response.WorksIds, sourceType);
  249. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  250. return true;
  251. }
  252. }
  253. return false;
  254. }
  255. }
  256. }