RoleInfoSProxy.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UnityEngine;
  6. using UnityEngine.Networking;
  7. namespace GFGGame
  8. {
  9. public static class RoleInfoSProxy
  10. {
  11. //请求个人信息
  12. public static async ETTask<bool> ReqPersonalInfo()
  13. {
  14. S2C_GetPersonalInfo response = null;
  15. response = (S2C_GetPersonalInfo)await MessageHelper.SendToServer(new C2S_GetPersonalInfo());
  16. if (response != null)
  17. {
  18. if (response.Error == ErrorCode.ERR_Success)
  19. {
  20. RoleDataManager.slogan = response.Signature;
  21. RoleDataManager.headId = response.HeadItemId;
  22. RoleDataManager.headBorderId = response.HeadBorderItemId;
  23. RoleDataManager.photoDatas = response.PictureIds;
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. //请求其他玩家详细信息
  30. public static async ETTask<OtherRoleInfoDetailData> ReqOtherRoleDetailInfo(long friendId)
  31. {
  32. S2C_GetOtherRoleDetailInfo response = null;
  33. response = (S2C_GetOtherRoleDetailInfo)await MessageHelper.SendToServer(new C2S_GetOtherRoleDetailInfo() { RoleId = friendId });
  34. if (response != null)
  35. {
  36. if (response.Error == ErrorCode.ERR_Success)
  37. {
  38. OtherRoleInfoDetailData roleInfoDetail = new OtherRoleInfoDetailData();
  39. roleInfoDetail.slogan = response.Signature;
  40. roleInfoDetail.RoleLvl = response.RoleLvl;
  41. for (int i = 0; i < response.PictureInfoList.Count; i++)
  42. {
  43. if (roleInfoDetail.showPhotoList.Count == i)
  44. {
  45. roleInfoDetail.showPhotoList.Add(new PoemPhotoData());
  46. }
  47. if (response.PictureInfoList[i].PictureId == 0)
  48. {
  49. roleInfoDetail.showPhotoList[i] = null;
  50. }
  51. else
  52. {
  53. roleInfoDetail.showPhotoList[i].PictureId = response.PictureInfoList[i].PictureId;
  54. roleInfoDetail.showPhotoList[i].PictureTempUrl = response.PictureInfoList[i].PictureTempUrl;
  55. }
  56. }
  57. if (response.CustomSuit != null)
  58. {
  59. roleInfoDetail.customSuitData = new CustomSuitData(response.CustomSuit.Pos);
  60. roleInfoDetail.customSuitData.bg = response.CustomSuit.BgId;
  61. roleInfoDetail.customSuitData.suitId = response.CustomSuit.SuitId;
  62. roleInfoDetail.customSuitData.equipDatas = response.CustomSuit.EquipIds;
  63. roleInfoDetail.customSuitData.pic = response.CustomSuit.Pic;
  64. }
  65. return roleInfoDetail;
  66. }
  67. }
  68. return null;
  69. }
  70. public static IEnumerator Download(List<PoemPhotoData> list)
  71. {
  72. for (int i = 0; i < list.Count; i++)
  73. {
  74. PoemPhotoData data = list[i];
  75. if (data == null || data.Ntexture != null) continue;
  76. using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(data.PictureTempUrl))
  77. {
  78. yield return request.SendWebRequest();
  79. if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
  80. {
  81. PromptController.Instance.ShowFloatTextPrompt("下载失败");
  82. yield return null;
  83. }
  84. else
  85. {
  86. Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
  87. data.Ntexture = new NTexture(texture);
  88. }
  89. }
  90. }
  91. ET.Log.Debug("Download finish!!!");
  92. EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
  93. }
  94. //修改个人签名
  95. public static async ETTask<string> ReqModifySlogan(string slogan)
  96. {
  97. S2C_ModifySignature response = null;
  98. response = (S2C_ModifySignature)await MessageHelper.SendToServer(new C2S_ModifySignature() { Signature = slogan });
  99. if (response != null)
  100. {
  101. if (response.Error == ErrorCode.ERR_Success)
  102. {
  103. RoleDataManager.slogan = response.Signature;
  104. return RoleDataManager.slogan;
  105. }
  106. }
  107. return RoleDataManager.slogan;
  108. }
  109. //修改角色名称
  110. public static async ETTask<bool> ReqModifyRoleName(string name)
  111. {
  112. S2C_ModifyRoleName response = null;
  113. response = (S2C_ModifyRoleName)await MessageHelper.SendToServer(new C2S_ModifyRoleName() { Name = name });
  114. if (response != null)
  115. {
  116. if (response.Error == ErrorCode.ERR_Success)
  117. {
  118. RoleDataManager.roleName = response.Name;
  119. EventAgent.DispatchEvent(ConstMessage.CHANGE_ROLE_NAME);
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. //修改角色头像
  126. public static async ETTask<bool> ReqModifyRoleHead(int headId)
  127. {
  128. S2C_AuHeadPortrait response = null;
  129. response = (S2C_AuHeadPortrait)await MessageHelper.SendToServer(new C2S_AuHeadPortrait() { HeadItemId = headId });
  130. if (response != null)
  131. {
  132. if (response.Error == ErrorCode.ERR_Success)
  133. {
  134. RoleDataManager.headId = response.HeadItemId;
  135. EventAgent.DispatchEvent(ConstMessage.CHANGE_ROLE_NAME);
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. //修改角色头像框
  142. public static async ETTask<bool> ReqModifyRoleHeadBorder(int HeadBorder)
  143. {
  144. S2C_AuHeadPortraitBox response = null;
  145. response = (S2C_AuHeadPortraitBox)await MessageHelper.SendToServer(new C2S_AuHeadPortraitBox() { HeadBorderItemId = HeadBorder });
  146. if (response != null)
  147. {
  148. if (response.Error == ErrorCode.ERR_Success)
  149. {
  150. RoleDataManager.headBorderId = response.HeadBorderItemId;
  151. EventAgent.DispatchEvent(ConstMessage.CHANGE_ROLE_NAME);
  152. return true;
  153. }
  154. }
  155. return false;
  156. }
  157. //修改展示图片
  158. public static async ETTask<bool> ReqModifyShowPhoto(List<int> photoDatas)
  159. {
  160. S2C_AddOpenAlbumInfo response = null;
  161. response = (S2C_AddOpenAlbumInfo)await MessageHelper.SendToServer(new C2S_AddOpenAlbumInfo() { PictureIds = photoDatas });
  162. if (response != null)
  163. {
  164. if (response.Error == ErrorCode.ERR_Success)
  165. {
  166. EventAgent.DispatchEvent(ConstMessage.CHANGE_ROLE_NAME);
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. }
  173. }