ソースを参照

Merge branch 'master' of http://192.168.123.2:3000/ck/XiuXianGame

lzx 3 日 前
コミット
1a2672be58
1 ファイル変更100 行追加72 行削除
  1. 100 72
      Assets/Scripts/GameLogic/Hero/HeroInfo.cs

+ 100 - 72
Assets/Scripts/GameLogic/Hero/HeroInfo.cs

@@ -30,6 +30,7 @@ namespace GameLogic.Hero
 
         // public List<int> ImmortalBond = new List<int>();
 
+        private Map<HeroAttributeType, float> attributeValue = new Map<HeroAttributeType, float>();
 
         public HeroInfo()
         {
@@ -150,6 +151,7 @@ namespace GameLogic.Hero
 
         public void ComputeHeroInfo()
         {
+            attributeValue.Clear();
             attributeBlValue.Clear();
             Metal = 100;
             Wood = 100;
@@ -205,43 +207,48 @@ namespace GameLogic.Hero
                 daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
                 ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
             }
+
             //心境带来的加成
             AddSentimentData();
-           
+
             if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
             {
                 CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
                 CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
             }
+
+            AddAttributeValue();
         }
 
         private void AddSentimentData()
         {
-            SentimentEffectConfig[] allSentimentEffectConfigs =   ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
-            List<AccountFileInfo.SentimentData> SentimentDatas =  AccountFileInfo.Instance.playerData.SentimentDatas;
+            SentimentEffectConfig[] allSentimentEffectConfigs =
+                ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
+            List<AccountFileInfo.SentimentData> SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas;
             for (int i = 0; i < SentimentDatas.Count; i++)
             {
-                AccountFileInfo.SentimentData sentimentData=   SentimentDatas[i];
+                AccountFileInfo.SentimentData sentimentData = SentimentDatas[i];
                 for (int j = 0; j < sentimentData.sentimentProperties.Count; j++)
                 {
-                    AddSentimentProperty( sentimentData.sentimentProperties[i],allSentimentEffectConfigs);
+                    AddSentimentProperty(sentimentData.sentimentProperties[i], allSentimentEffectConfigs);
                 }
-              
             }
         }
 
-        private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,SentimentEffectConfig[] allSentimentEffectConfigs)
+        private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,
+            SentimentEffectConfig[] allSentimentEffectConfigs)
         {
             SentimentEffectConfig currSentimentEffectConfig = default;
             for (int i = 0; i < allSentimentEffectConfigs.Length; i++)
             {
-                SentimentEffectConfig sentimentEffectConfig=   allSentimentEffectConfigs[i];
-                if(sentimentEffectConfig.groupId==sentimentProperty.groupId&& sentimentEffectConfig.level==sentimentProperty.level)
+                SentimentEffectConfig sentimentEffectConfig = allSentimentEffectConfigs[i];
+                if (sentimentEffectConfig.groupId == sentimentProperty.groupId &&
+                    sentimentEffectConfig.level == sentimentProperty.level)
                 {
-                    currSentimentEffectConfig= sentimentEffectConfig;
+                    currSentimentEffectConfig = sentimentEffectConfig;
                 }
             }
-           
+
             switch (currSentimentEffectConfig.effectType)
             {
                 case 1:
@@ -276,92 +283,113 @@ namespace GameLogic.Hero
                             Earth += currSentimentEffectConfig.effectVale[1];
                             break;
                     }
+
                     break;
-                case 6: 
-                    finallyHarmReduce= currSentimentEffectConfig.effectVale[0];
+                case 6:
+                    finallyHarmReduce = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 7:
-                    abnormalHarmAdd= currSentimentEffectConfig.effectVale[0];
+                    abnormalHarmAdd = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 8:
-                    Fire_Proficient= currSentimentEffectConfig.effectVale[0];
+                    Fire_Proficient = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 9:
-                    Wood_Proficient= currSentimentEffectConfig.effectVale[0];
+                    Wood_Proficient = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 10:
-                    Metal_Proficient= currSentimentEffectConfig.effectVale[0];
+                    Metal_Proficient = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 11:
-                    Water_Proficient= currSentimentEffectConfig.effectVale[0];
+                    Water_Proficient = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 12:
-                    Earth_Proficient= currSentimentEffectConfig.effectVale[0];
+                    Earth_Proficient = currSentimentEffectConfig.effectVale[0];
                     break;
                 case 99:
                     // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0];
                     break;
-                
             }
         }
 
-        private void ComputeHeroAttributeType(int shuxingID, float value)
+        private void AddAttributeValue()
         {
-            switch ((HeroAttributeType)shuxingID)
+            for (attributeValue.Begin(); attributeValue.Next();)
             {
-                case HeroAttributeType.HP:
-                    hp.Value += (int)value;
-                    break;
-                case HeroAttributeType.ATT:
-                    attack.Value += (int)value;
-                    break;
-                case HeroAttributeType.DEF:
-                    defense.Value += (int)value;
-                    break;
-                case HeroAttributeType.HP_BL:
-                    hp.Value += (long)(hp.Value * (value / 100f));
-                    break;
-                case HeroAttributeType.ATT_BL:
-                    attack.Value += (long)(attack.Value * (value / 100f));
-                    break;
-                case HeroAttributeType.DEF_BL:
-                    defense.Value += (long)(defense.Value * (value / 100f));
-                    break;
-                case HeroAttributeType.ShengShi_BL:
-                    shenshi.Value += (long)(shenshi.Value * (value / 100f));
-                    break;
-                case HeroAttributeType.Gold:
-                    Metal += value;
-                    break;
-                case HeroAttributeType.Wood:
-                    Wood += value;
-                    break;
-                case HeroAttributeType.Fire:
-                    Fire += value;
-                    break;
-                case HeroAttributeType.Water:
-                    Water += value;
-                    break;
-                case HeroAttributeType.Earth:
-                    Earth += value;
-                    break;
-                case HeroAttributeType.Shields:
-                    Shield.Value += (int)value;
-                    break;
-                default:
-                    if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
-                       )
-                    {
-                        attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
-                    }
-                    else
-                    {
-                        attributeBlValue.Add((HeroAttributeType)shuxingID, value);
-                    }
+                HeroAttributeType heroAttributeType = attributeValue.Key;
+                float value = attributeValue.Value;
+                switch (heroAttributeType)
+                {
+                    case HeroAttributeType.HP:
+                        hp.Value += (int)value;
+                        break;
+                    case HeroAttributeType.ATT:
+                        attack.Value += (int)value;
+                        break;
+                    case HeroAttributeType.DEF:
+                        defense.Value += (int)value;
+                        break;
+                    case HeroAttributeType.HP_BL:
+                        hp.Value += (long)(hp.Value * (value / 100f));
+                        break;
+                    case HeroAttributeType.ATT_BL:
+                        attack.Value += (long)(attack.Value * (value / 100f));
+                        break;
+                    case HeroAttributeType.DEF_BL:
+                        defense.Value += (long)(defense.Value * (value / 100f));
+                        break;
+                    case HeroAttributeType.ShengShi_BL:
+                        shenshi.Value += (long)(shenshi.Value * (value / 100f));
+                        break;
+                    case HeroAttributeType.Gold:
+                        Metal += value;
+                        break;
+                    case HeroAttributeType.Wood:
+                        Wood += value;
+                        break;
+                    case HeroAttributeType.Fire:
+                        Fire += value;
+                        break;
+                    case HeroAttributeType.Water:
+                        Water += value;
+                        break;
+                    case HeroAttributeType.Earth:
+                        Earth += value;
+                        break;
+                    case HeroAttributeType.Shields:
+                        Shield.Value += (int)value;
+                        break;
+                    // default:
+                    //     if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
+                    //        )
+                    //     {
+                    //         attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
+                    //     }
+                    //     else
+                    //     {
+                    //         attributeBlValue.Add((HeroAttributeType)shuxingID, value);
+                    //     }
+                    //
 
+                    // break;
+                }
+            }
+            attributeValue.Clear();
+        }
 
-                    break;
+        private void ComputeHeroAttributeType(int shuxingID, float value)
+        {
+            HeroAttributeType heroAttributeType = (HeroAttributeType)shuxingID;
+            if (attributeValue.TryGetValue(heroAttributeType, out float oldValue))
+            {
+                attributeValue[heroAttributeType] = oldValue + value;
             }
+            else
+            {
+                attributeValue.Add(heroAttributeType, value);
+            }
+
+            // attributeValue.Add((HeroAttributeType)shuxingID,);
         }
     }
 }