MatchingCompetitionSproxy.cs 13 KB

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