From b04fc4bee9584af8ea0457aafe4cf1b6c19b36d2 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期五, 01 三月 2019 16:36:10 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 System/Skill/TreasurePotentialLevelUpWin.cs |   24 ++++++--
 System/Skill/TreasurePotentialBehaviour.cs  |   11 +++
 System/Skill/TreasureSkillWin.cs            |  109 ++++++++++++++++++++++++++++++++----
 System/Skill/TreasureSkillCell.cs           |   16 ++---
 System/Skill/TreasureSkillModel.cs          |    5 +
 5 files changed, 135 insertions(+), 30 deletions(-)

diff --git a/System/Skill/TreasurePotentialBehaviour.cs b/System/Skill/TreasurePotentialBehaviour.cs
index b229efc..e0d6830 100644
--- a/System/Skill/TreasurePotentialBehaviour.cs
+++ b/System/Skill/TreasurePotentialBehaviour.cs
@@ -17,6 +17,7 @@
         [SerializeField] Image m_PotentialIcon;
         [SerializeField] Button m_Func;
         [SerializeField] RedpointBehaviour m_Redpoint;
+        [SerializeField] UIEffect m_UnlockEffect;
 
         int skillId = 0;
 
@@ -67,6 +68,16 @@
             }
         }
 
+        public void StartUnlock()
+        {
+            m_UnlockEffect.Play();
+        }
+
+        public void StopUnlock()
+        {
+            m_UnlockEffect.StopImediatly();
+        }
+
         private void OnFunc()
         {
             bool isOpen = model.IsPotentialUnlock(skillId);
diff --git a/System/Skill/TreasurePotentialLevelUpWin.cs b/System/Skill/TreasurePotentialLevelUpWin.cs
index e6b32c5..3ec8b44 100644
--- a/System/Skill/TreasurePotentialLevelUpWin.cs
+++ b/System/Skill/TreasurePotentialLevelUpWin.cs
@@ -29,12 +29,18 @@
         [SerializeField] Button m_LevelUp;
         [SerializeField] Button m_GetWay;
         [SerializeField] Button m_Close;
+        [SerializeField] UIEffect m_LevelUpEffect;
 
         public static int selectPotentialId = 0;
 
         TreasureSkillModel model
         {
             get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); }
+        }
+
+        PackModel packModel
+        {
+            get { return ModelCenter.Instance.GetModel<PackModel>(); }
         }
         #region Built-in
         protected override void BindController()
@@ -53,6 +59,7 @@
         {
             Display();
             model.skillLevelUpRefresh += SkillLevelUpRefresh;
+            packModel.refreshItemCountEvent += RefreshItemCountEvent;
         }
 
         protected override void OnAfterOpen()
@@ -62,6 +69,7 @@
         protected override void OnPreClose()
         {
             model.skillLevelUpRefresh -= SkillLevelUpRefresh;
+            packModel.refreshItemCountEvent -= RefreshItemCountEvent;
         }
 
         protected override void OnAfterClose()
@@ -74,6 +82,7 @@
             if (selectPotentialId == id)
             {
                 Display();
+                m_LevelUpEffect.Play();
             }
         }
 
@@ -133,12 +142,7 @@
 
                 if (!isMax)
                 {
-                    var requireSkillConfig = SkillConfig.Get(config.LearnSkillReq);
-                    TreasurePotential requirePotential;
-                    if (model.TryGetPotential(config.LearnSkillReq, out requirePotential))
-                    {
-                        m_Item.SetItem(config.ExAttr4, config.ExAttr5);
-                    }
+                    m_Item.SetItem(config.ExAttr4, config.ExAttr5);
                 }
             }
 
@@ -172,6 +176,14 @@
             }
         }
 
+        private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
+        {
+            if (packType == PackType.Item && model.skillLevelUpItems.Contains(itemId))
+            {
+                Display();
+            }
+        }
+
     }
 
 }
diff --git a/System/Skill/TreasureSkillCell.cs b/System/Skill/TreasureSkillCell.cs
index 2263dcb..75bb039 100644
--- a/System/Skill/TreasureSkillCell.cs
+++ b/System/Skill/TreasureSkillCell.cs
@@ -43,11 +43,12 @@
             var treasureId = treasureModel.GetTreasureBySkillId(skillId);
 
             var isSkillUnlock = false;
-
-            Treasure treasure;
-            if (treasureModel.TryGetTreasure(treasureId, out treasure))
+            TreasureSkill treasureSkill;
+            if (model.TryGetSkill(skillId, out treasureSkill))
             {
-                isSkillUnlock = treasure.state == TreasureState.Collected;
+                isSkillUnlock = treasureSkill.level > 0;
+                m_SkillLevel.text = StringUtility.Contact("LV.", treasureSkill.level);
+                m_Redpoint.redpointId = treasureSkill.redpoint.id;
             }
 
             m_ContainerLock.gameObject.SetActive(!isSkillUnlock);
@@ -56,12 +57,7 @@
             m_ContainerSelect.gameObject.SetActive(skillId == model.selectSkill);
             m_SkillLevel.gameObject.SetActive(isSkillUnlock);
 
-            TreasureSkill treasureSkill;
-            if (model.TryGetSkill(skillId, out treasureSkill))
-            {
-                m_SkillLevel.text = StringUtility.Contact("LV.", treasureSkill.level);
-                m_Redpoint.redpointId = treasureSkill.redpoint.id;
-            }
+            
         }
 
         void DisplayBase()
diff --git a/System/Skill/TreasureSkillModel.cs b/System/Skill/TreasureSkillModel.cs
index 6d3318e..f5de5f7 100644
--- a/System/Skill/TreasureSkillModel.cs
+++ b/System/Skill/TreasureSkillModel.cs
@@ -8,7 +8,8 @@
     {
         Dictionary<int, TreasureSkill> treasureSkills = new Dictionary<int, TreasureSkill>();
         Dictionary<int, List<int>> jobTreasureSkills = new Dictionary<int, List<int>>();
-        List<int> skillLevelUpItems = new List<int>();
+
+        public List<int> skillLevelUpItems = new List<int>();
 
         int m_SelectSkill;
         public int selectSkill
@@ -368,7 +369,7 @@
 
                 foreach (var potential in skill.potentials)
                 {
-                    if (requireRemind && funcOpen &&
+                    if (requireRemind && funcOpen && IsPotentialUnlock(potential.id) &&
                         TryLevelUpPotential(potential.id, out error)
                         && skill.level > 0)
                     {
diff --git a/System/Skill/TreasureSkillWin.cs b/System/Skill/TreasureSkillWin.cs
index f7c83b0..7cf1c7f 100644
--- a/System/Skill/TreasureSkillWin.cs
+++ b/System/Skill/TreasureSkillWin.cs
@@ -28,12 +28,20 @@
         [SerializeField] Button m_GetWay;
         [SerializeField] Button m_LevelUp;
         [SerializeField] RedpointBehaviour m_LevelRedpoint;
+        [SerializeField] UIEffect m_LevelUpEffect;
         [SerializeField] Transform m_ContainerMax;
         [SerializeField] TreasurePotentialBehaviour[] m_TreasurePotentials;
+
+        List<Clock> clocks = new List<Clock>();
 
         TreasureSkillModel model
         {
             get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); }
+        }
+
+        PackModel packModel
+        {
+            get { return ModelCenter.Instance.GetModel<PackModel>(); }
         }
 
         #region Built-in
@@ -56,6 +64,7 @@
             model.treasureSkillRefresh += TreasureSkillRefresh;
             model.selectRefresh += SelectRefresh;
             model.skillLevelUpRefresh += SkillLevelUpRefresh;
+            packModel.refreshItemCountEvent += RefreshItemCountEvent;
         }
 
         protected override void OnAfterOpen()
@@ -67,7 +76,18 @@
             model.treasureSkillRefresh -= TreasureSkillRefresh;
             model.selectRefresh -= SelectRefresh;
             model.skillLevelUpRefresh -= SkillLevelUpRefresh;
+            packModel.refreshItemCountEvent -= RefreshItemCountEvent;
             model.SetAlreadyRemind();
+
+            for (int i = 0; i < m_TreasurePotentials.Length; i++)
+            {
+                m_TreasurePotentials[i].StopUnlock();
+            }
+            foreach (var clock in clocks)
+            {
+                clock.Stop();
+            }
+            clocks.Clear();
         }
 
         protected override void OnAfterClose()
@@ -108,6 +128,7 @@
         {
             DisplaySkills();
             DisplaySkillDetial();
+            DisplayPotentials();
         }
 
         private void DisplaySkills()
@@ -156,19 +177,28 @@
                         WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.Daily_EmperorRelic);
                     });
                 }
+            }
+        }
 
-                for (int i = 0; i < m_TreasurePotentials.Length; i++)
-                {
-                    if (i < skill.potentials.Count)
-                    {
-                        m_TreasurePotentials[i].gameObject.SetActive(true);
-                        m_TreasurePotentials[i].Display(skill.potentials[i].id);
-                    }
-                    else
-                    {
-                        m_TreasurePotentials[i].gameObject.SetActive(false);
-                    }
-                }
+        private void DisplayPotentials()
+        {
+            for (int i = 0; i < m_TreasurePotentials.Length; i++)
+            {
+                DisplayPotential(i);
+            }
+        }
+
+        private void DisplayPotential(int index)
+        {
+            TreasureSkill skill;
+            if (!model.TryGetSkill(model.selectSkill, out skill))
+            {
+                return;
+            }
+            if (index < m_TreasurePotentials.Length)
+            {
+                m_TreasurePotentials[index].gameObject.SetActive(index < skill.potentials.Count);
+                m_TreasurePotentials[index].Display(skill.potentials[index].id);
             }
         }
 
@@ -204,8 +234,18 @@
 
         private void SelectRefresh()
         {
+            for (int i = 0; i < m_TreasurePotentials.Length; i++)
+            {
+                m_TreasurePotentials[i].StopUnlock();
+            }
+            foreach (var clock in clocks)
+            {
+                clock.Stop();
+            }
+            clocks.Clear();
             m_Controller.m_Scorller.RefreshActiveCellViews();
             DisplaySkillDetial();
+            DisplayPotentials();
         }
 
         private void SkillLevelUpRefresh(int id)
@@ -214,6 +254,51 @@
             {
                 m_Controller.m_Scorller.RefreshActiveCellViews();
                 DisplaySkillDetial();
+
+                m_LevelUpEffect.Play();
+
+                TreasureSkill skill;
+                if (model.TryGetSkill(model.selectSkill, out skill))
+                {
+                    for (int i = 0; i < skill.potentials.Count; i++)
+                    {
+                        var index = i;
+                        if (index < m_TreasurePotentials.Length &&
+                            skill.potentials[index].openLevel == skill.level)
+                        {
+                            m_TreasurePotentials[index].StartUnlock();
+                            Clock clock = null;
+                            clock = Clock.Create(1, () =>
+                              {
+                                  DisplayPotential(index);
+                                  if (clock != null && clocks.Contains(clock))
+                                  {
+                                      clocks.Remove(clock);
+                                  }
+                              });
+                            clocks.Add(clock);
+                        }
+                    }
+                }
+            }
+            else
+            {
+                var skillId = 0;
+                if (model.ContainsSkill(id, out skillId))
+                {
+                    if (skillId == model.selectSkill)
+                    {
+                        DisplayPotentials();
+                    }
+                }
+            }
+        }
+
+        private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
+        {
+            if (packType == PackType.Item && model.skillLevelUpItems.Contains(itemId))
+            {
+                DisplaySkillDetial();
             }
         }
     }

--
Gitblit v1.8.0