From c3525dadcaa037816b654a6bb706284bbbf51af3 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期四, 11 九月 2025 17:50:22 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts --- Main/System/HeroUI/HeroUIManager.cs | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 212 insertions(+), 10 deletions(-) diff --git a/Main/System/HeroUI/HeroUIManager.cs b/Main/System/HeroUI/HeroUIManager.cs index aa04270..9a0dabc 100644 --- a/Main/System/HeroUI/HeroUIManager.cs +++ b/Main/System/HeroUI/HeroUIManager.cs @@ -1,6 +1,8 @@ 锘縰sing System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using Jace.Operations; using LitJson; using UnityEngine; @@ -13,25 +15,36 @@ public int selectHeroListJob = 0; //姝﹀皢鍒楄〃鐣岄潰 绛涢�夎亴涓� public int selectHeroListCountry = 0; //姝﹀皢鍒楄〃鐣岄潰绛涢�夊浗瀹� public string selectHeroGuid; //閫変腑鐨勬灏唅d + public int[] heroRedpointItemList; //鏈夊奖鍝嶇孩鐐圭殑閬撳叿 #endregion public WaitHeroFuncResponse waitResponse; //璇锋眰姝﹀皢鍔熻兘锛屼笌鏈嶅姟绔氦浜� //鐢ㄤ簬闈炰笂闃垫灏嗘垬鍔涘彉鍖栨椂 姝﹀皢ID锛氫笂娆℃垬鍔� //浣跨敤鏂规硶锛氬叾浠栧姛鑳界晫闈㈣缃鍊煎嵆鍙� - public KeyValuePair<string, long> lastFightPower = new KeyValuePair<string, long>(); + public KeyValuePair<string, long> lastFightPower = new KeyValuePair<string, long>(); public override void Init() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; + DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnLoginLoadOK; HeroManager.Instance.onHeroChangeEvent += OnHeroChangeEvent; + GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; + PackManager.Instance.RefreshItemEvent += RefreshItemEvent; + TeamManager.Instance.OnTeamChange += OnTeamChangeEvent; ParseConfig(); + InitHeroOnTeamRedpointList(); + InitHeroBookRedpointList(); } public override void Release() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; + DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnLoginLoadOK; HeroManager.Instance.onHeroChangeEvent -= OnHeroChangeEvent; + GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; + PackManager.Instance.RefreshItemEvent -= RefreshItemEvent; + TeamManager.Instance.OnTeamChange -= OnTeamChangeEvent; } void ParseConfig() @@ -42,13 +55,11 @@ rebornFormula = config.Numerical3; rebornPayBackPer = int.Parse(config.Numerical4); deletePayBackPer = int.Parse(config.Numerical5); - + ParseGiftConfig(); - config = FuncConfigConfig.Get("HeroBook"); - var arr = JsonMapper.ToObject<int[]>(config.Numerical1); - bookMoneyType = arr[0]; - bookMoneyValue = arr[1]; + config = FuncConfigConfig.Get("HeroRedpoint"); + heroRedpointItemList = JsonMapper.ToObject<int[]>(config.Numerical1); } public void OnBeforePlayerDataInitialize() @@ -58,13 +69,23 @@ awakeRebirthCnt = 0; waitResponse = default; heroCollectInfoDic.Clear(); + newHeroIDList.Clear(); + } + + + void OnLoginLoadOK() + { + UpdateHeroCardRedpoint(); } private void OnHeroChangeEvent(HeroInfo hero) { if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) return; + WaitServerResponse(hero); + + refreshRedPoint = true; } private void WaitServerResponse(HeroInfo hero) @@ -98,7 +119,7 @@ { var config = HeroAwakeConfig.GetHeroAwakeConfig(hero.heroId, hero.awakeLevel); if (hero.talentAwakeRandomIDList.Count > 0) - { + { UIManager.Instance.OpenWindow<HeroAwakeSelectGiftWin>(); } else if (config.SkillID != 0 || config.UnlockTalentSlot != 0) @@ -252,6 +273,7 @@ public int selectHeroCallListJob = 0; //绛涢�夎亴涓� public int selectHeroCallListCountry = 0; //绛涢�夊浗瀹� + public List<int> newHeroIDList = new List<int>(); //鏂版灏嗗垪琛� public bool IsNewHero(int heroID) { HB122_tagSCHeroInfo.tagSCHero bookInfo; @@ -262,6 +284,7 @@ //鏇寸簿鍑嗙殑 闇�瑕佹瘮杈冩湰娆℃娊鐨勫悓姝﹀皢涓暟 鍜� 鑳屽寘閲屾湁鐨勪釜鏁板啀姣旇緝 if (HappyXBModel.Instance.GetCountInResult(heroID) >= HeroManager.Instance.GetHeroCountByID(heroID)) { + AddNewHero(heroID); return true; } else @@ -275,14 +298,34 @@ } } + AddNewHero(heroID); return true; + } + + public void AddNewHero(int heroID) + { + if (newHeroIDList.Contains(heroID)) + { + return; + } + newHeroIDList.Add(heroID); + } + + public void RemoveNewHero(int heroID) + { + if (!newHeroIDList.Contains(heroID)) + { + return; + } + newHeroIDList.Remove(heroID); + refreshRedPoint = true; } List<int> allHeroCallScoreList = new List<int>(); //绉垎鎷涘嫙鍒楄〃 public void SortHeroCallList() { if (allHeroCallScoreList.IsNullOrEmpty()) - { + { allHeroCallScoreList = HappyXBModel.Instance.GetAllGridLibItemIDByType((int)HappXBTitle.HeroCallScore); } heroCallSortList = new List<int>(); @@ -319,13 +362,11 @@ HeroConfig heroA = HeroConfig.Get(idA); HeroConfig heroB = HeroConfig.Get(idB); - // 鎺掑簭瑙勫垯锛氭灏嗗搧璐紴姝﹀皢ID if (heroA.Quality != heroB.Quality) { return heroA.Quality > heroB.Quality ? -1 : 1; } - return heroA.HeroID.CompareTo(heroB.HeroID); } @@ -333,6 +374,167 @@ #endregion + // 浼樺厛鍔熻兘鎻愰啋绫诲瀷锛�1瑙夐啋 2鍗囨槦 3绐佺牬 4鍗囩骇 + // 涓荤嚎涓婇樀姝﹀皢鎵嶉渶瑕佹彁閱� 瑙夐啋锛炲崌鏄燂紴绐佺牬锛炲崌绾� + public int GetFuncState(HeroInfo hero) + { + if (!hero.IsInTeamByTeamType(TeamType.Story)) + { + return 0; + } + + var heroCnt = PackManager.Instance.GetItemCountByID(PackType.Hero, hero.heroId); + var itemPack = PackManager.Instance.GetSinglePack(PackType.Item); + //5鏄熷悗鎵嶈兘瑙夐啋 + if (hero.heroStar < starLevelCanAwake) + { + if (heroCnt > 1) return 2; + } + else + { + //鍒ゆ柇瑙夐啋鏉愭枡鏄惁瓒冲 + var maxAwakeLV = HeroAwakeConfig.GetMaxAwakeLV(hero.heroId); + if (hero.awakeLevel < maxAwakeLV) + { + var config = HeroQualityAwakeConfig.GetQualityAwakeConfig(hero.Quality, hero.awakeLevel); + if (itemPack.GetCountById(config.UPCostItem[0]) >= config.UPCostItem[1]) + { + return 1; + } + } + } + + if (heroCnt > 1) return 2; + + var maxBreakLV = HeroBreakConfig.GetMaxBreakLv(hero.heroId); + if (hero.breakLevel < maxBreakLV) + { + if (IsLVMaxByBreakLevel(hero)) + { + var breakConfig = HeroQualityBreakConfig.GetQualityBreakConfig(hero.Quality, hero.breakLevel); + if (itemPack.GetCountById(breakConfig.UPCostItem[0]) >= breakConfig.UPCostItem[1]) + { + return 3; + } + } + } + + if (!IsLVMax(hero)) + { + var lvupConfig = HeroQualityLVConfig.GetQualityLVConfig(hero.Quality, hero.heroLevel); + if (itemPack.GetCountById(lvupConfig.UPCostItem[0]) >= lvupConfig.UPCostItem[1]) + { + return 4; + } + } + return 0; + } + + #region 绾㈢偣 + + public bool refreshRedPoint = false; + List<Redpoint> heroOnTeamRedpointList = new List<Redpoint>(); //涓婇樀鐨勬灏嗙孩鐐� + List<Redpoint> heroBookRedpointList = new List<Redpoint>(); //鍥鹃壌鎵�鏈夋灏嗙孩鐐� + + //鏂版爣璇嗙殑绾㈢偣 鎵�鏈夋灏嗙粺涓�涓� + Redpoint newMarkRedPoint = new Redpoint(MainRedDot.HeroCardRedpoint, MainRedDot.HeroCardRedpoint * 10 + 9); + void InitHeroOnTeamRedpointList() + { + heroOnTeamRedpointList.Clear(); + for (int i = 0; i < TeamConst.MaxTeamHeroCount; i++) + { + heroOnTeamRedpointList.Add(new Redpoint(MainRedDot.HeroCardRedpoint, MainRedDot.HeroCardRedpoint * 10 + i)); + } + } + + + //姝﹀皢鍗$殑绾㈢偣:鍙粰涓婇樀姝﹀皢鍒风孩鐐癸紙鍚柊鏍囪瘑锛夛紝闈炰笂闃垫灏嗙殑鏂板浘鏍囨寜鍥剧墖澶勭悊涓嶅綊绫讳负绾㈢偣 + void UpdateHeroCardRedpoint() + { + if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Hero)) + return; + + var team = TeamManager.Instance.GetTeam(TeamType.Story); + for (int i = 0; i < heroOnTeamRedpointList.Count; i++) + { + var redpoint = heroOnTeamRedpointList[i]; + var teamHero = team.GetServerHeroByIndex(i); + if (teamHero != null) + { + var hero = HeroManager.Instance.GetHero(teamHero.guid); + if (hero != null) + { + if (GetFuncState(hero) > 0) + { + redpoint.state = RedPointState.Simple; + continue; + } + } + } + + redpoint.state = RedPointState.None; + } + + newMarkRedPoint.state = newHeroIDList.Count > 0 ? RedPointState.New : RedPointState.None; + } + + + void InitHeroBookRedpointList() + { + heroBookRedpointList.Clear(); + foreach (var key in HeroConfig.GetKeys()) + { + heroBookRedpointList.Add(new Redpoint(MainRedDot.HeroCardCollectRedpoint, MainRedDot.HeroCardCollectRedpoint * 10000000 + key)); + } + } + + void UpdateHeroBookRedpoint() + { + if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Hero)) + return; + + foreach (var redpoint in heroBookRedpointList) + { + var heroID = redpoint.id % 10000000; + var state = GetHeroBookState(heroID, HeroConfig.Get(heroID).Quality); + if (state == 1 || state == 3 || state == 4) + { + redpoint.state = RedPointState.Simple; + continue; + } + redpoint.state = RedPointState.None; + } + } + + + void OnSecondEvent() + { + if (refreshRedPoint) + { + UpdateHeroCardRedpoint(); + refreshRedPoint = false; + } + } + + void RefreshItemEvent(PackType packType, int index, int itemID) + { + if (packType != PackType.Item) + return; + + if (heroRedpointItemList.Contains(itemID)) + { + refreshRedPoint = true; + } + } + + void OnTeamChangeEvent(TeamType teamType) + { + if (teamType == TeamType.Story) + { + refreshRedPoint = true; + } + } + #endregion } #region 绛夊緟鏈嶅姟绔搷搴� -- Gitblit v1.8.0