From ee945ee8d3199e91df76e7b320d2c37f5efc599a Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期三, 12 九月 2018 17:10:57 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 System/MainInterfacePanel/FeatureNoticeWin.cs |  240 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 222 insertions(+), 18 deletions(-)

diff --git a/System/MainInterfacePanel/FeatureNoticeWin.cs b/System/MainInterfacePanel/FeatureNoticeWin.cs
index 71749f6..383f6e7 100644
--- a/System/MainInterfacePanel/FeatureNoticeWin.cs
+++ b/System/MainInterfacePanel/FeatureNoticeWin.cs
@@ -22,8 +22,14 @@
         [SerializeField] Text m_TextShowD;//鏄剧ず鍐呭4
         [SerializeField] ScrollerController m_ScrollerController;
         [SerializeField] Button m_CloseButton;
-        List<FunctionForecastConfig> FunctionList = new List<FunctionForecastConfig>();
+        [SerializeField] Text m_TextTurnedOn;//宸插紑鍚�
+        [SerializeField] Text m_TextUnopened;//鏈紑鍚�
+        [SerializeField] Text m_Textschedule;//杩涘害
+        [SerializeField] Button m_ButtonGoto;
+        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
+        FeatureNoticeModel featureNoticeModel { get { return ModelCenter.Instance.GetModel<FeatureNoticeModel>(); } }
         #region Built-in
+        private int ClickFuncID = 0;
         protected override void BindController()
         {
         }
@@ -35,32 +41,70 @@
 
         protected override void OnPreOpen()
         {
-            AddList();
-            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
+            DefaultSelection();//鑾峰彇榛樿閫夋嫨
+            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;       
             OnCreateGridLineCell(m_ScrollerController);
+            ContentDisplay();
+            m_ScrollerController.JumpIndex(JumpIndex());
         }
 
         protected override void OnAfterOpen()
         {
-        }
-
+            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
+            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnPlayersUpLV;
+            treasureModel.treasureStateChangeEvent += treasureStateChangeEvent;
+            treasureModel.treasureStageUpEvent += treasureStageUpEvent;
+        }
         protected override void OnPreClose()
         {
-            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
+            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnPlayersUpLV;
+            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
+            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
+            treasureModel.treasureStateChangeEvent -= treasureStateChangeEvent;
+            treasureModel.treasureStageUpEvent -= treasureStageUpEvent;
+            if (featureNoticeModel.redPointStre1.state == RedPointState.Simple)
+            {
+                featureNoticeModel.redPointStre1.state = RedPointState.None;
+            }
         }
 
+        private void treasureStageUpEvent(int obj)
+        {
+            ContentDisplay();
+            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+        }
+
+        private void treasureStateChangeEvent(int obj)
+        {
+            ContentDisplay();
+            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+        }
+
+        private void OnFuncStateChangeEvent(int obj)
+        {
+            ContentDisplay();
+            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+        }
+        private void OnPlayersUpLV(PlayerDataRefresh obj)
+        {
+            if (obj == PlayerDataRefresh.LV)
+            {
+                ContentDisplay();
+                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+            }
+        }
         void OnCreateGridLineCell(ScrollerController gridCtrl)
         {
             gridCtrl.Refresh();
-            for (int i = 0; i < FunctionList.Count; i++)
+            for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
             {
                 if (i == 0)
                 {
-                    gridCtrl.AddCell(ScrollerDataType.Header, FunctionList[i].FuncId);
+                    gridCtrl.AddCell(ScrollerDataType.Header, featureNoticeModel.FunctionList[i].FuncId);
                 }
                 else
                 {
-                    gridCtrl.AddCell(ScrollerDataType.Normal, FunctionList[i].FuncId);
+                    gridCtrl.AddCell(ScrollerDataType.Normal, featureNoticeModel.FunctionList[i].FuncId);
                 }
             }
             gridCtrl.Restart();
@@ -72,11 +116,45 @@
             {
                 FeaturesType1 featuresType1 = cell.GetComponent<FeaturesType1>();
                 featuresType1.GetTheFeatureID(funcId);
+                if (funcId == ClickFuncID)
+                {
+                    featuresType1.ImageSelected.SetActive(true);
+                }
+                else
+                {
+                    featuresType1.ImageSelected.SetActive(false);
+                }
+                featuresType1.Button.SetListener(()=> 
+                {
+                    if (funcId != ClickFuncID)
+                    {
+                        ClickFuncID = funcId;
+                        ContentDisplay();
+                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                    }
+                });
             }
             else if (type == ScrollerDataType.Normal)
             {
                 FeaturesType2 featuresType2 = cell.GetComponent<FeaturesType2>();
                 featuresType2.GetTheFeatureID(funcId);
+                if (funcId == ClickFuncID)
+                {
+                    featuresType2.ImageSelected.SetActive(true);
+                }
+                else
+                {
+                    featuresType2.ImageSelected.SetActive(false);
+                }
+                featuresType2.Button.SetListener(() =>
+                {
+                    if (funcId != ClickFuncID)
+                    {
+                        ClickFuncID = funcId;
+                        ContentDisplay();
+                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//鍒锋柊鍙
+                    }
+                });
             }
         }
 
@@ -84,20 +162,146 @@
         {
         }
         #endregion
-        private void AddList()
+        private void DefaultSelection()//鑾峰彇榛樿閫夋嫨
         {
-            if (FunctionList.Count <= 0)
+            var configs = Config.Instance.GetAllValues<FunctionForecastConfig>();
+            foreach (var config in configs)
             {
-                var configs = Config.Instance.GetAllKeys<FunctionForecastConfig>();
-                foreach (var key in configs)
+                int openTag = config.FuncId;
+                if (!FuncOpen.Instance.IsFuncOpen(openTag))
                 {
-                    var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(key);
-                    if (functionForecastConfig != null && functionForecastConfig.Display == 1)
-                    {
-                        FunctionList.Add(functionForecastConfig);
-                    }
+                    ClickFuncID = openTag;
+                    return;
+                }
+            }
+            if (ClickFuncID == 0)
+            {
+                ClickFuncID = featureNoticeModel.FunctionList[0].FuncId;
+            }
+        }
+
+        private int JumpIndex()//Jump閫変腑
+        {
+            int Index = 0;
+            Index = featureNoticeModel.FunctionList.FindIndex((x)=> 
+            {
+                return x.FuncId == ClickFuncID;
+            });
+            return Index;
+        }
+
+        private void ContentDisplay()//鍐呭鏄剧ず
+        {
+            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
+            if (functionForecastConfig == null)
+            {
+                return;
+            }
+            m_TextAdvanceName.text = functionForecastConfig.FuncName;
+            m_FeaturesImage.SetSprite(functionForecastConfig.Icon);
+            string[] StrList = ConfigParse.GetMultipleStr(functionForecastConfig.Content);
+            if (StrList.Length > 0)
+            {
+                m_Text_ShowA.text = StrList[0];
+                m_TextShowB.text = StrList[1];
+                m_TextShowC.text = StrList[2];
+                m_TextShowD.text = StrList[3];
+            }
+            if (FuncOpen.Instance.IsFuncOpen(ClickFuncID))
+            {
+                m_TextTurnedOn.gameObject.SetActive(true);
+                m_TextUnopened.gameObject.SetActive(false);
+                m_Textschedule.gameObject.SetActive(false);
+                m_ButtonGoto.gameObject.SetActive(false);
+            }
+            else
+            {
+                TrailerClassification(ClickFuncID);
+            }
+
+        }
+
+        void TrailerClassification(int funcID)//棰勫憡鍒嗙被
+        {
+            m_TextTurnedOn.gameObject.SetActive(false);
+            m_TextUnopened.gameObject.SetActive(false);
+            m_Textschedule.gameObject.SetActive(false);
+            m_ButtonGoto.gameObject.SetActive(false);
+            FuncOpenLVConfig funcoPenConfig = Config.Instance.Get<FuncOpenLVConfig>(funcID);
+            if (funcoPenConfig.LimitMagicWeapon != 0 || funcoPenConfig.LimitMissionID != 0)
+            {
+                if (funcoPenConfig.LimitMagicWeapon != 0)//娉曞疂
+                {
+                    int faBaoID = funcoPenConfig.LimitMagicWeapon / 100;
+                    MagicWeapon(faBaoID);
 
                 }
+                else if (funcoPenConfig.LimitMissionID != 0)//浠诲姟
+                {
+                    m_TextUnopened.gameObject.SetActive(true);
+                    m_TextUnopened.text= string.Format(Language.Get("TaskFuncOpen"), funcoPenConfig.LimitLV);
+                    return;
+                }
+            }
+            else//绛夌骇
+            {
+                m_TextUnopened.gameObject.SetActive(true);
+                m_TextUnopened.text= string.Format(Language.Get("FuncLevelOpen"), funcoPenConfig.LimitLV);
+                return;
+            }
+        }
+
+        private void MagicWeapon(int fabaoID)
+        {
+            m_ButtonGoto.gameObject.SetActive(true);
+            Treasure treasure;
+            TreasureConfig _treasure = Config.Instance.Get<TreasureConfig>(fabaoID);
+            m_ButtonGoto.SetListener(()=> 
+            {
+                var config = Config.Instance.Get<TreasureConfig>(fabaoID);
+                treasureModel.selectedTreasure = fabaoID;
+                treasureModel.currentCategory = (TreasureCategory)config.Category;
+                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureCollectSoul);
+            });
+            if (treasureModel.TryGetTreasure(fabaoID, out treasure)
+                && treasure.state == TreasureState.Collected)
+            {
+                m_Textschedule.gameObject.SetActive(true);
+                var list = treasure.treasureStages;
+                var funcStage = 0;
+                for (int i = 0; i < list.Count; i++)
+                {
+                    if (list[i].unlockType == TreasureStageUnlock.Func &&
+                        list[i].func == ClickFuncID)
+                    {
+                        funcStage = i;
+                        break;
+                    }
+                }
+                if (treasure.stage < funcStage)
+                {
+                    if (treasure.stage == funcStage - 1 || funcStage == 0)
+                    {
+                        if (treasure.exp >= treasure.treasureStages[funcStage].exp)
+                        {
+                            m_Textschedule.text = "100%";
+                        }
+                        else
+                        {
+                            m_Textschedule.text = (float)treasure.exp / treasure.treasureStages[funcStage].exp + "%";
+                        }
+                       
+                    }
+                    else
+                    {
+                        m_Textschedule.text = 0+" %";
+                    }
+                }
+            }
+            else
+            {
+                m_TextUnopened.gameObject.SetActive(true);
+                m_TextUnopened.text = string.Format(Language.Get("FuncFBOpen"), _treasure.Name);
             }
         }
     }

--
Gitblit v1.8.0