PoemPhotoSProxy.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Net;
  5. using System.Net.Http;
  6. using ET;
  7. using FairyGUI;
  8. using UnityEngine;
  9. using UnityEngine.Networking;
  10. namespace GFGGame
  11. {
  12. public static class PoemPhotoSProxy
  13. {
  14. //获取玩家所有相册数据协议
  15. public static async ETTask<bool> ReqAllPhotoInfos()
  16. {
  17. S2C_GetAllAlbumInfo response = null;
  18. response = (S2C_GetAllAlbumInfo)await MessageHelper.SendToServer(new C2S_GetAllAlbumInfo());
  19. if (response != null)
  20. {
  21. if (response.Error == ErrorCode.ERR_Success)
  22. {
  23. for (int i = 0; i < response.PictureInfosA.Count; i++)
  24. {
  25. PoemPhotoData photoData = new PoemPhotoData();
  26. photoData.PictureId = response.PictureInfosA[i].PictureId;
  27. photoData.CreationTime = response.PictureInfosA[i].CreationTime;
  28. photoData.ToppingStatus = response.PictureInfosA[i].ToppingStatus;
  29. photoData.LockingStatus = response.PictureInfosA[i].LockingStatus;
  30. photoData.SourceType = response.PictureInfosA[i].SourceType;
  31. photoData.PictureTempUrl = response.PictureInfosA[i].PictureTempUrl;
  32. // Timers.inst.StartCoroutine(PictureStorageHelper.DownloadFile(photoData.PictureTempUrl, (Texture2D texture) =>
  33. // {
  34. // photoData.Bytes = texture.EncodeToJPG();
  35. // photoData.Ntexture = new NTexture(texture);
  36. // }));
  37. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.PersonalAlbum);
  38. }
  39. Timers.inst.StartCoroutine(PictureStorageHelper.Download(PoemPhotoDataManager.Instance.PersonalPhotoInfos));
  40. for (int i = 0; i < response.PictureInfosB.Count; i++)
  41. {
  42. PoemPhotoData photoData = new PoemPhotoData();
  43. photoData.PictureId = response.PictureInfosB[i].PictureId;
  44. photoData.CreationTime = response.PictureInfosB[i].CreationTime;
  45. photoData.ToppingStatus = response.PictureInfosB[i].ToppingStatus;
  46. photoData.LockingStatus = response.PictureInfosB[i].LockingStatus;
  47. photoData.SourceType = response.PictureInfosB[i].SourceType;
  48. photoData.TravelLocationId = response.PictureInfosB[i].TravelLocationId;
  49. photoData.TravelSuitId = response.PictureInfosB[i].TravelSuitId;
  50. photoData.SuitResIndex = response.PictureInfosB[i].TravelSuitResourceIndex;
  51. photoData.PositionIndex = response.PictureInfosB[i].PositionIndex;
  52. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.WanShuiQianShan);
  53. }
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. //保存成功后,添加图片至相册
  60. public static async ETTask<long> ReqAddTophoto(string pictureObjectPath, int sourceType)
  61. {
  62. S2C_AddPicture response = null;
  63. response = (S2C_AddPicture)await MessageHelper.SendToServer(new C2S_AddPicture() { PictureObjectPath = pictureObjectPath, SourceType = sourceType });
  64. ViewManager.Hide<ModalStatusView>();
  65. if (response != null)
  66. {
  67. if (response.Error == ErrorCode.ERR_Success)
  68. {
  69. PoemPhotoData photoData = new PoemPhotoData();
  70. photoData.PictureId = response.PictureInfo.PictureId;
  71. photoData.CreationTime = response.PictureInfo.CreationTime;
  72. photoData.ToppingStatus = response.PictureInfo.ToppingStatus;
  73. photoData.LockingStatus = response.PictureInfo.LockingStatus;
  74. photoData.PictureTempUrl = response.PictureInfo.PictureTempUrl;
  75. PoemPhotoDataManager.Instance.Add(photoData, sourceType);
  76. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  77. PromptController.Instance.ShowFloatTextPrompt("已保存至相册");
  78. return response.PictureInfo.PictureId;
  79. }
  80. }
  81. PromptController.Instance.ShowFloatTextPrompt("存储数据失败");
  82. return 0;
  83. }
  84. //批量删除玩家相册
  85. public static async ETTask<bool> ReqRemovedPhoto(List<long> pictureIds, int sourceType)
  86. {
  87. S2C_RemovedPictures response = null;
  88. response = (S2C_RemovedPictures)await MessageHelper.SendToServer(new C2S_RemovedPictures() { PictureIds = pictureIds });
  89. if (response != null)
  90. {
  91. if (response.Error == ErrorCode.ERR_Success)
  92. {
  93. PoemPhotoDataManager.Instance.Remove(response.PictureIds, sourceType);
  94. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. //修改图片锁定状态
  101. public static async ETTask<bool> ReqChangeLockingState(long pictureId, bool state, int sourceType)
  102. {
  103. S2C_UpPictureLockingStatus response = null;
  104. response = (S2C_UpPictureLockingStatus)await MessageHelper.SendToServer(new C2S_UpPictureLockingStatus() { PictureId = pictureId, Status = state });
  105. if (response != null)
  106. {
  107. if (response.Error == ErrorCode.ERR_Success)
  108. {
  109. PoemPhotoDataManager.Instance.ChangeLockingState(response.PictureId, response.Status, sourceType);
  110. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. //修改图片置顶状态
  117. public static async ETTask<bool> ReqChangeToppingState(long pictureId, bool state, int sourceType)
  118. {
  119. S2C_UpPictureToppingStatus response = null;
  120. response = (S2C_UpPictureToppingStatus)await MessageHelper.SendToServer(new C2S_UpPictureToppingStatus() { PictureId = pictureId, Status = state });
  121. if (response != null)
  122. {
  123. if (response.Error == ErrorCode.ERR_Success)
  124. {
  125. PoemPhotoDataManager.Instance.ChangeToppingState(response.PictureId, response.Status, sourceType);
  126. EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. }
  133. }