From 09bc892c7283df8757a07b646d5af21ddaa263d1 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期四, 06 十一月 2025 18:22:34 +0800
Subject: [PATCH] 164 天子的考验-客户端

---
 Main/System/Hero/HeroInfo.cs |  252 +++++++++++++++++++++++---------------------------
 1 files changed, 116 insertions(+), 136 deletions(-)

diff --git a/Main/System/Hero/HeroInfo.cs b/Main/System/Hero/HeroInfo.cs
index 9e36344..e0b9657 100644
--- a/Main/System/Hero/HeroInfo.cs
+++ b/Main/System/Hero/HeroInfo.cs
@@ -2,39 +2,15 @@
 using UnityEngine;
 using LitJson;
 
+//  姝﹀皢淇℃伅锛氬疄闄呰幏寰楃殑姝﹀皢锛屼笉鍖呭惈鍥鹃壌鏁版嵁
 public partial class HeroInfo
 {
-    //  姝﹀皢鏈嶅姟鍣ㄥ敮涓�ID
-    public long sid;
-
     //  姝﹀皢閰嶇疆琛↖D
-    public int heroId
-    {
-        get
-        {
-            #if UNITY_EDITOR
-            if (null == itemHero)
-            {
-                return 520001;
-            }
-            #endif
+    public int heroId;
 
-            return itemHero.config.ID;
-        }
-    }
-
-    //  姝﹀皢绛夌骇
-    public int heroLevel;
-
-    //  姝﹀皢鏄熺骇
-    public int heroStar;
-
-    //  姝﹀皢绐佺牬绛夌骇
-    public int breakLevel;
-
-    //  姝﹀皢瑙夐啋绛夌骇
-    public int awakeLevel;
-
+    //  姝﹀皢閰嶇疆
+    public HeroConfig heroConfig { get; private set; }
+    public ItemModel itemHero;  //寮曠敤鑳屽寘閲岀殑 鏁版嵁鍚屾
 
     public HeroCountry heroCountry
     {
@@ -44,6 +20,9 @@
         }
     }
 
+    //  鍝佽川閰嶇疆
+    public HeroQualityConfig qualityConfig { get; private set; }
+
     public int Quality
     {
         get
@@ -52,141 +31,142 @@
         }
     }
 
-    public ItemModel itemHero;
-
-    // public readonly CB122_tagSCHeroInfo.tagSCHero scHeroInfo;
-
-    //  姝﹀皢閰嶇疆
-    public HeroConfig heroConfig;
-    //  瑙夐啋閰嶇疆
-    public HeroAwakeConfig awakeConfig;
-    //  绐佺牬閰嶇疆
-    public HeroBreakConfig breakConfig;
-    //  缇佺粖閰嶇疆
-    public HeroFetterConfig fetterConfig;
-    //  鍝佽川瑙夐啋閰嶇疆
-    public HeroQualityAwakeConfig qualityAwakeConfig;
-    //  鍝佽川閰嶇疆
-    public HeroQualityConfig qualityConfig;
-    //  鍝佽川绐佺牬閰嶇疆
-    public HeroQualityBreakConfig qualityBreakConfig;
-
-    public List<HeroFetterInfo> fetterInfoList = new List<HeroFetterInfo>();
-    public List<HeroTalentInfo> talentList = new List<HeroTalentInfo>();
-
-
-    public HeroInfo(/*CB122_tagSCHeroInfo.tagSCHero _scHeroInfo, */ItemModel _itemHero)
+    //  姝﹀皢绛夌骇
+    public int heroLevel
     {
-        // scHeroInfo = _scHeroInfo;
+        get
+        {
+            if (itemHero == null)
+                return 0;
+            return itemHero.GetUseDataFirstValue(70);
+        }
+    }
+
+
+    public bool isLock
+    {
+        get
+        {
+            return itemHero.itemInfo.isLock;
+        }
+    }
+
+
+    //宸插涔犵殑鎵�鏈夋妧鑳藉彇鏈�楂樼骇鐨勬妧鑳�
+    Dictionary<int, int> allSkillTypeIDToID = new Dictionary<int, int>();  //鎶�鑳界被鍨婭D锛�  鏈�楂樻妧鑳絀D
+
+
+    public HeroInfo(ItemModel _itemHero)
+    {
         UpdateHero(_itemHero);
-        
-
-        
     }
 
-    #if UNITY_EDITOR
-    public HeroInfo()
-    {
-        heroLevel = 1;
-        heroStar = 1;
-        breakLevel = 1;
-        awakeLevel = 1;
-        SkinIndex = 0;
-        heroConfig = HeroConfig.Get(heroId);
-        awakeConfig = HeroAwakeConfig.GetHeroAwakeConfig(heroId, awakeLevel);
-        breakConfig = HeroBreakConfig.GetHeroBreakConfig(heroId, breakLevel);
-        qualityAwakeConfig = HeroQualityAwakeConfig.GetQualityAwakeConfig(Quality, awakeLevel);
-        qualityConfig = HeroQualityConfig.Get(Quality);
-        qualityBreakConfig = HeroQualityBreakConfig.GetQualityBreakConfig(Quality, awakeLevel);
-        CalculateProperties();
-    }
-    #endif
 
-    // public HeroInfo Clone() => JsonMapper.ToObject<HeroInfo>(JsonMapper.ToJson(this));
 
-    //  鍥鹃壌淇℃伅
-    public void UpdateSCHero(CB122_tagSCHeroInfo.tagSCHero _scHeroInfo)
-    {
-
-    }
 
     public void UpdateHero(ItemModel _itemHero)
     {
         itemHero = _itemHero;
         // HeroConfigUtility
-
-        // 70 # 鑻遍泟绛夌骇
-        heroLevel = itemHero.GetUseData(70)[0];
-        // 72 # 鑻遍泟鏄熺骇
-        heroStar = itemHero.GetUseData(72)[0];
-        // 74 # 鑻遍泟绐佺牬绛夌骇
-        breakLevel = itemHero.GetUseData(74)[0];
-        // 76 # 鑻遍泟瑙夐啋绛夌骇
-        awakeLevel = itemHero.GetUseData(76)[0];
-        // 78 # 鑻遍泟浣跨敤鐨勭毊鑲ょ储寮�
-        SkinIndex = itemHero.GetUseData(78)[0];
-
-
-        // 71 # 鑻遍泟澶╄祴ID鍒楄〃
-        List<int> talentSkillList = itemHero.GetUseData(71);
-        // 73 # 鑻遍泟澶╄祴ID绛夌骇鍒楄〃锛屽搴�71澶╄祴ID鐨勭瓑绾�
-        List<int> talentLvList = itemHero.GetUseData(73);
-        // 75 # 鑻遍泟澶╄祴娲楃偧閿佸畾绱㈠紩鍒楄〃锛屽搴�71澶╄祴ID绱㈠紩
-        List<int> talentLockList = itemHero.GetUseData(75);
+        heroId = itemHero.config.ID;
 
         InitConfigs();
 
-        if (talentLockList.Count != talentLvList.Count || talentLvList.Count != talentSkillList.Count)
-        {
-            Debug.LogError("澶╄祴ID鍒楄〃鍙婂悗缁殑鏁版嵁鏁伴噺娌″涓�");
-        }
+        CalculateProperties();
+        // //  缇佺粖
+        // fetterInfoList.Clear();
+        // for (int i = 0; i < heroConfig.FetterIDList.Length; i++)
+        // {
+        //     fetterInfoList.Add(new HeroFetterInfo(this, heroConfig.FetterIDList[i]));
+        // }
 
-        //  澶╄祴
-        talentList.Clear();
-        for (int i = 0; i < talentSkillList.Count; i++)
-        {
-            talentList.Add(new HeroTalentInfo(this, talentSkillList[i], talentLvList[i], talentLockList[i]));
-        }
-
-        //  缇佺粖
-        fetterInfoList.Clear();
-        for (int i = 0; i < heroConfig.FetterIDList.Length; i++)
-        {
-            fetterInfoList.Add(new HeroFetterInfo(this, heroConfig.FetterIDList[i]));
-        }
-
-// 77 # 鑻遍泟澶╄祴娲楃偧闅忔満ID鍒楄〃
-// 79 # 鑻遍泟瑙夐啋鏃堕殢鏈哄ぉ璧嬮�夐」ID鍒楄〃
-// 80 # 涓婚樀鍨嬩笂闃典綅缃�
+        // 80 # 涓婚樀鍨嬩笂闃典綅缃�
     }
 
     protected void InitConfigs()
     {
         //  姝﹀皢閰嶇疆
         heroConfig = HeroConfig.Get(heroId);
-
-        //  瑙夐啋閰嶇疆 (婊$骇涓虹┖)
-        awakeConfig = HeroAwakeConfig.GetHeroAwakeConfig(heroId, awakeLevel);
-
-        //  绐佺牬閰嶇疆
-        breakConfig = HeroBreakConfig.GetHeroBreakConfig(heroId, breakLevel);
-
-        //  缇佺粖閰嶇疆 鍙兘闇�瑕乫etterid 鍘绘绱㈡晥鐜囧お浣�
-        // fetterConfig;
-
-        //  鍝佽川瑙夐啋閰嶇疆
-        qualityAwakeConfig = HeroQualityAwakeConfig.GetQualityAwakeConfig(Quality, awakeLevel);
-
         //  鍝佽川閰嶇疆
         qualityConfig = HeroQualityConfig.Get(Quality);
 
         //  鍝佽川绐佺牬閰嶇疆
-        qualityBreakConfig = HeroQualityBreakConfig.GetQualityBreakConfig(Quality, awakeLevel);
+        qualityBreakConfig = HeroQualityBreakConfig.GetQualityBreakConfig(Quality, breakLevel);
+
+        breakConfig = HeroBreakConfig.GetHeroBreakConfig(heroId, breakLevel);
+        awakeConfig = HeroAwakeConfig.GetHeroAwakeConfig(heroId, awakeLevel);
+        qualityAwakeConfig = HeroQualityAwakeConfig.GetQualityAwakeConfig(Quality, awakeLevel);
 
     }
 
-    public int GetInheritRate(HeroAttrType attrType)
+
+
+    //鏄惁涓妜闃� 鏈嶅姟绔槦浼�
+    public bool IsInTeamByTeamType(TeamType teamType)
     {
-        return heroConfig.GetInheritPercent(attrType);
+        return TeamManager.Instance.GetTeam(teamType).HasHeroInServer(itemHero.guid);
     }
+
+    //鏄惁涓婁换浣曢樀瀹�
+    public bool IsInAnyTeam()
+    {
+        for (int i = 1; i < (int)TeamType.Max; i++)
+        {
+            if (TeamManager.Instance.GetTeam((TeamType)i).HasHeroInServer(itemHero.guid))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    //鏄惁涓婁换浣曢樀瀹癸紝涓斿彧鏈変竴鍙�
+    public bool IsInAnyTeamJustOne()
+    {
+        for (int i = 1; i < (int)TeamType.Max; i++)
+        {
+            var team = TeamManager.Instance.GetTeam((TeamType)i);
+            if (team.HasHeroInServer(itemHero.guid))
+            {
+                if (team.GetTeamHeroCount() == 1)
+                    return true;
+            }
+        }
+        return false;
+    }
+
+    //涓嬮樀鎵�鏈夐樀瀹�
+    public void LeaveAllTeam()
+    {
+        for (int i = 1; i < (int)TeamType.Max; i++)
+        {
+            int pos;
+            var team = TeamManager.Instance.GetTeam((TeamType)i);
+            if (TeamManager.Instance.GetTeam((TeamType)i).RemoveHero(this, out pos))
+            {
+                //濡傛灉鏄渶鍚庝竴涓灏嗭紝鍒欓粯璁や笂闃典竴涓�
+                team.SaveTeam();
+            }
+        }
+    }
+
+    public long GetSkillsFightPower()
+    {
+        long fightPower = 0;
+        foreach (var skillID in allSkillTypeIDToID.Values)
+        {
+            fightPower += SkillConfig.Get(skillID).FightPower;
+        }
+        return fightPower;
+    }
+    
+
+    public void ChangeLockState()
+    {
+        var pack = new CB238_tagCSHeroLock();
+        pack.ItemIndex = (ushort)itemHero.gridIndex;
+        pack.IsLock = isLock ? (byte)0 : (byte)1;
+        GameNetSystem.Instance.SendInfo(pack);
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0