From a0ede150686a218c92b901b1f20aef12a9913890 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期五, 14 九月 2018 09:36:59 +0800
Subject: [PATCH] 1930【1.0.15】【主干】功能预告跳转八卦炉激活,功能预告界面未关闭

---
 System/Skill/SkillModel.cs |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/System/Skill/SkillModel.cs b/System/Skill/SkillModel.cs
index 596509c..c988c69 100644
--- a/System/Skill/SkillModel.cs
+++ b/System/Skill/SkillModel.cs
@@ -14,11 +14,13 @@
         {
             ParseConfig();
             FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
+            PlayerTaskDatas.Event_TaskInformation += TaskInformationUpdate;
         }
 
         public override void UnInit()
         {
             FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
+            PlayerTaskDatas.Event_TaskInformation -= TaskInformationUpdate;
         }
 
         public void OnBeforePlayerDataInitialize()
@@ -27,6 +29,7 @@
             equipPassSkills.Clear();
             playerLoginOk = false;
             equipPassPage = false;
+            taskHoleCondition = 0;
         }
 
         #region 閰嶇疆
@@ -44,6 +47,9 @@
         public Dictionary<int, Dictionary<int, List<SkillConfig>>> skillActDict { get; private set; }
         public List<int> betterPassSkills { get; private set; }
         public bool jumpToPass { get; set; }
+        public int minTaskHole { get; private set; }
+        public int maxTaskHole { get; private set; }
+        public int immediatelyUnlockTask { get; private set; }
         void ParseConfig()
         {
             for (int i = 1; i <= 3; i++)
@@ -68,9 +74,20 @@
                     PassSkillLimit limit = JsonMapper.ToObject<PassSkillLimit>(jsonData[key].ToJson());
                     limit.hole = int.Parse(key);
                     passSkillLimits.Add(limit);
+                    if (minTaskHole == 0 && limit.OpenSkillSlots > 0)
+                    {
+                        minTaskHole = limit.OpenSkillSlots;
+                    }
+                    if (limit.OpenSkillSlots > maxTaskHole)
+                    {
+                        maxTaskHole = limit.OpenSkillSlots;
+                    }
                 }
                 passEquipCnt = int.Parse(funcCfg.Numerical2);
+                taskHoleDict = ConfigParse.GetDic<int, int>(funcCfg.Numerical4);
             }
+            funcCfg = Config.Instance.Get<FuncConfigConfig>("PassiveSkillTask");
+            immediatelyUnlockTask = int.Parse(funcCfg.Numerical2);
             funcCfg = Config.Instance.Get<FuncConfigConfig>("PassSkillEquipGetWay");
             if (funcCfg != null)
             {
@@ -212,6 +229,7 @@
         public int presentEquipPage { get; private set; }
         public bool playerLoginOk = false;
         private Dictionary<int, Dictionary<int, int>> equipPassSkills = new Dictionary<int, Dictionary<int, int>>();
+        public Dictionary<int, int> taskHoleDict { get; private set; }
         public event Action UpdatePassEquipSkillEvent;
         public bool equipPassPage { get; set; }
         public bool TryGetEquipPassSkills(int page, int hole, out int _skillId)
@@ -283,6 +301,61 @@
             }
         }
 
+        public event Action taskUnlockUpdate;
+
+        public uint taskHoleCondition { get; private set; }
+
+        public const string TASKHOLEKEY = "OpenSkillSlots";
+
+        public int UnlockPassHole
+        {
+            get { return LocalSave.GetInt(StringUtility.Contact(TASKHOLEKEY, "_", PlayerDatas.Instance.baseData.PlayerID)); }
+            set { LocalSave.SetInt(StringUtility.Contact(TASKHOLEKEY, "_", PlayerDatas.Instance.baseData.PlayerID), value); }
+        }
+
+        public bool IsTaskHoleUnlock(int condition)
+        {
+            if (task._DicTaskInformation.ContainsKey(1)
+                && task._DicTaskInformation[1].ContainsKey(TASKHOLEKEY))
+            {
+                uint value = 0;
+                uint.TryParse(task._DicTaskInformation[1][TASKHOLEKEY], out value);
+                return MathUtility.GetBitValue(value, (ushort)condition);
+                //return value >= condition;
+            }
+            return false;
+        }
+
+        private void TaskInformationUpdate(int _id, Dictionary<int, Dictionary<string, string>> _Dic)
+        {
+            if (_Dic != null && _Dic.ContainsKey(1))
+            {
+                var dict = _Dic[1];
+                if (dict.ContainsKey(TASKHOLEKEY))
+                {
+                    uint result = 0;
+                    uint.TryParse(dict[TASKHOLEKEY], out result);
+                    if (playerLoginOk)
+                    {
+                        for (int k = minTaskHole; k <= maxTaskHole; k++)
+                        {
+                            if (!MathUtility.GetBitValue(taskHoleCondition, (ushort)k)
+                                && MathUtility.GetBitValue(result, (ushort)k))
+                            {
+                                UnlockPassHole = k;
+                            }
+                        }
+                        if (taskUnlockUpdate != null)
+                        {
+                            taskUnlockUpdate();
+                        }
+                    }
+                    taskHoleCondition = result;
+                }
+            }
+            UpdateTaskHoleRedpoint();
+        }
+
         RolePromoteModel m_PromoteModel;
         RolePromoteModel promoteModel
         {
@@ -291,6 +364,8 @@
                 return m_PromoteModel ?? (m_PromoteModel = ModelCenter.Instance.GetModel<RolePromoteModel>());
             }
         }
+
+        PlayerTaskDatas task { get { return ModelCenter.Instance.GetModel<PlayerTaskDatas>(); } }
 
         public void SendEquipPassSkill(int _page, int _index, int _skillId)
         {
@@ -335,6 +410,13 @@
                 else if (limit.MountLv > 0)
                 {
                     if (promoteModel.GetMountTotallv() < limit.MountLv)
+                    {
+                        return false;
+                    }
+                }
+                else if (limit.OpenSkillSlots > 0)
+                {
+                    if (!IsTaskHoleUnlock(limit.OpenSkillSlots))
                     {
                         return false;
                     }
@@ -449,6 +531,7 @@
             }
             playerLoginOk = true;
             UpdateRedpoint();
+            UpdateTaskHoleRedpoint();
         }
 
         public void CheckEquipPassSkill(PlayerSkillData _skill)
@@ -567,6 +650,36 @@
             DayRemind.Instance.SetDayRemind(DayRemind.PASS_SKILL_REDPOINT, true);
             UpdateRedpoint();
         }
+
+        public Redpoint taskHoleRedpoint = new Redpoint(10302, 1030299);
+        void UpdateTaskHoleRedpoint()
+        {
+            taskHoleRedpoint.state = RedPointState.None;
+            if (DayRemind.Instance.GetDayRemind(DayRemind.TASK_SKILL_HOLE))
+            {
+                return;
+            }
+            foreach (var hole in taskHoleDict.Keys)
+            {
+                var taskId = taskHoleDict[hole];
+                if (taskId == immediatelyUnlockTask)
+                {
+                    var config = Config.Instance.Get<PyTaskConfig>(taskId);
+                    if (PlayerDatas.Instance.baseData.LV >= config.lv
+                        && !IsTaskHoleUnlock(hole))
+                    {
+                        taskHoleRedpoint.state = RedPointState.Simple;
+                    }
+                    return;
+                }
+            }
+        }
+
+        public void SetTaskHoleRemind()
+        {
+            DayRemind.Instance.SetDayRemind(DayRemind.TASK_SKILL_HOLE, true);
+            UpdateTaskHoleRedpoint();
+        }
         #endregion
 
         private void OnFuncStateChangeEvent(int _id)
@@ -574,6 +687,7 @@
             if (_id == 109)
             {
                 UpdateRedpoint();
+                UpdateTaskHoleRedpoint();
             }
         }
     }
@@ -584,6 +698,7 @@
         public int level;
         public int vipLv;
         public int MountLv;
+        public int OpenSkillSlots;
     }
 
     [Serializable]

--
Gitblit v1.8.0