| using System;  | 
| using System.Collections;  | 
| using System.Collections.Generic;  | 
| using UnityEngine;  | 
| namespace vnxbqy.UI  | 
| {  | 
|       | 
|       | 
|     public class TreasureSkillModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk  | 
|     {  | 
|         Dictionary<int, TreasureSkill> treasureSkills = new Dictionary<int, TreasureSkill>();  | 
|         Dictionary<int, List<int>> jobTreasureSkills = new Dictionary<int, List<int>>();  | 
|         Dictionary<int, int> m_ExpertSkills = new Dictionary<int, int>();  | 
|         Dictionary<int, int> m_ExpertActiveLevels = new Dictionary<int, int>();  | 
|   | 
|         public List<int> skillLevelUpItems = new List<int>();  | 
|         public long CloseExpertSkillSelectWinTime; //  = DateTime.Now.Ticks;   | 
|   | 
|         int m_SelectSkill;  | 
|         public int selectSkill  | 
|         {  | 
|             get { return m_SelectSkill; }  | 
|             set  | 
|             {  | 
|                 if (m_SelectSkill != value)  | 
|                 {  | 
|                     m_SelectSkill = value;  | 
|                     if (selectRefresh != null)  | 
|                     {  | 
|                         selectRefresh();  | 
|                     }  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         int m_SelectExpertSkill;  | 
|         public int selecttExpertSkill  | 
|         {  | 
|             get { return m_SelectExpertSkill; }  | 
|             set  | 
|             {  | 
|                 if (m_SelectExpertSkill != value)  | 
|                 {  | 
|                     m_SelectExpertSkill = value;  | 
|                     if (selectExpertSkillRefresh != null)  | 
|                     {  | 
|                         selectExpertSkillRefresh();  | 
|                     }  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         public bool serverInited { get; private set; }  | 
|   | 
|         public bool requireRemind { get; private set; }  | 
|   | 
|         public bool newSatisfyActiveExpertDirty { get; set; }  | 
|   | 
|         public bool selectActivePriority { get; set; }  | 
|   | 
|         public readonly Redpoint redpoint = new Redpoint(103, 10304);  | 
|         public const int REDPOINTID_BASE = 10304000;  | 
|         public static int redpointIndex = 100;  | 
|   | 
|         PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }  | 
|         ReikiRootModel reikiRootModel { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }  | 
|   | 
|         public event Action selectRefresh;  | 
|         public event Action selectExpertSkillRefresh;  | 
|         public event Action<int> treasureSkillRefresh;  | 
|         public event Action<int> skillLevelUpRefresh;  | 
|         public event Action<int, int> potentialLevelRefresh;  | 
|         public event Action expertSkillRefresh;  | 
|         public event Action<int> expertActiveRefresh;  | 
|         public override void Init()  | 
|         {  | 
|             ParseConfig();  | 
|   | 
|             packModel.refreshItemCountEvent += RefreshItemCountAct;  | 
|             FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;  | 
|             PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;  | 
|         }  | 
|   | 
|         public void OnBeforePlayerDataInitialize()  | 
|         {  | 
|             foreach (var skill in treasureSkills.Values)  | 
|             {  | 
|                 skill.Reset();  | 
|             }  | 
|             m_ExpertSkills.Clear();  | 
|             m_ExpertActiveLevels.Clear();  | 
|             serverInited = false;  | 
|         }  | 
|   | 
|         public void OnPlayerLoginOk()  | 
|         {  | 
|             serverInited = true;  | 
|             requireRemind = true;  | 
|             UpdateRedpoint();  | 
|         }  | 
|   | 
|         public override void UnInit()  | 
|         {  | 
|             packModel.refreshItemCountEvent -= RefreshItemCountAct;  | 
|             FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;  | 
|             PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;  | 
|         }  | 
|   | 
|         private void PlayerDataRefreshEvent(PlayerDataType dataType)  | 
|         {  | 
|             if (!serverInited)  | 
|             {  | 
|                 return;  | 
|             }  | 
|             if (dataType == PlayerDataType.CDBPlayerRefresh_Mater  | 
|                 || dataType == PlayerDataType.CDBPlayerRefresh_Wood  | 
|                 || dataType == PlayerDataType.CDBPlayerRefresh_Water  | 
|                 || dataType == PlayerDataType.CDBPlayerRefresh_Fire  | 
|                 || dataType == PlayerDataType.CDBPlayerRefresh_Earth)  | 
|             {  | 
|                 UpdateRedpoint();  | 
|   | 
|                 var requireVerifyNewActive = true;  | 
|                 if (dataType == PlayerDataType.CDBPlayerRefresh_Mater  | 
|                     && reikiRootModel.GetReikiRootFreePoint((int)PropertyType.Mater) == 0)  | 
|                 {  | 
|                     requireVerifyNewActive = false;  | 
|                 }  | 
|                 if (dataType == PlayerDataType.CDBPlayerRefresh_Wood  | 
|                     && reikiRootModel.GetReikiRootFreePoint((int)PropertyType.Wood) == 0)  | 
|                 {  | 
|                     requireVerifyNewActive = false;  | 
|                 }  | 
|                 if (dataType == PlayerDataType.CDBPlayerRefresh_Water  | 
|                    && reikiRootModel.GetReikiRootFreePoint((int)PropertyType.Water) == 0)  | 
|                 {  | 
|                     requireVerifyNewActive = false;  | 
|                 }  | 
|                 if (dataType == PlayerDataType.CDBPlayerRefresh_Fire  | 
|                    && reikiRootModel.GetReikiRootFreePoint((int)PropertyType.Fire) == 0)  | 
|                 {  | 
|                     requireVerifyNewActive = false;  | 
|                 }  | 
|                 if (dataType == PlayerDataType.CDBPlayerRefresh_Earth  | 
|                    && reikiRootModel.GetReikiRootFreePoint((int)PropertyType.Earth) == 0)  | 
|                 {  | 
|                     requireVerifyNewActive = false;  | 
|                 }  | 
|   | 
|                 if (requireVerifyNewActive)  | 
|                 {  | 
|                     foreach (var skill in treasureSkills.Values)  | 
|                     {  | 
|                         if (skill.expertRedpoint.state == RedPointState.Simple)  | 
|                         {  | 
|                             if (WindowCenter.Instance.IsOpen<ReikiRootWin>()  | 
|                                 && !WindowCenter.Instance.IsOpen<ReikiGotoSkillLevelUpWin>())  | 
|                             {  | 
|                                 newSatisfyActiveExpertDirty = true;  | 
|                             }  | 
|                             break;  | 
|                         }  | 
|                     }  | 
|                 }  | 
|             }  | 
|             else if (dataType == PlayerDataType.LV)  | 
|             {  | 
|                 UpdateRedpoint();  | 
|             }  | 
|         }  | 
|   | 
|         private void OnFuncStateChangeEvent(int id)  | 
|         {  | 
|             if (id == 82 || id == 177)  | 
|             {  | 
|                 UpdateRedpoint();  | 
|             }  | 
|         }  | 
|   | 
|         private void RefreshItemCountAct(PackType packType, int arg2, int itemId)  | 
|         {  | 
|             if (packType == PackType.Item && skillLevelUpItems.Contains(itemId))  | 
|             {  | 
|                 if (serverInited)  | 
|                 {  | 
|                     requireRemind = true;  | 
|                 }  | 
|                 UpdateRedpoint();  | 
|             }  | 
|         }  | 
|   | 
|         void ParseConfig()  | 
|         {  | 
|             var configs = TreasureSkillConfig.GetValues();  | 
|             foreach (var config in configs)  | 
|             {  | 
|                 TreasureSkill treasureSkill;  | 
|                 if (!treasureSkills.TryGetValue(config.limitSkillId, out treasureSkill))  | 
|                 {  | 
|                     treasureSkill = new TreasureSkill(config.limitSkillId);  | 
|                     treasureSkills.Add(config.limitSkillId, treasureSkill);  | 
|                 }  | 
|                 treasureSkill.potentials.Add(new TreasurePotential(config.id, 0, config.limitLevel, treasureSkill.expertRedpoint.id));  | 
|                 var skillConfig = SkillConfig.Get(config.limitSkillId);  | 
|   | 
|                 List<int> skills;  | 
|                 if (!jobTreasureSkills.TryGetValue(skillConfig.UseType, out skills))  | 
|                 {  | 
|                     skills = new List<int>();  | 
|                     jobTreasureSkills.Add(skillConfig.UseType, skills);  | 
|                 }  | 
|                 if (!skills.Contains(config.limitSkillId))  | 
|                 {  | 
|                     skills.Add(config.limitSkillId);  | 
|                 }  | 
|             }  | 
|   | 
|             foreach (var skill in treasureSkills.Values)  | 
|             {  | 
|                 for (int i = 1; i <= skill.maxLevel; i++)  | 
|                 {  | 
|                     var config = skill.GetSkillConfig(i);  | 
|                     if (!skillLevelUpItems.Contains(config.ExAttr4))  | 
|                     {  | 
|                         skillLevelUpItems.Add(config.ExAttr4);  | 
|                     }  | 
|                 }  | 
|   | 
|                 foreach (var potential in skill.potentials)  | 
|                 {  | 
|                     for (int i = 1; i <= potential.maxLevel; i++)  | 
|                     {  | 
|                         var config = potential.GetSkillConfig(i);  | 
|                         if (!skillLevelUpItems.Contains(config.ExAttr4))  | 
|                         {  | 
|                             skillLevelUpItems.Add(config.ExAttr4);  | 
|                         }  | 
|                     }  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         public bool TryGetSkills(out List<int> skills)  | 
|         {  | 
|             var job = PlayerDatas.Instance.baseData.Job;  | 
|             var useType = (int)Mathf.Pow(2, job);  | 
|             return jobTreasureSkills.TryGetValue(useType, out skills);  | 
|         }  | 
|   | 
|         public bool TryGetSkill(int skillId, out TreasureSkill treasureSkill)  | 
|         {  | 
|             return treasureSkills.TryGetValue(skillId, out treasureSkill);  | 
|         }  | 
|   | 
|         public bool TryGetExpertSkill(int skillId, out int _skill)  | 
|         {  | 
|             return m_ExpertSkills.TryGetValue(skillId, out _skill) && _skill != 0;  | 
|         }  | 
|   | 
|         public bool TryGetPotential(int skillId, out TreasurePotential potential)  | 
|         {  | 
|             var treasureSkillId = 0;  | 
|             potential = null;  | 
|             if (ContainsSkill(skillId, out treasureSkillId))  | 
|             {  | 
|                 var treasureSkill = treasureSkills[treasureSkillId];  | 
|                 potential = treasureSkill.potentials.Find((x) =>  | 
|                 {  | 
|                     return x.id == skillId;  | 
|                 });  | 
|                 return potential != null;  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public bool TryGetExpertActiveLevel(int skillId, out int level)  | 
|         {  | 
|             return m_ExpertActiveLevels.TryGetValue(skillId, out level);  | 
|         }  | 
|   | 
|         public int GetTotalExpertSkillLevel()  | 
|         {  | 
|             var level = 0;  | 
|             foreach (var _level in m_ExpertActiveLevels.Values)  | 
|             {  | 
|                 level += _level;  | 
|             }  | 
|             return level;  | 
|         }  | 
|   | 
|         public int GetSatisfyLevelUpMinCostSkillId()  | 
|         {  | 
|             var minCost = int.MaxValue;  | 
|             var minSkillId = 0;  | 
|             foreach (var skill in treasureSkills.Values)  | 
|             {  | 
|                 var error = 0;  | 
|                 if (TryLevelUpTreasureSkill(skill.skillId, out error)  | 
|                     && skill.level > 0)  | 
|                 {  | 
|                     var config = skill.GetSkillConfig(skill.level + 1);  | 
|                     if (config.ExAttr5 < minCost)  | 
|                     {  | 
|                         minCost = config.ExAttr5;  | 
|                         minSkillId = skill.skillId;  | 
|                     }  | 
|                 }  | 
|             }  | 
|             return minSkillId;  | 
|         }  | 
|   | 
|         public int GetExpertSkillCountUseReikiRoot(int id)  | 
|         {  | 
|             var count = 0;  | 
|             foreach (var skillId in m_ExpertSkills.Values)  | 
|             {  | 
|                 var config = SkillConfig.Get(skillId);  | 
|                 if (config != null && config.RequireProperty() == id)  | 
|                 {  | 
|                     count++;  | 
|                 }  | 
|             }  | 
|             return count;  | 
|         }  | 
|   | 
|         public void OnReceivePackage(int oldSkillID, int newSkillID)  | 
|         {  | 
|             var config = SkillConfig.Get(newSkillID);  | 
|             var skillTypeId = config.SkillTypeID;  | 
|             var treasureSkillId = 0;  | 
|             if (ContainsSkill(skillTypeId, out treasureSkillId))  | 
|             {  | 
|                 var treasureSkill = treasureSkills[treasureSkillId];  | 
|   | 
|                 var level = 0;  | 
|                 if (skillTypeId == treasureSkillId)  | 
|                 {  | 
|                     level = treasureSkill.level;  | 
|                 }  | 
|                 else  | 
|                 {  | 
|                     TreasurePotential potential;  | 
|                     if (TryGetPotential(skillTypeId, out potential))  | 
|                     {  | 
|                         level = potential.level;  | 
|                     }  | 
|                 }  | 
|   | 
|                 treasureSkill.Refresh(newSkillID);  | 
|   | 
|                 bool levelUp = false;  | 
|                 if (skillTypeId == treasureSkillId)  | 
|                 {  | 
|                     levelUp = treasureSkill.level > level;  | 
|                 }  | 
|                 else  | 
|                 {  | 
|                     TreasurePotential potential;  | 
|                     if (TryGetPotential(skillTypeId, out potential))  | 
|                     {  | 
|                         levelUp = potential.level > level;  | 
|                     }  | 
|   | 
|                     if (potential != null && potentialLevelRefresh != null)  | 
|                     {  | 
|                         potentialLevelRefresh(skillTypeId, potential.level);  | 
|                     }  | 
|                 }  | 
|   | 
|                 if (levelUp && serverInited)  | 
|                 {  | 
|                     if (skillLevelUpRefresh != null)  | 
|                     {  | 
|                         skillLevelUpRefresh(skillTypeId);  | 
|                     }  | 
|                 }  | 
|   | 
|                 if (treasureSkillRefresh != null)  | 
|                 {  | 
|                     treasureSkillRefresh(skillTypeId);  | 
|                 }  | 
|   | 
|                 UpdateRedpoint();  | 
|             }  | 
|         }  | 
|   | 
|         public void OnReceivePackage(HA309_tagMCSkillElementInfo package)  | 
|         {  | 
|             var resetReikiRemind = false;  | 
|   | 
|             for (int i = 0; i < package.Cnt; i++)  | 
|             {  | 
|                 var data = package.InfoList[i];  | 
|                 m_ExpertSkills[(int)data.MainSkillID] = (int)data.ElementSkillID;  | 
|   | 
|                 for (int j = 0; j < data.SkillCnt; j++)  | 
|                 {  | 
|                     var lastLevel = m_ExpertActiveLevels.ContainsKey((int)data.ActiveSkill[j].SkillID) ?  | 
|                         m_ExpertActiveLevels[(int)data.ActiveSkill[j].SkillID] : 0;  | 
|                     m_ExpertActiveLevels[(int)data.ActiveSkill[j].SkillID] = data.ActiveSkill[j].ActiveLV;  | 
|                     if (serverInited)  | 
|                     {  | 
|                         if (expertActiveRefresh != null)  | 
|                         {  | 
|                             expertActiveRefresh((int)data.ActiveSkill[j].SkillID);  | 
|                         }  | 
|   | 
|                         if (!resetReikiRemind)  | 
|                         {  | 
|                             if (data.ActiveSkill[j].ActiveLV < lastLevel && reikiRootModel.resetReikiRootRecord)  | 
|                             {  | 
|                                 resetReikiRemind = true;  | 
|                             }  | 
|                         }  | 
|   | 
|                         //if (GetTotalExpertSkillLevel() == 1 && data.ActiveSkill[j].ActiveLV == 1  | 
|                         //    && m_ExpertSkills[(int)data.MainSkillID] == 0)  | 
|                         //{  | 
|                         //    var pak = new CA516_tagCMSelectSkillElement();  | 
|                         //    pak.SkillTypeID = data.ActiveSkill[j].SkillID;  | 
|                         //    pak.DoType = 1;  | 
|                         //    GameNetSystem.Instance.SendInfo(pak);  | 
|                         //}  | 
|                     }  | 
|                 }  | 
|             }  | 
|             if (expertSkillRefresh != null)  | 
|             {  | 
|                 expertSkillRefresh();  | 
|             }  | 
|   | 
|             if (resetReikiRemind)  | 
|             {  | 
|                 reikiRootModel.resetReikiRemind = true;  | 
|             }  | 
|   | 
|             reikiRootModel.resetReikiRootRecord = false;  | 
|   | 
|             UpdateRedpoint();  | 
|         }  | 
|   | 
|         public void OnDeleteSkill(int skillID)  | 
|         {  | 
|             var skillConfig = SkillConfig.Get(skillID);  | 
|             if (skillConfig == null)  | 
|             {  | 
|                 return;  | 
|             }  | 
|             TreasurePotential treasurePotential;  | 
|             if (TryGetPotential(skillConfig.SkillTypeID, out treasurePotential))  | 
|             {  | 
|                 treasurePotential.Reset();  | 
|             }  | 
|             if (expertSkillRefresh != null)  | 
|             {  | 
|                 expertSkillRefresh();  | 
|             }  | 
|             UpdateRedpoint();  | 
|         }  | 
|   | 
|         public bool TryLevelUpTreasureSkill(int skillId, out int error)  | 
|         {  | 
|             error = 0;  | 
|             TreasureSkill skill;  | 
|             if (TryGetSkill(skillId, out skill))  | 
|             {  | 
|                 if (skill.level >= skill.maxLevel)  | 
|                 {  | 
|                     error = 1;  | 
|                     return false;  | 
|                 }  | 
|                 var upConfig = skill.GetSkillConfig(skill.level + 1);  | 
|                 var count = packModel.GetItemCountByID(PackType.Item, upConfig.ExAttr4);  | 
|                 if (count < upConfig.ExAttr5)  | 
|                 {  | 
|                     error = 2;  | 
|                     return false;  | 
|                 }  | 
|                   | 
|             }  | 
|             return true;  | 
|         }  | 
|   | 
|         public bool TryLevelUpTreasureSkillEx(int skillId, out int error)  | 
|         {  | 
|             error = 0;  | 
|             TreasureSkill skill;  | 
|             if (TryGetSkill(skillId, out skill))  | 
|             {  | 
|                 if (skill.level >= skill.maxLevel)  | 
|                 {  | 
|                     error = 1;  | 
|                     return false;  | 
|                 }  | 
|                 var upConfig = skill.GetSkillConfig(skill.level + 1);  | 
|                 var count = packModel.GetItemCountByID(PackType.Item, upConfig.ExAttr4);  | 
|                 LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(20, upConfig.ExAttr4, upConfig.ExAttr5, 1, 0);  | 
|                 if (count < upConfig.ExAttr5)  | 
|                 {  | 
|                     error = 2;  | 
|                     return false;  | 
|                 }  | 
|   | 
|             }  | 
|             return true;  | 
|         }  | 
|   | 
|         public bool IsSatisfyLevelUpSkill(int skillId, int proeprty, int level)  | 
|         {  | 
|             TreasureSkill treasureSkill;  | 
|             if (TryGetSkill(skillId, out treasureSkill) && treasureSkill.level > 0)  | 
|             {  | 
|                 foreach (var expertSkill in treasureSkill.potentials)  | 
|                 {  | 
|                     var skillConfig = expertSkill.GetSkillConfig(0);  | 
|                     if (skillConfig.RequireProperty() == proeprty)  | 
|                     {  | 
|                         if (PlayerDatas.Instance.baseData.LV < expertSkill.limitLevel)  | 
|                         {  | 
|                             return false;  | 
|                         }  | 
|                         var skillLevel = 0;  | 
|                         TryGetExpertActiveLevel(expertSkill.id, out skillLevel);  | 
|                         if (skillLevel >= level)  | 
|                         {  | 
|                             return false;  | 
|                         }  | 
|                         skillConfig = expertSkill.GetSkillConfig(level);  | 
|                         var requireValue = skillConfig.RequirePropertyValue();  | 
|                         if ((int)UIHelper.GetPropertyValue((PropertyType)proeprty) < requireValue)  | 
|                         {  | 
|                             return false;  | 
|                         }  | 
|                         return true;  | 
|                     }  | 
|                 }  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public void DisplayLevelUpError(int error)  | 
|         {  | 
|             switch (error)  | 
|             {  | 
|                 case 1:  | 
|                     break;  | 
|                 case 2:  | 
|                     SysNotifyMgr.Instance.ShowTip("TreasureSkillLevelUpError2");  | 
|                     break;  | 
|                 case 11:  | 
|                     break;  | 
|                 case 12:  | 
|                     break;  | 
|                 case 13:  | 
|                     break;  | 
|             }  | 
|         }  | 
|   | 
|         public bool ContainsSkill(int skillId, out int treasureSkillId)  | 
|         {  | 
|             treasureSkillId = 0;  | 
|             foreach (var skill in treasureSkills.Values)  | 
|             {  | 
|                 if (skill.skillId == skillId)  | 
|                 {  | 
|                     treasureSkillId = skill.skillId;  | 
|                     return true;  | 
|                 }  | 
|                 if (skill.potentials.FindIndex((x) =>  | 
|                  {  | 
|                      return x.id == skillId;  | 
|                  }) != -1)  | 
|                 {  | 
|                     treasureSkillId = skill.skillId;  | 
|                     return true;  | 
|                 }  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public bool ExistAnyActiveExpert(int skillId)  | 
|         {  | 
|             var expertSkill = 0;  | 
|             return ExistAnyActiveExpert(skillId, out expertSkill);  | 
|         }  | 
|   | 
|         public bool ExistAnyActiveExpert(int skillId, out int expertSkill)  | 
|         {  | 
|             TreasureSkill treasureSkill;  | 
|             expertSkill = 0;  | 
|             if (TryGetSkill(skillId, out treasureSkill))  | 
|             {  | 
|                 for (int i = 0; i < treasureSkill.potentials.Count; i++)  | 
|                 {  | 
|                     var level = 0;  | 
|                     if (TryGetExpertActiveLevel(treasureSkill.potentials[i].id, out level)  | 
|                         && level > 0)  | 
|                     {  | 
|                         expertSkill = treasureSkill.potentials[i].id;  | 
|                         return true;  | 
|                     }  | 
|                 }  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public bool SatisfyActiveExpert(int skillId, out int error)  | 
|         {  | 
|             error = 0;  | 
|             TreasurePotential expert;  | 
|             if (!TryGetPotential(skillId, out expert))  | 
|             {  | 
|                 return false;  | 
|             }  | 
|             if (PlayerDatas.Instance.baseData.LV < expert.limitLevel)  | 
|             {  | 
|                 error = 1;  | 
|                 return false;  | 
|             }  | 
|             var level = 0;  | 
|             TryGetExpertActiveLevel(skillId, out level);  | 
|             if (expert.maxLevel <= level)  | 
|             {  | 
|                 error = 2;  | 
|                 return false;  | 
|             }  | 
|             var skillConfig = SkillConfig.Get(skillId + level);  | 
|             var requireProperty = skillConfig.RequireProperty();  | 
|             var requireValue = skillConfig.RequirePropertyValue();  | 
|             if ((int)UIHelper.GetPropertyValue((PropertyType)requireProperty) < requireValue)  | 
|             {  | 
|                 error = 3;  | 
|                 return false;  | 
|             }  | 
|             return true;  | 
|         }  | 
|   | 
|         public void SetAlreadyRemind()  | 
|         {  | 
|             requireRemind = false;  | 
|             UpdateRedpoint();  | 
|         }  | 
|   | 
|         void UpdateRedpoint()  | 
|         {  | 
|             var funcOpen = FuncOpen.Instance.IsFuncOpen(82);  | 
|             var satisfyLevelUpMinSkillId = GetSatisfyLevelUpMinCostSkillId();  | 
|             foreach (var skill in treasureSkills.Values)  | 
|             {  | 
|                 if (requireRemind && funcOpen && FuncOpen.Instance.IsFuncOpen(177)  | 
|                     && satisfyLevelUpMinSkillId == skill.skillId)  | 
|                 {  | 
|                     skill.levelUpRedpoint.state = RedPointState.Simple;  | 
|                 }  | 
|                 else  | 
|                 {  | 
|                     skill.levelUpRedpoint.state = RedPointState.None;  | 
|                 }  | 
|   | 
|                 var expertSkill = 0;  | 
|                 if (funcOpen && !TryGetExpertSkill(skill.skillId, out expertSkill)  | 
|                     && ExistAnyActiveExpert(skill.skillId))  | 
|                 {  | 
|                     skill.expertSelectRedpoint.state = RedPointState.Simple;  | 
|                 }  | 
|                 else  | 
|                 {  | 
|                     skill.expertSelectRedpoint.state = RedPointState.None;  | 
|                 }  | 
|   | 
|                 var errorCode = 0;  | 
|                 foreach (var expert in skill.potentials)  | 
|                 {  | 
|                     if (funcOpen && skill.level > 0 && SatisfyActiveExpert(expert.id, out errorCode))  | 
|                     {  | 
|                         expert.activeRedpoint.state = RedPointState.Simple;  | 
|                     }  | 
|                     else  | 
|                     {  | 
|                         expert.activeRedpoint.state = RedPointState.None;  | 
|                     }  | 
|                 }  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|     public class TreasureSkill  | 
|     {  | 
|         public readonly int skillId;  | 
|         public readonly int maxLevel;  | 
|   | 
|         public int level { get; private set; }  | 
|         public Redpoint redpoint { get; private set; }  | 
|         public Redpoint levelUpRedpoint { get; private set; }  | 
|         public Redpoint expertRedpoint { get; private set; }  | 
|         public Redpoint expertSelectRedpoint { get; private set; }  | 
|         public List<TreasurePotential> potentials { get; private set; }  | 
|   | 
|         SkillModel skillModel { get { return ModelCenter.Instance.GetModel<SkillModel>(); } }  | 
|   | 
|         public TreasureSkill(int skillId)  | 
|         {  | 
|             this.skillId = skillId;  | 
|             potentials = new List<TreasurePotential>();  | 
|   | 
|             var config = SkillConfig.Get(skillId);  | 
|             maxLevel = config.SkillMaxLV;  | 
|   | 
|             redpoint = new Redpoint(10304,  | 
|                 TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);  | 
|             levelUpRedpoint = new Redpoint(skillModel.redpoint.id,  | 
|                 TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);  | 
|             expertRedpoint = new Redpoint(redpoint.id,  | 
|                 TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);  | 
|             expertSelectRedpoint = new Redpoint(expertRedpoint.id,  | 
|                 TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);  | 
|         }  | 
|   | 
|         public SkillConfig GetSkillConfig(int level)  | 
|         {  | 
|             if (level > 0)  | 
|             {  | 
|                 return SkillConfig.Get(skillId + level - 1);  | 
|             }  | 
|             else  | 
|             {  | 
|                 return SkillConfig.Get(skillId + level);  | 
|             }  | 
|         }  | 
|   | 
|         public void Refresh(int newSkillId)  | 
|         {  | 
|             var config = SkillConfig.Get(newSkillId);  | 
|             if (config.SkillTypeID == skillId)  | 
|             {  | 
|                 level = config.SkillLV;  | 
|             }  | 
|             else  | 
|             {  | 
|                 var index = potentials.FindIndex((x) =>  | 
|                 {  | 
|                     return x.id == config.SkillTypeID;  | 
|                 });  | 
|                 if (index != -1)  | 
|                 {  | 
|                     potentials[index].Refresh(newSkillId);  | 
|                 }  | 
|             }  | 
|         }  | 
|   | 
|         public void Reset()  | 
|         {  | 
|             level = 0;  | 
|             foreach (var potential in potentials)  | 
|             {  | 
|                 potential.Reset();  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|     public class TreasurePotential  | 
|     {  | 
|         public readonly int id;  | 
|         public readonly int maxLevel;  | 
|         public readonly int limitLevel;  | 
|         public readonly Redpoint activeRedpoint;  | 
|         public int level { get; private set; }  | 
|   | 
|         public TreasurePotential(int id, int level, int limitLevel, int redpointBase)  | 
|         {  | 
|             this.id = id;  | 
|             this.level = level;  | 
|             this.limitLevel = limitLevel;  | 
|   | 
|             var config = SkillConfig.Get(id);  | 
|             maxLevel = config.SkillMaxLV;  | 
|   | 
|             activeRedpoint = new Redpoint(redpointBase,  | 
|                 TreasureSkillModel.REDPOINTID_BASE + TreasureSkillModel.redpointIndex++);  | 
|         }  | 
|   | 
|         public SkillConfig GetSkillConfig(int level)  | 
|         {  | 
|             if (level > 0)  | 
|             {  | 
|                 return SkillConfig.Get(id + level - 1);  | 
|             }  | 
|             else  | 
|             {  | 
|                 return SkillConfig.Get(id + level);  | 
|             }  | 
|         }  | 
|   | 
|         public void Refresh(int newSkillId)  | 
|         {  | 
|             var config = SkillConfig.Get(newSkillId);  | 
|             if (config.SkillTypeID == id)  | 
|             {  | 
|                 level = config.SkillLV;  | 
|             }  | 
|         }  | 
|   | 
|         public void Reset()  | 
|         {  | 
|             level = 0;  | 
|         }  | 
|   | 
|   | 
|           | 
|   | 
|     }  | 
| }  | 
|   |