From 39001a600fcae2bcf27c225df8752d75fb92fef4 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 11:18:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/System/Hero/HeroManager.cs |   99 +++++++++++++++++++++----------------------------
 1 files changed, 42 insertions(+), 57 deletions(-)

diff --git a/Main/System/Hero/HeroManager.cs b/Main/System/Hero/HeroManager.cs
index d116aab..49ef7bd 100644
--- a/Main/System/Hero/HeroManager.cs
+++ b/Main/System/Hero/HeroManager.cs
@@ -10,17 +10,9 @@
     //鍒濆鍒涘缓锛�0725锛夛紝鍚庣画璺熼殢鑳屽寘浜嬩欢澧炲姞鍒犻櫎  key = guid
     protected Dictionary<string, HeroInfo> heroInfoDict = new Dictionary<string, HeroInfo>();
 
-    //姝﹀皢鍒楄〃鐣岄潰
-    public List<string> heroSortList = new List<string>();
-
-    //姝﹀皢绾㈢偣
-    //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()
     {
@@ -41,7 +33,7 @@
 
     void OnBeforePlayerDataInitialize()
     {
-        heroSortList.Clear();
+
         heroInfoDict.Clear();
     }
 
@@ -66,7 +58,7 @@
         }
     }
 
-    void DeleteHero(PackType packType, string guid)
+    void DeleteHero(PackType packType, string guid, int itemID, int index, int clearType)
     {
         if (packType == PackType.Hero)
         {
@@ -74,9 +66,8 @@
             heroInfoDict.TryGetValue(guid, out heroInfo);
 
             heroInfoDict.Remove(guid);
-            
-            if (null != heroInfo)
-                onHeroDeleteEvent?.Invoke(heroInfo);
+
+            onHeroDeleteEvent?.Invoke(itemID);
         }
     }
 
@@ -92,14 +83,41 @@
         return heroInfoDict.Values.ToList();
     }
 
+    public List<string> GetHeroGuidList(int job = 0, int country = 0)
+    {
+        if (job == 0 && country == 0)
+            return heroInfoDict.Keys.ToList();
+
+
+        List<string> retGuidList = new List<string>();
+        foreach (string guid in heroInfoDict.Keys)
+        {
+            HeroInfo heroInfo = heroInfoDict[guid];
+            //0浠h〃鍏ㄩ儴
+            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()
     {
         List<HeroInfo> heroList = new List<HeroInfo>(heroInfoDict.Values);
 
         heroList.Sort((a, b) =>
         {
-            int power1 = a.CalculatePower();
-            int power2 = b.CalculatePower();
+            long power1 = a.CalculateFightPower(false);
+            long power2 = b.CalculateFightPower(false);
 
             if (power1 == power2)
             {
@@ -119,52 +137,19 @@
         return retList;
     }
 
-    public bool waitResortHeroList = false;
 
-
-    //鍒锋柊鏃舵満, 鎵撳紑姝﹀皢鐣岄潰 鎴栬�� 鍏抽棴鍔熻兘鐣岄潰
-    public void SortHeroList()
+    public int GetHeroCount()
     {
-        heroSortList = heroInfoDict.Keys.ToList();
-        heroSortList.Sort(CmpHero);
+        return heroInfoDict.Count;
     }
 
-
-    int CmpHero(string guidA, string guidB)
+    public bool HasHero(int heroID)
     {
-        HeroInfo heroA = heroInfoDict[guidA];
-        HeroInfo heroB = heroInfoDict[guidB];
-        if (heroA == null || heroB == null)
-        {
-            return 0;
-        }
-        // 鎺掑簭瑙勫垯锛氫笂闃�>姝﹀皢绛夌骇锛炵獊鐮寸瓑绾э紴姝﹀皢瑙夐啋闃剁骇锛炴灏嗗搧璐紴姝﹀皢鍚炲櫖鏄熺骇锛炴灏咺D
-        if (heroA.isInMainBattle != heroB.isInMainBattle)
-        {
-            return heroA.isInMainBattle ? -1 : 1;
-        }
-        if (heroA.heroLevel != heroB.heroLevel)
-        {
-            return heroA.heroLevel > heroB.heroLevel ? -1 : 1;
-        }
-        if (heroA.breakLevel != heroB.breakLevel)
-        {
-            return heroA.breakLevel > heroB.breakLevel ? -1 : 1;
-        }
-        if (heroA.awakeLevel != heroB.awakeLevel)
-        {
-            return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1;
-        }
-        if (heroA.Quality != heroB.Quality)
-        {
-            return heroA.Quality > heroB.Quality ? -1 : 1;
-        }
-        if (heroA.heroStar != heroA.heroStar)
-        {
-            return heroA.heroStar > heroB.heroStar ? -1 : 1;
-        }
-
-        return heroA.heroId.CompareTo(heroB.heroId);
+        return PackManager.Instance.GetSinglePack(PackType.Hero).HasItem(heroID);
     }
 
+    public int GetHeroCountByID(int heroID)
+    {
+        return (int)PackManager.Instance.GetSinglePack(PackType.Hero).GetCountById(heroID);
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0