using System.Collections.Generic; using ET; using GFGGame; namespace ET { public class NoticeGetNewCard : AMHandler { protected override async ETTask Run(Session session, M2C_GetNewCard message) { CardDataManager.Add(message.CardInfo); SkillDataManager.Instance.InitServerData(message.CardInfo.CardId, message.CardInfo.KsSkill, message.CardInfo.VsSkill); await ETTask.CompletedTask; } } } namespace GFGGame { public static class CardSProxy { public static async ETTask GetCardInfos() { M2C_GetCardInfos response = null; response = (M2C_GetCardInfos)await MessageHelper.SendToServer(new C2M_GetCardInfos() { }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { for (int i = 0; i < response.CardInfos.Count; i++) { CardDataManager.Add(response.CardInfos[i]); SkillDataManager.Instance.InitServerData(response.CardInfos[i].CardId, response.CardInfos[i].KsSkill, response.CardInfos[i].VsSkill); } } } } public static async ETTask UpgradeCardLvl(int cardId, List itemNums) { M2C_UpgradeCardLvl response = null; response = (M2C_UpgradeCardLvl)await MessageHelper.SendToServer(new C2M_UpgradeCardLvl() { CardId = cardId, ItemNums = itemNums }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { CardData cardData = CardDataManager.GetCardDataById(response.CardId); cardData.lv = response.CardLvl; cardData.exp = response.CardExp; for (int i = 0; i < response.KsAttribute.Count; i++) { cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i]; } return true; } } return false; } public static async ETTask UpgradeCardStar(int cardId) { M2C_UpgradeCardStar response = null; response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar() { CardId = cardId }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { CardData cardData = CardDataManager.GetCardDataById(response.CardId); cardData.star = response.CardStar; for (int i = 0; i < response.KsAttribute.Count; i++) { cardData.scores[response.KsAttribute[i]] = response.VsAttribute[i]; } return true; } } return false; } //resIndex:0默认,1特殊 public static async ETTask ChangeCardRes(int cardId, int resIndex) { M2C_ChangeCardRes response = null; response = (M2C_ChangeCardRes)await MessageHelper.SendToServer(new C2M_ChangeCardRes() { CardId = cardId, ResIndex = resIndex }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { CardData cardData = CardDataManager.GetCardDataById(cardId); cardData.resIndex = resIndex; return true; } } return false; } public static async ETTask UpgradeCardSkill(int cardId, int skillId) { M2C_UpgradeCardSkill response = null; response = (M2C_UpgradeCardSkill)await MessageHelper.SendToServer(new C2M_UpgradeCardSkill() { CardId = cardId, SkillId = skillId }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { SkillDataManager.Instance.UpdateSkill(response.CardId, response.SkillId, response.SkillLvl); EventAgent.DispatchEvent(ConstMessage.CARD_UP_SKILL); } } } } }