From e0ec52ef7cd8aaa9687b8f8b9b68aec1d372a2ca Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期三, 08 五月 2019 10:56:33 +0800
Subject: [PATCH] 6680 子 【2.0】【开发】五行专精激活方式变更 / 【2.0】【前端】五行专精激活方式变更

---
 System/Skill/ExpertSkillSelectWin.cs |  118 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 92 insertions(+), 26 deletions(-)

diff --git a/System/Skill/ExpertSkillSelectWin.cs b/System/Skill/ExpertSkillSelectWin.cs
index bdf4d83..68e65f0 100644
--- a/System/Skill/ExpertSkillSelectWin.cs
+++ b/System/Skill/ExpertSkillSelectWin.cs
@@ -20,7 +20,10 @@
         [SerializeField] Image m_SkillIcon;
         [SerializeField] Text m_SkillName;
         [SerializeField] Text m_Reiki;
-        [SerializeField] ScrollerController m_Controller;
+        [SerializeField] Text m_ReikiPoint;
+        [SerializeField] ExpertSkillCyclicScroll m_CyclicScroll;
+        [SerializeField] LayoutElement m_LayoutElement;
+        [SerializeField] Button m_Active;
         [SerializeField] Button m_Select;
         [SerializeField] Button m_Close1;
         [SerializeField] Button m_Close2;
@@ -49,6 +52,10 @@
             }
         }
 
+        int selectActiveLevel = 0;
+
+        List<int> datas = new List<int>();
+
         TreasureSkillModel model { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
         #region Built-in
         protected override void BindController()
@@ -57,10 +64,11 @@
 
         protected override void AddListeners()
         {
-            m_Controller.OnRefreshCell += OnRefreshCell;
+            //m_Controller.OnRefreshCell += OnRefreshCell;
             m_Select.AddListener(OnSelect);
             m_Close1.AddListener(CloseClick);
             m_Close2.AddListener(CloseClick);
+            m_Active.AddListener(OnActiveSkill);
         }
 
         protected override void OnPreOpen()
@@ -70,7 +78,11 @@
 
             m_OpenDetail = false;
 
+            m_CyclicScroll.enabled = false;
+
             Display();
+
+            model.expertActiveRefresh += ExpertActiveRefresh;
         }
 
         protected override void OnAfterOpen()
@@ -79,6 +91,11 @@
 
         protected override void OnPreClose()
         {
+            m_CyclicScroll.Dispose();
+
+            StopAllCoroutines();
+
+            model.expertActiveRefresh -= ExpertActiveRefresh;
         }
 
         protected override void OnAfterClose()
@@ -97,7 +114,6 @@
         void SetDefaultSelect()
         {
             m_SelectExpert = 0;
-            //model.TryGetExpertSkill(selectSkillId, out m_SelectExpert);
         }
 
         void DisplayExperts()
@@ -125,24 +141,12 @@
         {
             if (selectExpert != 0)
             {
-                var level = 0;
-                TreasurePotential expert;
-                if (model.TryGetPotential(selectExpert, out expert))
-                {
-                    level = expert.level;
-                }
+                selectActiveLevel = 0;
+                model.TryGetExpertActiveLevel(selectExpert, out selectActiveLevel);
 
-                m_Select.gameObject.SetActive(PlayerDatas.Instance.baseData.LV >= expert.limitLevel);
+                DisplayButtonState();
 
-                SkillConfig skillConfig;
-                if (level == 0)
-                {
-                    skillConfig = SkillConfig.Get(selectExpert);
-                }
-                else
-                {
-                    skillConfig = SkillConfig.Get(selectExpert + level - 1);
-                }
+                var skillConfig = SkillConfig.Get(selectExpert);
 
                 m_SkillIcon.SetSprite(skillConfig.IconName);
                 m_SkillName.text = skillConfig.SkillName;
@@ -152,12 +156,44 @@
                 m_Reiki.text = propertyConfig.Name;
                 m_Reiki.color = UIHelper.GetPropertyColor(property);
 
-                m_Controller.Refresh();
+                m_ReikiPoint.text = string.Format("鎴戠殑{0}鐏垫牴锛歿1}",
+                    propertyConfig.Name, UIHelper.GetPropertyValue((PropertyType)property));
+
+                datas.Clear();
                 for (int i = 1; i <= skillConfig.SkillMaxLV; i++)
                 {
-                    m_Controller.AddCell(ScrollerDataType.Header, i);
+                    if (i >= selectActiveLevel)
+                    {
+                        datas.Add(selectExpert * 100 + i);
+                    }
                 }
-                m_Controller.Restart();
+
+                //m_LayoutElement.preferredHeight = datas.Count > 2 ? 440 : 302;
+
+                m_CyclicScroll.enabled = true;
+
+                m_CyclicScroll.Dispose();
+                m_CyclicScroll.Init(datas);
+                StartCoroutine(Co_Arrange());
+            }
+        }
+
+        IEnumerator Co_Arrange()
+        {
+            yield return null;
+            m_CyclicScroll.ReArrange();
+        }
+
+        void DisplayButtonState()
+        {
+            TreasurePotential expert;
+            if (model.TryGetPotential(selectExpert, out expert))
+            {
+                var satisfyActive = model.SatisfyActiveExpert(selectExpert);
+                var activeLevel = 0;
+                model.TryGetExpertActiveLevel(selectExpert, out activeLevel);
+                m_Select.gameObject.SetActive(activeLevel > 0 && !satisfyActive);
+                m_Active.gameObject.SetActive(satisfyActive);
             }
         }
 
@@ -178,17 +214,44 @@
             CloseImmediately();
         }
 
+        private void OnActiveSkill()
+        {
+            if (m_CyclicScroll.IsPlaying)
+            {
+                return;
+            }
+            var pak = new CA516_tagCMSelectSkillElement();
+            pak.SkillTypeID = (uint)selectExpert;
+            GameNetSystem.Instance.SendInfo(pak);
+        }
+
         private void OnSelect(int skillId)
         {
+            if (m_CyclicScroll.IsPlaying)
+            {
+                return;
+            }
             selectExpert = skillId;
         }
 
-        private void OnRefreshCell(ScrollerDataType type, CellView cell)
+        private void ExpertActiveRefresh(int id)
         {
-            var expertCell = cell as ExpertSkillConditionCell;
-            expertCell.Display(selectExpert, cell.index);
+            if (selectExpert == id)
+            {
+                var level = 0;
+                if (model.TryGetExpertActiveLevel(selectExpert, out level))
+                {
+                    if (level > selectActiveLevel && level > 1)
+                    {
+                        m_CyclicScroll.DisplayAnimation(()=> 
+                        {
+                            DisplayDetail();
+                        });
+                    }
+                }
+                DisplayButtonState();
+            }
         }
-
 
         #endregion
 
@@ -203,6 +266,7 @@
             [SerializeField] Transform m_ContainerSelect;
             [SerializeField] Text m_Use;
             [SerializeField] Text m_Limit;
+            [SerializeField] RedpointBehaviour m_Redpoint;
             [SerializeField] Button m_Select;
 
             public int skillId { get; private set; }
@@ -237,6 +301,8 @@
                 m_Icon.gray = !unlock;
                 m_ReikiBottom.gray = !unlock;
 
+                m_Redpoint.redpointId = expert.activeRedpoint.id;
+
                 m_Select.SetListener(() =>
                 {
                     if (func != null)

--
Gitblit v1.8.0