| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | |
| | | using UnityEngine; |
| | | |
| | | //图鉴和皮肤 |
| | | public partial class HeroUIManager : GameSystemManager<HeroUIManager> |
| | | { |
| | | |
| | | #region 图鉴和皮肤 |
| | | |
| | | public Dictionary<int, List<int>> heroCollectDict { get; private set; } = new Dictionary<int, List<int>>(); //武将图鉴按品质列表 |
| | | public int selectHeroCollectListJob = 0; //武将列表界面 筛选职业 |
| | | public int selectHeroCollectListCountry = 0; //武将列表界面筛选国家 |
| | | public int selectCollectHeroID; //选中的武将id |
| | | |
| | | public int bookMoneyType; //图鉴奖励货币类型 |
| | | public int bookMoneyValue;//图鉴奖励货币数量 |
| | | |
| | | |
| | | //图鉴和皮肤的激活情况 |
| | | public Dictionary<int, HB122_tagSCHeroInfo.tagSCHero> heroCollectInfoDic { get; private set; } = new Dictionary<int, HB122_tagSCHeroInfo.tagSCHero>(); |
| | | Dictionary<int, HB122_tagSCHeroInfo.tagSCHero> heroCollectInfoDic = new Dictionary<int, HB122_tagSCHeroInfo.tagSCHero>(); |
| | | |
| | | public int bookPer; |
| | | public int allHeroBookPer; //全体武将的图鉴激活百分比 |
| | | public event Action OnHeroCollectEvent; |
| | | |
| | | public void UpdateHeroCollectInfo(HB122_tagSCHeroInfo netPack) |
| | |
| | | { |
| | | heroCollectInfoDic[(int)netPack.HeroInfoList[i].HeroID] = netPack.HeroInfoList[i]; |
| | | } |
| | | bookPer = GetHeroCollectBookPer(); |
| | | allHeroBookPer = GetHeroCollectBookPer(); |
| | | OnHeroCollectEvent?.Invoke(); |
| | | } |
| | | |
| | |
| | | return per; |
| | | } |
| | | |
| | | public HB122_tagSCHeroInfo.tagSCHero GetHeroBookInfo(int heroID) |
| | | { |
| | | public bool TryGetHeroBookInfo(int heroID, out HB122_tagSCHeroInfo.tagSCHero heroData) |
| | | { |
| | | if (heroCollectInfoDic.ContainsKey(heroID)) |
| | | { |
| | | return heroCollectInfoDic[heroID]; |
| | | heroData = heroCollectInfoDic[heroID]; |
| | | return true; |
| | | } |
| | | return null; |
| | | heroData = new HB122_tagSCHeroInfo.tagSCHero(); |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | public void SortHeroCollectList() |
| | | { |
| | | var heroIDs = HeroConfig.GetKeys().ToList(); |
| | | |
| | | heroCollectDict.Clear(); |
| | | foreach (var heroID in heroIDs) |
| | | { |
| | | HeroConfig heroConfig = HeroConfig.Get(heroID); |
| | | if (!heroCollectDict.ContainsKey(heroConfig.Quality)) |
| | | { |
| | | heroCollectDict[heroConfig.Quality] = new List<int>(); |
| | | } |
| | | //过滤职业国家 |
| | | if (selectHeroCollectListJob != 0 && selectHeroCollectListJob != heroConfig.Class) |
| | | { |
| | | continue; |
| | | } |
| | | if (selectHeroCollectListCountry != 0 && selectHeroCollectListCountry != heroConfig.Country) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | heroCollectDict[heroConfig.Quality].Add(heroID); |
| | | } |
| | | } |
| | | |
| | | //图鉴总上限等级 = 图鉴星级上限 + 图鉴突破上限 |
| | | public int GetHeroBookMaxLevel(int heroID, int quality) |
| | | { |
| | | return GetMaxStarCount(heroID, quality) + HeroBreakConfig.GetMaxBreakLv(heroID); |
| | | } |
| | | |
| | | public int GetHeroBookLevel(int heroID) |
| | | { |
| | | if (heroCollectInfoDic.ContainsKey(heroID)) |
| | | { |
| | | return heroCollectInfoDic[heroID].BookStarLV + heroCollectInfoDic[heroID].BookBreakLV; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //分为0未获得、1可激活、2常规、3突破升级、4、星升级、5已满级 |
| | | public int GetHeroBookState(int heroID, int quality) |
| | | { |
| | | int funcState = 0; |
| | | |
| | | HB122_tagSCHeroInfo.tagSCHero colData; |
| | | TryGetHeroBookInfo(heroID, out colData); |
| | | int maxBreakLV = colData.BookBreakLVH; //历史最高突破等级 |
| | | int maxStarLV = colData.BookStarLVH; //历史最高星级 |
| | | |
| | | if (colData.BookInitState == 0) |
| | | { |
| | | funcState = 0; |
| | | } |
| | | else if (colData.BookInitState == 1) |
| | | { |
| | | funcState = 1; |
| | | } |
| | | else if (colData.BookInitState == 2) |
| | | { |
| | | if (GetHeroBookMaxLevel(heroID, quality) == colData.BookBreakLV + colData.BookStarLV) |
| | | { |
| | | funcState = 5; |
| | | } |
| | | else if (maxBreakLV + maxStarLV == colData.BookBreakLV + colData.BookStarLV) |
| | | { |
| | | funcState = 2; |
| | | } |
| | | else |
| | | { |
| | | //优先突破升级 |
| | | if (colData.BookBreakLV < colData.BookBreakLVH) |
| | | { |
| | | funcState = 3; |
| | | } |
| | | else |
| | | { |
| | | funcState = 4; |
| | | } |
| | | } |
| | | |
| | | } |
| | | return funcState; |
| | | } |
| | | |
| | | //找到可以操作的图鉴武将 |
| | | public int FindHeroIDCanAddCollectAttr(int excludeHeroID = 0) |
| | | { |
| | | foreach (var kv in heroCollectInfoDic) |
| | | { |
| | | if (kv.Key == excludeHeroID) |
| | | continue; |
| | | var state = GetHeroBookState(kv.Key, HeroConfig.Get(kv.Key).Quality); |
| | | if (state == 1 || state == 3 || state == 4) |
| | | { |
| | | return kv.Key; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetHeroBookPer(int heroID) |
| | | { |
| | | var config = HeroQualityConfig.Get(HeroConfig.Get(heroID).Quality); |
| | | HB122_tagSCHeroInfo.tagSCHero heroData; |
| | | TryGetHeroBookInfo(heroID, out heroData); |
| | | if (heroData.BookInitState < 2) |
| | | { |
| | | return 0; |
| | | } |
| | | return config.BookInitAddPer + heroData.BookStarLV * config.BookStarAddPer + heroData.BookBreakLV * config.BookBreakLVAddPer; |
| | | } |
| | | } |
| | | |