| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 | 
							- 
 
- 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 int CardResInitWidth = 1440;
 
-         public static int  CardResInitHight = 1920;
 
-         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();
 
-             _cardStoryCfgDic.Clear();
 
-         }
 
-         public static void Add(CardInfoProto cardInfoProto)
 
-         {
 
-             CardData cardData = new CardData();
 
-             cardData.id = cardInfoProto.CardId;
 
-             cardData.lv = cardInfoProto.Lvl;
 
-             cardData.exp = cardInfoProto.Exp;
 
-             cardData.star = cardInfoProto.Star;
 
-             cardData.mainScore = cardInfoProto.MainScore;
 
-             cardData.resIndex = cardInfoProto.ResIndex;
 
-             for (int i = 0; i < cardInfoProto.KsStarBonus.Count; i++)
 
-             {
 
-                 cardData.starRewardsState[cardInfoProto.KsStarBonus[i]] = cardInfoProto.VsStarBonus[i];
 
-             }
 
-             cardData.scores = new Dictionary<int, int>();
 
-             for (int j = 0; j < cardInfoProto.KsAttribute.Count; j++)
 
-             {
 
-                 cardData.scores.Add(cardInfoProto.KsAttribute[j], cardInfoProto.VsAttribute[j]);
 
-             }
 
-             if (_cardDicByType.ContainsKey(0) == false)
 
-             {
 
-                 _cardDicByType[0] = new Dictionary<int, CardData>();
 
-             }
 
-             if (_cardDicByType.ContainsKey(cardData.mainScore) == false)
 
-             {
 
-                 _cardDicByType[cardData.mainScore] = new Dictionary<int, CardData>();
 
-             }
 
-             _cardDicByType[0][cardData.id] = cardData;
 
-             _cardDicByType[cardData.mainScore][cardData.id] = cardData;
 
-             if(GameGlobal.AfterDataInited)
 
-             {
 
-                 PreloadManager.Instance.PreloadCardAnimationRes(cardData.id);
 
-             }
 
-         }
 
-         public 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;
 
-         }
 
-         //默认词牌排序规则 :稀有度>星级>等级>种类(风>花>雪>月)
 
-         public 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;
 
-                 }
 
-                 else
 
-                 {
 
-                     if (a.star < b.star)
 
-                     {
 
-                         return 1;
 
-                     }
 
-                     else if (a.star > b.star)
 
-                     {
 
-                         return -1;
 
-                     }
 
-                     else
 
-                     {
 
-                         if (a.lv < b.lv)
 
-                             return 1;
 
-                         else if (a.lv > b.lv)
 
-                             return -1;
 
-                         else
 
-                         {
 
-                             if (a.mainScore > b.mainScore)
 
-                                 return 1;
 
-                             else if (a.mainScore < b.mainScore)
 
-                                 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)
 
-         {
 
-             if (_cardDicByType.Count == 0 || !_cardDicByType.ContainsKey(0) || !_cardDicByType[0].ContainsKey(cardId))
 
-             {
 
-                 return null;
 
-             }
 
-             return _cardDicByType[0][cardId];
 
-         }
 
-         /// <summary>
 
-         /// 根据男主类型获取词牌列表
 
-         /// </summary>
 
-         public static List<CardData> GetCardListByRoleType(int mainScore)
 
-         {
 
-             if (_cardDicByType.ContainsKey(mainScore))
 
-             {
 
-                 return _cardDicByType[mainScore].Values.ToList();
 
-             }
 
-             return new List<CardData>();
 
-         }
 
-         public static bool isFullLv(int cardId, int lv, bool showTips = true)
 
-         {
 
-             CardData cardData = _cardDicByType[0][cardId];
 
-             int rarity = cardData.itemCfg.rarity;
 
-             int maxLv = CardRarityCfgArray.Instance.GetCfg(rarity).maxCardLvl;
 
-             if (lv >= maxLv && cardData.exp >= CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(rarity, maxLv).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 cardId, int curLv, int curExp, int hasExp, out int showLv, out int showExp)
 
-         {
 
-             showLv = curLv;
 
-             showExp = curExp + hasExp;
 
-             CardData cardData = _cardDicByType[0][cardId];
 
-             int rarity = cardData.itemCfg.rarity;
 
-             int maxLv = CardRarityCfgArray.Instance.GetCfg(rarity).maxCardLvl;
 
-             CardLvlCfg tCurCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(rarity, showLv);
 
-             while (showExp >= tCurCfg.needExp && showLv <= maxLv)
 
-             {
 
-                 showExp -= tCurCfg.needExp;
 
-                 if (showLv + 1 > maxLv)
 
-                 {
 
-                     //满级
 
-                     showExp = tCurCfg.needExp;
 
-                     break;
 
-                 }
 
-                 showLv++;
 
-                 tCurCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(rarity, showLv);
 
-             }
 
-         }
 
-         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(cardData.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>();
 
-         }
 
-         //升星是否满足材料消耗
 
-         public static bool GetUpStarEnoughMaterial(int cardId)
 
-         {
 
-             CardData cardData = CardDataManager.GetCardDataById(cardId);
 
-             CardStarCfg starCfg = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(cardId, cardData.star);
 
-             for (int i = 0; i < starCfg.materiarsArr.Length; i++)
 
-             {
 
-                 if (GameGlobal.myNumericComponent.GetAsInt(NumericType.IsAutoSelect) == 0 &&
 
-                     ItemDataManager.GetItemNum(starCfg.materiarsArr[i][0]) < starCfg.materiarsArr[i][1])
 
-                     return false;
 
-                 else if (GameGlobal.myNumericComponent.GetAsInt(NumericType.IsAutoSelect) == 1 &&
 
-                     (i == 0 && (ItemDataManager.GetItemNum(6003001) + ItemDataManager.GetItemNum(starCfg.materiarsArr[i][0])) < starCfg.materiarsArr[i][1]) || (i == 1 && (ItemDataManager.GetItemNum(6003002) + ItemDataManager.GetItemNum(starCfg.materiarsArr[i][0])) < starCfg.materiarsArr[i][1]))
 
-                     return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 根据主属性获取有序牌ID列表(排序规则: 已获得词牌按稀有度从高到低 > 未获得词牌按稀有度从高到低 > 按词牌名字拼音)
 
-         /// </summary>
 
-         /// <param name="mainScore">
 
-         /// 0 - 全部
 
-         /// </param>
 
-         /// <returns></returns>
 
-         public static List<int> GetAllCardIdListByRoleType(int mainScore)
 
-         {
 
-             List<int> result = new List<int>();
 
-             List<ItemCfg> itemCfgs = ItemCfgArray.Instance.GetCfgsByitemType(ConstItemType.CARD);
 
-             itemCfgs.Sort((a, b) =>
 
-             {
 
-                 bool haveA = GetCardDataById(a.id) != null;
 
-                 bool haveB = GetCardDataById(b.id) != null;
 
-                 if (haveB && !haveA)
 
-                 {
 
-                     return 1;
 
-                 }
 
-                 else if (!haveB && haveA)
 
-                 {
 
-                     return -1;
 
-                 }
 
-                 if (a.rarity != b.rarity)
 
-                 {
 
-                     return a.rarity > b.rarity ? -1 : 1;
 
-                 }
 
-                 return a.res.CompareTo(b.res);
 
-             });
 
-             for (int i = 0; i < itemCfgs.Count; i++)
 
-             {
 
-                 if (itemCfgs[i].isHide > 0)
 
-                 {
 
-                     continue;
 
-                 }
 
-                 if (mainScore == 0 || itemCfgs[i].mainScore == mainScore)
 
-                 {
 
-                     result.Add(itemCfgs[i].id);
 
-                 }
 
-             }
 
-             return result;
 
-         }
 
-         public static void GetTotalProgress(out int haveCount, out int totalCount, int mainScore = 0)
 
-         {
 
-             totalCount = GlobalCfgArray.globalCfg.CardCount;
 
-             if (mainScore != 0)
 
-             {
 
-                 List<ItemCfg> itemCfgs = ItemCfgArray.Instance.GetCfgsByitemType(ConstItemType.CARD);
 
-                 totalCount = 0;
 
-                 for (int i = 0; i < itemCfgs.Count; i++)
 
-                 {
 
-                     if (itemCfgs[i].isHide > 0)
 
-                     {
 
-                         continue;
 
-                     }
 
-                     if (itemCfgs[i].mainScore == mainScore)
 
-                     {
 
-                         ++totalCount;
 
-                     }
 
-                 }
 
-             }
 
-             haveCount = _cardDicByType.ContainsKey(mainScore) ? _cardDicByType[mainScore].Count : 0;
 
-         }
 
-     }
 
- }
 
 
  |