CardSProxy.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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,
  12. message.CardInfo.VsSkill);
  13. await ETTask.CompletedTask;
  14. }
  15. }
  16. }
  17. namespace GFGGame
  18. {
  19. public static class CardSProxy
  20. {
  21. public static async ETTask GetCardInfos()
  22. {
  23. M2C_GetCardInfos response = null;
  24. response = (M2C_GetCardInfos)await MessageHelper.SendToServer(new C2M_GetCardInfos() { });
  25. if (response != null)
  26. {
  27. if (response.Error == ErrorCode.ERR_Success)
  28. {
  29. for (int i = 0; i < response.CardInfos.Count; i++)
  30. {
  31. CardDataManager.Add(response.CardInfos[i], true);
  32. SkillDataManager.Instance.InitCardData(response.CardInfos[i].CardId,
  33. response.CardInfos[i].KsSkill, response.CardInfos[i].VsSkill);
  34. }
  35. EventAgent.DispatchEvent(ConstMessage.CARD_INFO);
  36. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  37. }
  38. }
  39. }
  40. public static async ETTask<bool> UpgradeCardLvl(int cardId, List<int> itemNums)
  41. {
  42. M2C_UpgradeCardLvl response = null;
  43. response = (M2C_UpgradeCardLvl)await MessageHelper.SendToServer(new C2M_UpgradeCardLvl()
  44. { CardId = cardId, ItemNums = itemNums });
  45. if (response != null)
  46. {
  47. if (response.Error == ErrorCode.ERR_Success)
  48. {
  49. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  50. cardData.lv = response.CardLvl;
  51. cardData.exp = response.CardExp;
  52. for (int i = 0; i < response.KsAttribute.Count; i++)
  53. {
  54. cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i];
  55. }
  56. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  57. EventAgent.DispatchEvent(ConstMessage.CARD_LEVEL_UP);
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. public static async ETTask<bool> UpgradeCardStar(int cardId, bool isAutoSelect = false)
  64. {
  65. M2C_UpgradeCardStar response = null;
  66. response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar()
  67. { CardId = cardId, IsAutoSelect = isAutoSelect });
  68. if (response != null)
  69. {
  70. if (response.Error == ErrorCode.ERR_Success)
  71. {
  72. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  73. cardData.star = response.CardStar;
  74. for (int i = 0; i < response.KsAttribute.Count; i++)
  75. {
  76. cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i];
  77. }
  78. for (int i = 0; i < response.KsStarBonus.Count; i++)
  79. {
  80. cardData.starRewardsState[response.KsStarBonus[i]] = response.VsStarBonus[i];
  81. }
  82. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  83. return true;
  84. }
  85. }
  86. return false;
  87. }
  88. //resIndex:0默认,1特殊
  89. public static async ETTask<bool> ChangeCardRes(int cardId, int resIndex)
  90. {
  91. M2C_ChangeCardRes response = null;
  92. response = (M2C_ChangeCardRes)await MessageHelper.SendToServer(new C2M_ChangeCardRes()
  93. { CardId = cardId, ResIndex = resIndex });
  94. if (response != null)
  95. {
  96. if (response.Error == ErrorCode.ERR_Success)
  97. {
  98. CardData cardData = CardDataManager.GetCardDataById(cardId);
  99. cardData.resIndex = resIndex;
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. public static async ETTask<bool> GetCardStarBonus(int cardId, int starLv)
  106. {
  107. S2C_GetCardStarBonus response = null;
  108. response = (S2C_GetCardStarBonus)await MessageHelper.SendToServer(new C2S_GetCardStarBonus()
  109. { CardId = cardId, CardStar = starLv });
  110. if (response != null)
  111. {
  112. if (response.Error == ErrorCode.ERR_Success)
  113. {
  114. CardData cardData = CardDataManager.GetCardDataById(response.CardId);
  115. cardData.starRewardsState[response.CardStar] = response.BonusStatus;
  116. var rewards = CommonDataManager.Tables.TblCardStarCfg.Get(response.CardId, response.CardStar)
  117. .Rewards;
  118. BonusController.TryShowBonusList(rewards.ToGfgGameItemParam());
  119. EventAgent.DispatchEvent(ConstMessage.CARD_STAR_REWARD);
  120. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. public static async ETTask<bool> SaveIsAutoSelect(bool isAutoSelect)
  127. {
  128. await MessageHelper.SendToServer(new C2M_SaveIsAutoSelect() { IsAutoSelect = isAutoSelect });
  129. return true;
  130. }
  131. }
  132. }