FieldSProxy.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System.Collections.Generic;
  2. using ET;
  3. using GFGGame;
  4. namespace GFGGame
  5. {
  6. public static class FieldSProxy
  7. {
  8. public static async ETTask<bool> ReqFieldInstanceInfos()
  9. {
  10. M2C_GetFieldInstanceInfos response = null;
  11. response = (M2C_GetFieldInstanceInfos)await MessageHelper.SendToServer(new C2M_GetFieldInstanceInfos());
  12. if (response != null)
  13. {
  14. if (response.Error == ErrorCode.ERR_Success)
  15. {
  16. FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
  17. fieldInfos.theme = response.Theme;
  18. fieldInfos.highestLvls = response.HighestLvls;
  19. fieldInfos.bonusWeekly = response.BonusWeekly;
  20. fieldInfos.bonusMaxLimit = response.BonusMaxLimit;
  21. fieldInfos.hasBonus = response.HasBonus;
  22. fieldInfos.taskDic = new Dictionary<int, int>();
  23. for (int i = 0; i < response.kTaskIds.Count; i++)
  24. {
  25. fieldInfos.taskDic.Add(response.kTaskIds[i], response.vTaskStatus[i]);
  26. }
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. public static async ETTask<bool> ReqFieldInstanceResult()
  33. {
  34. M2C_GetFieldInstanceResult response = null;
  35. response = (M2C_GetFieldInstanceResult)await MessageHelper.SendToServer(new C2M_GetFieldInstanceResult());
  36. if (response != null)
  37. {
  38. if (response.Error == ErrorCode.ERR_Success)
  39. {
  40. FieldResult fieldResult = FieldDataManager.Instance.fieldResult;
  41. fieldResult.passLvl = response.PassLvl;
  42. fieldResult.bonusList = ItemUtil.CreateItemDataList(response.BonusList);
  43. fieldResult.costNum = response.CostNum;
  44. fieldResult.hardLvl = response.HardLvl;
  45. FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
  46. fieldInfos.highestLvls[response.HardLvl] = response.HighestLvl;
  47. fieldInfos.bonusWeekly = response.BonusWeekly;
  48. for (int i = 0; i < response.kTaskIds.Count; i++)
  49. {
  50. if (!fieldInfos.taskDic.ContainsKey(response.kTaskIds[i]))
  51. {
  52. fieldInfos.taskDic.Add(response.kTaskIds[i], response.vTaskStatus[i]);
  53. }
  54. else
  55. {
  56. fieldInfos.taskDic[response.kTaskIds[i]] = response.vTaskStatus[i];
  57. }
  58. }
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. public static async ETTask<bool> ReqFieldTaskBonus(int taskId)
  65. {
  66. M2C_GetFieldTaskBonus response = null;
  67. response = (M2C_GetFieldTaskBonus)await MessageHelper.SendToServer(new C2M_GetFieldTaskBonus() { TaskId = taskId });
  68. if (response != null)
  69. {
  70. if (response.Error == ErrorCode.ERR_Success)
  71. {
  72. FieldInfos fieldInfos = FieldDataManager.Instance.fieldInfos;
  73. fieldInfos.bonusMaxLimit = response.BonusMaxLimit;
  74. // fieldInfos.taskDic[]
  75. return true;
  76. }
  77. }
  78. return false;
  79. }
  80. }
  81. }