123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System.Collections.Generic;
- using ET;
- using GFGGame;
- namespace ET
- {
- public class NoticeGetNewCard : AMHandler<M2C_GetNewCard>
- {
- 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<bool> UpgradeCardLvl(int cardId, List<int> 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<bool> 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<bool> 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<bool> 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);
- return true;
- }
- }
- return false;
- }
- }
- }
|