| | |
| | | //初始创建(0725),后续跟随背包事件增加删除 key = guid |
| | | protected Dictionary<string, HeroInfo> heroInfoDict = new Dictionary<string, HeroInfo>(); |
| | | |
| | | |
| | | |
| | | //武将红点 |
| | | //MainRedDot.HeroCardRedpoint * 1000 + hero.itemHero.gridIndex; |
| | | |
| | | public Action<HeroInfo> onNewHeroEvent; |
| | | |
| | | public Action<HeroInfo> onHeroChangeEvent; |
| | | |
| | | public Action<HeroInfo> onHeroDeleteEvent; |
| | | public Action<int> onHeroDeleteEvent; |
| | | |
| | | public override void Init() |
| | | { |
| | |
| | | |
| | | void OnBeforePlayerDataInitialize() |
| | | { |
| | | |
| | | |
| | | heroInfoDict.Clear(); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | void DeleteHero(PackType packType, string guid) |
| | | void DeleteHero(PackType packType, string guid, int itemID, int index, int clearType) |
| | | { |
| | | if (packType == PackType.Hero) |
| | | { |
| | |
| | | heroInfoDict.TryGetValue(guid, out heroInfo); |
| | | |
| | | heroInfoDict.Remove(guid); |
| | | |
| | | if (null != heroInfo) |
| | | onHeroDeleteEvent?.Invoke(heroInfo); |
| | | |
| | | onHeroDeleteEvent?.Invoke(itemID); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (job == 0 && country == 0) |
| | | return heroInfoDict.Keys.ToList(); |
| | | |
| | | return heroInfoDict.Keys.Where((x) => |
| | | |
| | | |
| | | List<string> retGuidList = new List<string>(); |
| | | foreach (string guid in heroInfoDict.Keys) |
| | | { |
| | | HeroInfo heroInfo = heroInfoDict[x]; |
| | | return heroInfo.heroConfig.Class == job && heroInfo.heroConfig.Country == country; |
| | | }).ToList(); |
| | | HeroInfo heroInfo = heroInfoDict[guid]; |
| | | //0代表全部 |
| | | if (job == 0 || country == 0) |
| | | { |
| | | if (job != 0 && job == heroInfo.heroConfig.Class) |
| | | retGuidList.Add(guid); |
| | | if (country != 0 && country == heroInfo.heroConfig.Country) |
| | | retGuidList.Add(guid); |
| | | } |
| | | else |
| | | { |
| | | if (job == heroInfo.heroConfig.Class && country == heroInfo.heroConfig.Country) |
| | | retGuidList.Add(guid); |
| | | } |
| | | } |
| | | return retGuidList; |
| | | } |
| | | |
| | | public List<HeroInfo> GetPowerfulHeroList() |
| | |
| | | |
| | | heroList.Sort((a, b) => |
| | | { |
| | | int power1 = a.CalculatePower(); |
| | | int power2 = b.CalculatePower(); |
| | | long power1 = a.CalculatePower(false); |
| | | long power2 = b.CalculatePower(false); |
| | | |
| | | if (power1 == power2) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | public int GetHeroCount() |
| | | { |
| | | return heroInfoDict.Count; |
| | | } |
| | | |
| | | public bool HasHero(int heroID) |
| | | { |
| | | return PackManager.Instance.GetSinglePack(PackType.Hero).HasItem(heroID); |
| | | } |
| | | |
| | | |
| | | public int GetHeroCountByID(int heroID) |
| | | { |
| | | return (int)PackManager.Instance.GetSinglePack(PackType.Hero).GetCountById(heroID); |
| | | } |
| | | } |