CardSProxy.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System.Collections.Generic;
  2. using ET;
  3. using GFGGame;
  4. namespace ET
  5. {
  6. public class NoticeGetNewCard : AMHandler<M2C_GetNewCard>
  7. {
  8. protected override async ETTask Run(Session session, M2C_GetNewCard message)
  9. {
  10. CardDataManager.Add(message.CardInfo);
  11. SkillDataManager.Instance.InitCardData(message.CardInfo.CardId, message.CardInfo.KsSkill, message.CardInfo.VsSkill);
  12. await ETTask.CompletedTask;
  13. }
  14. }
  15. }
  16. namespace GFGGame
  17. {
  18. public static class CardSProxy
  19. {
  20. public static async ETTask GetCardInfos()
  21. {
  22. M2C_GetCardInfos response = null;
  23. response = (M2C_GetCardInfos)await MessageHelper.SendToServer(new C2M_GetCardInfos() { });
  24. if (response != null)
  25. {
  26. if (response.Error == ErrorCode.ERR_Success)
  27. {
  28. for (int i = 0; i < response.CardInfos.Count; i++)
  29. {
  30. CardDataManager.Add(response.CardInfos[i]);
  31. SkillDataManager.Instance.InitCardData(response.CardInfos[i].CardId, response.CardInfos[i].KsSkill, response.CardInfos[i].VsSkill);
  32. }
  33. EventAgent.DispatchEvent(ConstMessage.CARD_INFO);
  34. }
  35. }
  36. }
  37. public static async ETTask<bool> UpgradeCardLvl(int cardId, List<int> itemNums)
  38. {
  39. M2C_UpgradeCardLvl response = null;
  40. response = (M2C_UpgradeCardLvl)await MessageHelper.SendToServer(new C2M_UpgradeCardLvl() { CardId = cardId, ItemNums = itemNums });
  41. if (response != null)
  42. {
  43. if (response.Error == ErrorCode.ERR_Success)
  44. {
  45. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  46. cardData.lv = response.CardLvl;
  47. cardData.exp = response.CardExp;
  48. for (int i = 0; i < response.KsAttribute.Count; i++)
  49. {
  50. cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i];
  51. }
  52. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. public static async ETTask<bool> UpgradeCardStar(int cardId)
  59. {
  60. M2C_UpgradeCardStar response = null;
  61. response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar() { CardId = cardId });
  62. if (response != null)
  63. {
  64. if (response.Error == ErrorCode.ERR_Success)
  65. {
  66. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  67. cardData.star = response.CardStar;
  68. for (int i = 0; i < response.KsAttribute.Count; i++)
  69. {
  70. cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i];
  71. }
  72. for (int i = 0; i < response.KsStarBonus.Count; i++)
  73. {
  74. cardData.starRewardsState[response.KsStarBonus[i]] = response.VsStarBonus[i];
  75. }
  76. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. //resIndex:0默认,1特殊
  83. public static async ETTask<bool> ChangeCardRes(int cardId, int resIndex)
  84. {
  85. M2C_ChangeCardRes response = null;
  86. response = (M2C_ChangeCardRes)await MessageHelper.SendToServer(new C2M_ChangeCardRes() { CardId = cardId, ResIndex = resIndex });
  87. if (response != null)
  88. {
  89. if (response.Error == ErrorCode.ERR_Success)
  90. {
  91. CardData cardData = CardDataManager.GetCardDataById(cardId);
  92. cardData.resIndex = resIndex;
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. public static async ETTask<bool> GetCardStarBonus(int cardId, int starLv)
  99. {
  100. S2C_GetCardStarBonus response = null;
  101. response = (S2C_GetCardStarBonus)await MessageHelper.SendToServer(new C2S_GetCardStarBonus() { CardId = cardId, CardStar = starLv });
  102. if (response != null)
  103. {
  104. if (response.Error == ErrorCode.ERR_Success)
  105. {
  106. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  107. cardData.starRewardsState[response.CardStar] = response.BonusStatus;
  108. int[][] rewards = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(response.CardId, response.CardStar).rewardsArr;
  109. BonusController.TryShowBonusList(rewards);
  110. EventAgent.DispatchEvent(ConstMessage.CARD_STAR_REWARD);
  111. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. }
  118. }