| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- 
 
- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using ET;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class CardDataManager
 
-     {
 
-         private static Dictionary<int, Dictionary<int, CardData>> _cardDicByType = new Dictionary<int, Dictionary<int, CardData>>();
 
-         public static Dictionary<int, Dictionary<int, int>> _selectList = new Dictionary<int, Dictionary<int, int>>();
 
-         public static List<int> _selectRoleList = new List<int>();
 
-         public static List<int> _selectRarityList = new List<int>();
 
-         public static List<int> _selectFosterList = new List<int>();
 
-         public static bool isFilter = false;//是否筛选中
 
-         private static Dictionary<int, List<CardStoryCfg>> _cardStoryCfgDic = new Dictionary<int, List<CardStoryCfg>>();
 
-         public static void Clear()
 
-         {
 
-             _cardDicByType.Clear();
 
-         }
 
-         public static void Add(CardInfoProto cardInfoProto)
 
-         {
 
-             CardData cardData = new CardData();
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cardInfoProto.CardId);
 
-             if (itemCfg == null)
 
-             {
 
-                 ET.Log.Error(cardInfoProto.CardId + "   ItemCfgArray配置不存在");
 
-                 return;
 
-             }
 
-             cardData.id = cardInfoProto.CardId;
 
-             cardData.lv = cardInfoProto.Lvl;
 
-             cardData.exp = cardInfoProto.Exp;
 
-             cardData.star = cardInfoProto.Star;
 
-             cardData.itemCfg = itemCfg;
 
-             cardData.resIndex = cardInfoProto.ResIndex;
 
-             cardData.scores = new Dictionary<int, int>();
 
-             for (int j = 0; j < cardInfoProto.KsAttribute.Count; j++)
 
-             {
 
-                 cardData.scores.Add(cardInfoProto.KsAttribute[j], cardInfoProto.VsAttribute[j]);
 
-             }
 
-             cardData.mainScore = itemCfg.mainScore;
 
-             cardData.resources = CardDataManager.GetCardResources(itemCfg);
 
-             if (_cardDicByType.ContainsKey(0) == false)
 
-             {
 
-                 _cardDicByType[0] = new Dictionary<int, CardData>();
 
-             }
 
-             if (_cardDicByType.ContainsKey(cardData.itemCfg.mainScore) == false)
 
-             {
 
-                 _cardDicByType[cardData.itemCfg.mainScore] = new Dictionary<int, CardData>();
 
-             }
 
-             _cardDicByType[0][cardData.id] = cardData;
 
-             _cardDicByType[cardData.itemCfg.mainScore][cardData.id] = cardData;
 
-         }
 
-         private static List<string> GetCardResources(ItemCfg itemCfg)
 
-         {
 
-             List<string> resources = new List<string>();
 
-             resources.Add(itemCfg.res);
 
-             if (itemCfg.cardRes != "")
 
-             {
 
-                 resources.Add(itemCfg.cardRes);
 
-             }
 
-             return resources;
 
-         }
 
-         private static List<CardData> SortItemList(List<CardData> arrayList)
 
-         {
 
-             arrayList.Sort((CardData a, CardData b) =>
 
-             {
 
-                 int rarityA = a.itemCfg.rarity;
 
-                 int rarityB = b.itemCfg.rarity;
 
-                 if (rarityA < rarityB)
 
-                 {
 
-                     return 1;
 
-                 }
 
-                 else if (rarityA > rarityB)
 
-                 {
 
-                     return -1;
 
-                 }
 
-                 return string.Compare(a.itemCfg.res, b.itemCfg.res);
 
-             });
 
-             return arrayList;
 
-         }
 
-         /// <summary>
 
-         /// 根据卡牌Id获取卡牌升级升星数据,无数据返回null
 
-         /// </summary>
 
-         /// <param name="cardId"></param>
 
-         /// <returns></returns>
 
-         public static CardData GetCardDataById(int cardId)
 
-         {
 
-             return _cardDicByType[0].ContainsKey(cardId) ? _cardDicByType[0][cardId] : null;
 
-         }
 
-         /// <summary>
 
-         /// 根据男主类型获取卡牌列表
 
-         /// </summary>
 
-         public static List<CardData> GetCardListByRarity(int mainScore)
 
-         {
 
-             if (_cardDicByType.ContainsKey(mainScore))
 
-             {
 
-                 Dictionary<int, CardData> cardDic = _cardDicByType[mainScore];
 
-                 CardData[] cardArray = new CardData[cardDic.Count];
 
-                 cardDic.Values.CopyTo(cardArray, 0);
 
-                 List<CardData> cardList = new List<CardData>(cardArray);
 
-                 cardList = CardDataManager.SortItemList(cardList);
 
-                 return cardList;
 
-             }
 
-             return new List<CardData>();
 
-         }
 
-         public static bool isFullLv(int cardId, int lv, bool showTips = true)
 
-         {
 
-             CardData cardData = _cardDicByType[0][cardId];
 
-             if (lv >= CardRarityCfgArray.Instance.GetCfg(cardData.itemCfg.rarity).maxCardLvl && cardData.exp >= CardLvlCfgArray.Instance.GetCfgBycardLvlAndcardRarity(lv, cardData.itemCfg.rarity).needExp)
 
-             {
 
-                 if (showTips == true)
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt("已达到最大等级");
 
-                 }
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         public static bool isFullStar(int cardId, int star, bool showTips = true)
 
-         {
 
-             CardData cardData = _cardDicByType[0][cardId];
 
-             if (CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(cardData.id, star + 1) == null)
 
-             {
 
-                 if (showTips == true)
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt("已达到最大星级");
 
-                 }
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         public static void GetPreViewLvAndExp(int rarity, int curLv, int curExp, int hasExp, out int showLv, out int showExp)
 
-         {
 
-             showLv = curLv;
 
-             showExp = curExp + hasExp;
 
-             int maxLv = CardRarityCfgArray.Instance.GetCfg(rarity).maxCardLvl;
 
-             CardLvlCfg tCurCfg = CardLvlCfgArray.Instance.GetCfgBycardLvlAndcardRarity(showLv, rarity);
 
-             while (showExp >= tCurCfg.needExp && showLv <= maxLv)
 
-             {
 
-                 showExp -= tCurCfg.needExp;
 
-                 if (showLv + 1 > maxLv)
 
-                 {
 
-                     //满级
 
-                     // showLv = showLv - 1;
 
-                     showExp = tCurCfg.needExp;
 
-                     break;
 
-                 }
 
-                 showLv++;
 
-                 tCurCfg = CardLvlCfgArray.Instance.GetCfgBycardLvlAndcardRarity(showLv, rarity);
 
-                 // if (showExp < tCurCfg.needExp)
 
-                 // {
 
-                 //     showLv = showLv - 1;
 
-                 //     break;
 
-                 // }
 
-             }
 
-         }
 
-         public static List<CardData> FilterCardList(List<CardData> cardList)
 
-         {
 
-             List<CardData> _cardList = new List<CardData>();
 
-             for (int i = 0; i < cardList.Count; i++)
 
-             {
 
-                 CardData cardData = cardList[i];
 
-                 bool isRole = _selectRoleList.Count == 0 || _selectRoleList.IndexOf(cardData.itemCfg.subType) >= 0;
 
-                 bool isRarity = _selectRarityList.Count == 0 || _selectRarityList.IndexOf(cardData.itemCfg.rarity) >= 0;
 
-                 int maxLv = CardRarityCfgArray.Instance.GetCfg(cardList[i].itemCfg.rarity).maxCardLvl;
 
-                 bool isFoster = _selectFosterList.Count == 0 ||
 
-                 _selectFosterList.IndexOf(ConstCardState.STATE_FULL_LV) >= 0 && cardList[i].lv == maxLv ||
 
-                 _selectFosterList.IndexOf(ConstCardState.STATE_LV) >= 0 && cardList[i].lv < maxLv ||
 
-                 _selectFosterList.IndexOf(ConstCardState.STATE_FULL_STAR) >= 0 && isFullStar(cardList[i].id, cardList[i].star, false) ||
 
-                 _selectFosterList.IndexOf(ConstCardState.STATE_STAR) >= 0 && !isFullStar(cardList[i].id, cardList[i].star, false);
 
-                 if (isRole && isRarity && isFoster)
 
-                 {
 
-                     _cardList.Add(cardData);
 
-                 }
 
-             }
 
-             return _cardList;
 
-         }
 
-         public static List<CardStoryCfg> GetStoryCfgsById(int cardId)
 
-         {
 
-             if (_cardStoryCfgDic.Keys.Count == 0)
 
-             {
 
-                 CardStoryCfg[] cardStoryCfgs = CardStoryCfgArray.Instance.dataArray;
 
-                 for (int i = 0; i < cardStoryCfgs.Length; i++)
 
-                 {
 
-                     int _cardId = cardStoryCfgs[i].cardId;
 
-                     if (_cardStoryCfgDic.ContainsKey(_cardId) == false)
 
-                     {
 
-                         _cardStoryCfgDic.Add(_cardId, new List<CardStoryCfg>());
 
-                     }
 
-                     _cardStoryCfgDic[_cardId].Add(cardStoryCfgs[i]);
 
-                 }
 
-             }
 
-             return _cardStoryCfgDic.ContainsKey(cardId) ? _cardStoryCfgDic[cardId] : new List<CardStoryCfg>();
 
-         }
 
-     }
 
- }
 
 
  |