CardSProxy.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.InitServerData(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.InitServerData(response.CardInfos[i].CardId, response.CardInfos[i].KsSkill, response.CardInfos[i].VsSkill);
  32. }
  33. }
  34. }
  35. }
  36. public static async ETTask<bool> UpgradeCardLvl(int cardId, List<int> itemNums)
  37. {
  38. M2C_UpgradeCardLvl response = null;
  39. response = (M2C_UpgradeCardLvl)await MessageHelper.SendToServer(new C2M_UpgradeCardLvl() { CardId = cardId, ItemNums = itemNums });
  40. if (response != null)
  41. {
  42. if (response.Error == ErrorCode.ERR_Success)
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. public static async ETTask<bool> UpgradeCardStar(int cardId)
  50. {
  51. M2C_UpgradeCardStar response = null;
  52. response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar() { CardId = cardId });
  53. if (response != null)
  54. {
  55. if (response.Error == ErrorCode.ERR_Success)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. //resIndex:0默认,1特殊
  63. public static async ETTask<bool> ChangeCardRes(int cardId, int resIndex)
  64. {
  65. M2C_ChangeCardLvl response = null;
  66. response = (M2C_ChangeCardLvl)await MessageHelper.SendToServer(new C2M_ChangeCardLvl() { CardId = cardId, ResIndex = resIndex });
  67. if (response != null)
  68. {
  69. if (response.Error == ErrorCode.ERR_Success)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. public static async ETTask UpgradeCardSkill(int cardId, int skillId)
  77. {
  78. M2C_UpgradeCardSkill response = null;
  79. response = (M2C_UpgradeCardSkill)await MessageHelper.SendToServer(new C2M_UpgradeCardSkill() { CardId = cardId, SkillId = skillId });
  80. if (response != null)
  81. {
  82. if (response.Error == ErrorCode.ERR_Success)
  83. {
  84. SkillDataManager.Instance.UpdateSkill(response.CardId, response.SkillId, response.SkillLvl);
  85. EventAgent.DispatchEvent(ConstMessage.CARD_UP_SKILL);
  86. }
  87. }
  88. }
  89. }
  90. }