CardSProxy.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. public static async ETTask<bool> UpgradeCardStar(int cardId)
  58. {
  59. M2C_UpgradeCardStar response = null;
  60. response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar() { CardId = cardId });
  61. if (response != null)
  62. {
  63. if (response.Error == ErrorCode.ERR_Success)
  64. {
  65. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  66. cardData.star = response.CardStar;
  67. for (int i = 0; i < response.KsAttribute.Count; i++)
  68. {
  69. cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i];
  70. }
  71. for (int i = 0; i < response.KsStarBonus.Count; i++)
  72. {
  73. cardData.starRewardsState[response.KsStarBonus[i]] = response.VsStarBonus[i];
  74. }
  75. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  76. return true;
  77. }
  78. }
  79. return false;
  80. }
  81. //resIndex:0默认,1特殊
  82. public static async ETTask<bool> ChangeCardRes(int cardId, int resIndex)
  83. {
  84. M2C_ChangeCardRes response = null;
  85. response = (M2C_ChangeCardRes)await MessageHelper.SendToServer(new C2M_ChangeCardRes() { CardId = cardId, ResIndex = resIndex });
  86. if (response != null)
  87. {
  88. if (response.Error == ErrorCode.ERR_Success)
  89. {
  90. CardData cardData = CardDataManager.GetCardDataById(cardId);
  91. cardData.resIndex = resIndex;
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. public static async ETTask<bool> GetCardStarBonus(int cardId, int starLv)
  98. {
  99. S2C_GetCardStarBonus response = null;
  100. response = (S2C_GetCardStarBonus)await MessageHelper.SendToServer(new C2S_GetCardStarBonus() { CardId = cardId, CardStar = starLv });
  101. if (response != null)
  102. {
  103. if (response.Error == ErrorCode.ERR_Success)
  104. {
  105. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  106. cardData.starRewardsState[response.CardStar] = response.BonusStatus;
  107. int[][] rewards = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(response.CardId, response.CardStar).rewardsArr;
  108. BonusController.TryShowBonusList(rewards);
  109. EventAgent.DispatchEvent(ConstMessage.CARD_STAR_REWARD);
  110. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. }
  117. }