TravelSProxy.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Net;
  6. using System.Net.Http;
  7. using ET;
  8. using FairyGUI;
  9. using GFGGame;
  10. using ICSharpCode.SharpZipLib.GZip;
  11. using UnityEngine;
  12. using UnityEngine.Networking;
  13. namespace GFGGame
  14. {
  15. public static class TravelSProxy
  16. {
  17. //获取游历信息
  18. public static async ETTask<bool> ReqTravelInfo()
  19. {
  20. S2C_GetTravelGuideData response = null;
  21. response = (S2C_GetTravelGuideData)await MessageHelper.SendToServer(new C2S_GetTravelGuideData());
  22. if (response != null)
  23. {
  24. if (response.Error == ErrorCode.ERR_Success)
  25. {
  26. TravelData travelData = new TravelData();
  27. travelData.Status = response.TravelGuideInfo.Status;
  28. travelData.CreationTime = response.TravelGuideInfo.CreationTime;
  29. travelData.TravelNeedHour = response.TravelGuideInfo.TravelNeedHour;
  30. travelData.TravelLocationId = response.TravelGuideInfo.TravelLocationId;
  31. travelData.TravelCount = response.TravelGuideInfo.TravelCount;
  32. travelData.TravelSuitId = response.TravelGuideInfo.TravelSuitId;
  33. travelData.PositionIndex = response.TravelGuideInfo.PositionIndex;
  34. travelData.SuitResIndex = response.TravelGuideInfo.PositionIndex;
  35. travelData.RewardItems = ItemUtil.CreateItemDataList(response.TravelGuideInfo.RewardItem);
  36. TravelDataManager.Instance.TravelData = travelData;
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. //开始游历
  43. public static async ETTask<bool> ReqGoTravel(List<int> qSuitIds)
  44. {
  45. S2C_TravelGuideGo response = null;
  46. response = (S2C_TravelGuideGo)await MessageHelper.SendToServer(new C2S_TravelGuideGo() { TravelSuitIds = qSuitIds });
  47. if (response != null)
  48. {
  49. if (response.Error == ErrorCode.ERR_Success)
  50. {
  51. TravelData travelData = new TravelData();
  52. travelData.Status = response.TravelGuideInfo.Status;
  53. travelData.CreationTime = response.TravelGuideInfo.CreationTime;
  54. travelData.TravelNeedHour = response.TravelGuideInfo.TravelNeedHour;
  55. travelData.TravelLocationId = response.TravelGuideInfo.TravelLocationId;
  56. travelData.TravelCount = response.TravelGuideInfo.TravelCount;
  57. travelData.TravelSuitId = response.TravelGuideInfo.TravelSuitId;
  58. travelData.PositionIndex = response.TravelGuideInfo.PositionIndex;
  59. travelData.SuitResIndex = response.TravelGuideInfo.PositionIndex;
  60. travelData.RewardItems = ItemUtil.CreateItemDataList(response.TravelGuideInfo.RewardItem);
  61. TravelDataManager.Instance.TravelData = travelData;
  62. EventAgent.DispatchEvent(ConstMessage.TRAVEL_STATE_CHANGE);
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. //领取游历奖励
  69. public static async ETTask<bool> ReqGetTravelReward()
  70. {
  71. S2C_ReceiveTravelGuideReward response = null;
  72. response = (S2C_ReceiveTravelGuideReward)await MessageHelper.SendToServer(new C2S_ReceiveTravelGuideReward() { });
  73. if (response != null)
  74. {
  75. if (response.Error == ErrorCode.ERR_Success)
  76. {
  77. PoemPhotoData photoData = new PoemPhotoData();
  78. photoData.PictureId = response.PictureInfo.PictureId;
  79. photoData.CreationTime = response.PictureInfo.CreationTime;
  80. photoData.ToppingStatus = response.PictureInfo.ToppingStatus;
  81. photoData.LockingStatus = response.PictureInfo.LockingStatus;
  82. photoData.TravelLocationId = response.PictureInfo.TravelLocationId;
  83. photoData.TravelSuitId = response.PictureInfo.TravelSuitId;
  84. photoData.ResourceIndex = response.PictureInfo.TravelSuitResourceIndex;
  85. photoData.PositionIndex = response.PictureInfo.PositionIndex;
  86. PoemPhotoDataManager.Instance.Add(photoData, (int)PictureSourceType.WanShuiQianShan);
  87. TravelDataManager inst = TravelDataManager.Instance;
  88. inst.TravelData.Status = (int)TravelGuideType.NoTravel;
  89. inst.ListTravelLocationCount[inst.TravelData.TravelLocationId - 1] = inst.TravelData.TravelCount;
  90. EventAgent.DispatchEvent(ConstMessage.TRAVEL_STATE_CHANGE);
  91. if (inst.TravelData.TravelCount > 1) return true;//非首次到达该地无需处理图鉴红点
  92. string location = TravelLoactionCfgArray.Instance.GetCfg(inst.TravelData.TravelLocationId).location;
  93. for (int i = 0; i < inst.ListTravelAreaRewardState.Count; i++)
  94. {
  95. TravelGuideCfg travelGuide = TravelGuideCfgArray.Instance.GetCfg(i + 1);
  96. if (Array.IndexOf(travelGuide.locationsArr, location) >= 0)
  97. {
  98. if (inst.ListTravelAreaRewardState[i] > (int)ConstBonusStatus.CAN_NOT_GET) break;//可领和已领状态不用处理
  99. bool isRed = true;
  100. for (int j = 0; j < travelGuide.locationsArr.Length; j++)
  101. {
  102. int loactionId = TravelLoactionCfgArray.Instance.GetCfgBylocation(travelGuide.locationsArr[j]).id;
  103. if (inst.ListTravelLocationCount[loactionId - 1] == 0)
  104. {
  105. //仍有未到达的地点
  106. isRed = false;
  107. break;
  108. }
  109. }
  110. if (isRed)
  111. {
  112. inst.ListTravelAreaRewardState[i] = (int)ConstBonusStatus.CAN_GET;
  113. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  114. }
  115. break;
  116. }
  117. }
  118. return true;
  119. }
  120. }
  121. return false;
  122. }
  123. //获取游历图鉴记录
  124. public static async ETTask<bool> ReqTravelGuideInfo()
  125. {
  126. S2C_GetTravelGuideRecordAll response = null;
  127. response = (S2C_GetTravelGuideRecordAll)await MessageHelper.SendToServer(new C2S_GetTravelGuideRecordAll() { });
  128. if (response != null)
  129. {
  130. if (response.Error == ErrorCode.ERR_Success)
  131. {
  132. TravelDataManager.Instance.ListTravelLocationCount = new List<int>(response.TglLocationRecordList.ToArray());
  133. TravelDataManager.Instance.ListTravelAreaRewardState = new List<int>(response.TglAreaRecordList.ToArray());
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. //领取游历图鉴区域奖励
  140. public static async ETTask<bool> ReqGetTravelGuideReward(int areaId)
  141. {
  142. S2C_ReceiveTravelAreaReward response = null;
  143. response = (S2C_ReceiveTravelAreaReward)await MessageHelper.SendToServer(new C2S_ReceiveTravelAreaReward() { AreaId = areaId });
  144. if (response != null)
  145. {
  146. if (response.Error == ErrorCode.ERR_Success)
  147. {
  148. TravelDataManager.Instance.ListTravelAreaRewardState[areaId - 1] = (int)ConstBonusStatus.GOT;
  149. List<ItemData> rewards = ItemUtil.CreateItemDataList(response.RewardItem);
  150. BonusController.TryShowBonusList(rewards);
  151. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  152. return true;
  153. }
  154. }
  155. return false;
  156. }
  157. }
  158. }