123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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.InitCardData(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.InitCardData(response.CardInfos[i].CardId, response.CardInfos[i].KsSkill, response.CardInfos[i].VsSkill);
- }
- EventAgent.DispatchEvent(ConstMessage.CARD_INFO);
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- }
- }
- }
- 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];
- }
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> UpgradeCardStar(int cardId,bool isAutoSelect = false)
- {
- M2C_UpgradeCardStar response = null;
- response = (M2C_UpgradeCardStar)await MessageHelper.SendToServer(new C2M_UpgradeCardStar() { CardId = cardId , IsAutoSelect = isAutoSelect });
- 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];
- }
- for (int i = 0; i < response.KsStarBonus.Count; i++)
- {
- cardData.starRewardsState[response.KsStarBonus[i]] = response.VsStarBonus[i];
- }
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- 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> GetCardStarBonus(int cardId, int starLv)
- {
- S2C_GetCardStarBonus response = null;
- response = (S2C_GetCardStarBonus)await MessageHelper.SendToServer(new C2S_GetCardStarBonus() { CardId = cardId, CardStar = starLv });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- CardData cardData = CardDataManager.GetCardDataById(response.CardId);
- cardData.starRewardsState[response.CardStar] = response.BonusStatus;
- int[][] rewards = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(response.CardId, response.CardStar).rewardsArr;
- BonusController.TryShowBonusList(rewards);
- EventAgent.DispatchEvent(ConstMessage.CARD_STAR_REWARD);
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> SaveIsAutoSelect(bool isAutoSelect)
- {
- await MessageHelper.SendToServer(new C2M_SaveIsAutoSelect() { IsAutoSelect = isAutoSelect });
- return true;
- }
- }
- }
|