CardSProxy.cs 5.2 KB

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