From c2d2d5d3a840bf50968b3f95e304929bc62a7b70 Mon Sep 17 00:00:00 2001
From: leonard Wu <364452445@qq.com>
Date: 星期五, 03 八月 2018 21:02:26 +0800
Subject: [PATCH] 更新代码

---
 System/Rune/RuneModel.cs |   53 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/System/Rune/RuneModel.cs b/System/Rune/RuneModel.cs
index a30aa76..bd0ed78 100644
--- a/System/Rune/RuneModel.cs
+++ b/System/Rune/RuneModel.cs
@@ -4,6 +4,7 @@
 using TableConfig;
 using System;
 using System.Text;
+using System.Linq;
 
 namespace Snxxz.UI
 {
@@ -54,6 +55,7 @@
         public Dictionary<int, float> runeAttrAdditionDic = new Dictionary<int, float>();
         public Dictionary<int, float> runeExpDic = new Dictionary<int, float>();
         public Dictionary<int, float> runeEliteAdditonDic = new Dictionary<int, float>();
+        Dictionary<int, int> runeQualityMaxLevel;
         public int[] runeUnlockArray { get; private set; }
         public float runeExpAddition { get; private set; }
         public string runeExpFormula { get; private set; }
@@ -83,7 +85,12 @@
                     cfg = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RunePackageNum");
                     runePackMaxNum = int.Parse(cfg.Numerical1);
 
-                    for (int i = 1; i < RuneMaxLevel; i++)
+                    var config = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RuneMaxLV");
+                    runeQualityMaxLevel = ConfigParse.GetDic<int, int>(config.Numerical1);
+
+                    var maxlevel = runeQualityMaxLevel != null ? runeQualityMaxLevel.Values.Last() : 0;
+
+                    for (int i = 1; i < maxlevel; i++)
                     {
                         Equation.Instance.Clear();
                         Equation.Instance.AddKeyValue(replaceValStr, i + 1);
@@ -106,6 +113,26 @@
 
         private static StringBuilder _textBuilder = new StringBuilder();
         static readonly string replaceValStr = "level";
+
+        public int GetRuneMaxLevel(int _itemColor)
+        {
+            if (runeQualityMaxLevel != null && runeQualityMaxLevel.ContainsKey(_itemColor))
+            {
+                return runeQualityMaxLevel[_itemColor];
+            }
+            if (runeQualityMaxLevel != null)
+            {
+                return runeQualityMaxLevel.Values.Last();
+            }
+            return 0;
+        }
+
+        public int GetRuneMaxLevelByItem(int _itemId)
+        {
+            var config = ConfigManager.Instance.GetTemplate<ItemConfig>(_itemId);
+            return config == null ? 0 : GetRuneMaxLevel(config.ItemColor);
+        }
+
         public string GetRuneAttrStr(int id, int level)
         {
             _textBuilder.Length = 0;
@@ -172,7 +199,8 @@
         public int GetRuneNeedExp(int id, int level)
         {
             float _levelUpExp = 0;
-            if (level < RuneMaxLevel)
+            ItemConfig _tagChinModel = ConfigManager.Instance.GetTemplate<ItemConfig>(id);
+            if (level < GetRuneMaxLevel(_tagChinModel.ItemColor))
             {
                 float _result = 0;
                 if (runeExpResultDict.ContainsKey(level + 1))
@@ -187,7 +215,6 @@
                     runeExpResultDict.Add(level + 1, _result);
                 }
                 RuneConfig cfg = ConfigManager.Instance.GetTemplate<RuneConfig>(id);
-                ItemConfig _tagChinModel = ConfigManager.Instance.GetTemplate<ItemConfig>(id);
                 if (cfg.AttrType.Length > 1)
                 {
                     _levelUpExp = _result * runeExpDic[_tagChinModel.ItemColor] * runeExpAddition;
@@ -242,7 +269,8 @@
         public int GetRuneLevelByExp(int id, float _exp)
         {
             float _totalExp = 0;
-            for (int i = 1; i < RuneMaxLevel; i++)
+            var maxlevel = runeQualityMaxLevel != null ? runeQualityMaxLevel.Values.Last() : 0;
+            for (int i = 1; i < maxlevel; i++)
             {
                 _totalExp += GetRuneNeedExp(id, i);
                 if (_totalExp > _exp)
@@ -250,7 +278,7 @@
                     return i;
                 }
             }
-            return RuneMaxLevel;
+            return maxlevel;
         }
         #endregion
         public const int RUNE_REDPOINT_INTERVAL = 100;
@@ -353,7 +381,7 @@
             {
                 var _data = GetHoleRune(i);
                 if (_data != null && RuneSplinters >= GetRuneNeedExp(_data.id, _data.lv)
-                       && _data.lv < RuneMaxLevel)
+                       && _data.lv < GetRuneMaxLevelByItem(_data.id))
                 {
                     runelevelUpSorts.Add(i);
                 }
@@ -408,7 +436,7 @@
             if (runeData != null)
             {
                 if (RuneSplinters > GetRuneNeedExp(runeData.id, runeData.lv)
-                    && runeData.lv < RuneMaxLevel)
+                    && runeData.lv < GetRuneMaxLevelByItem(runeData.id))
                 {
                     return true;
                 }
@@ -946,16 +974,7 @@
             }
             return Cnt;
         }
-        private int rune_max_level = 0;
-        public int RuneMaxLevel {
-            get {
-                if (rune_max_level == 0)
-                {
-                    rune_max_level = int.Parse(ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RuneMaxLV").Numerical1);
-                }
-                return rune_max_level;
-            }
-        }
+
         public void ClearRuneData()
         {
             runePackData.Clear();

--
Gitblit v1.8.0