Browse Source

剧情章节显示效果修改

zhangyuqian 1 year ago
parent
commit
040308b4f0

+ 61 - 22
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryChapterListView.cs

@@ -11,7 +11,6 @@ namespace GFGGame
         private int curTab;
         private int subType = ConstInstanceZonesSubType.Normal;
         private List<StoryChapterCfg> _chapterCfgs;
-
         public override void Dispose()
         {
             if (_ui != null)
@@ -46,7 +45,8 @@ namespace GFGGame
             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zxian_bg3");
 
             _ui.m_listChapter.scrollPane.onScroll.Add(DoSpecialEffect);//滚动时派发事件
-            
+            //_ui.m_listChapter.scrollPane.onScroll.Add(SetItemColorCallBack);
+
 
         }
 
@@ -66,7 +66,7 @@ namespace GFGGame
             Timers.inst.AddUpdate(CheckGuide);
             _ui.m_openViewAction.Play();
 
-           
+
         }
 
         protected override void OnHide()
@@ -105,19 +105,36 @@ namespace GFGGame
             GObject chapterItem = context.sender as GObject;
             int chapterID = (int)chapterItem.data;
             StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterID);
-            if (MainStoryDataManager.CheckChapterUnlock(chapterID))
+            //这里变成-1,是因为调整了item,最左右两边现在有item但是是透明没数据的
+            int index = chapterCfg.order - 1;
+            index = Mathf.Clamp(index, 0, _ui.m_listChapter.numItems - 2);
+            int firstChildIndex = _ui.m_listChapter.GetFirstChildInView();
+            if (firstChildIndex != index)
             {
-                ViewManager.Show<StoryChapterView>(new object[] { chapterID , _ui.m_listType.selectedIndex }, new object[] { typeof(StoryChapterListView).FullName, new object[] { _ui.m_listType.selectedIndex } });
-                this.Hide();
+                _ui.m_listChapter.ScrollToView(index, true, true);
             }
             else
             {
+                if (MainStoryDataManager.CheckChapterUnlock(chapterID))
+                {
+                    ViewManager.Show<StoryChapterView>(new object[] { chapterID, _ui.m_listType.selectedIndex }, new object[] { typeof(StoryChapterListView).FullName, new object[] { _ui.m_listType.selectedIndex } });
+                    this.Hide();
+                }
+                else
+                {
 
+                }
             }
+
         }
 
         private void ListChapterItem(int index, GObject item)
         {
+            if (index == 0 || index == _ui.m_listChapter.numItems - 1)
+            {
+                return;
+            }
+            index -= 1;
             UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(item);
             if (subType == 1)
             {
@@ -148,7 +165,7 @@ namespace GFGGame
                 //listItem.m_content.m_txtMaxProgress.color = new Color(0.514f, 0.345f, 0.220f, 1.000f);
 
             }
-            
+
             // if (index % 2 == 0)
             // {
             //     listItem.m_content.target.y = 102;
@@ -187,7 +204,8 @@ namespace GFGGame
             {
                 i = _time;
             }
-            else {
+            else
+            {
                 if (_timeCount > _ui.m_listChapter.numChildren)
                 {
                     Timers.inst.Remove(OnTimerUpdate);
@@ -195,23 +213,32 @@ namespace GFGGame
                 }
                 i = _time - _ui.m_listChapter.numChildren;
             }
-            _ui.m_listChapter.GetChildAt(i).visible = true;
-            UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
-            listItem.m_openListAction.Play();
-
+            if (i > 0 && i < _ui.m_listChapter.numItems - 1)
+            {
+                _ui.m_listChapter.GetChildAt(i).visible = true;
+                UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
+                listItem.m_openListAction.Play();
+            }
             _time += (int)param;
         }
 
         private void UpdateList()
         {
             _chapterCfgs = StoryChapterCfgArray.Instance.GetCfgsBysubType(subType);
-            _ui.m_listChapter.numItems = _chapterCfgs.Count;
+            //这里+2,只是为了list左右两边为空白的表现,对于数据没啥意义
+            _ui.m_listChapter.numItems = _chapterCfgs.Count + 2;
             int currentChapterIndex = 0;
-            for (int i = 0; i < _ui.m_listChapter.numChildren; i++)
+            for (int i = 0; i < _ui.m_listChapter.numChildren; i++) 
             {
+                if (i == 0 || i == _ui.m_listChapter.numItems - 1)
+                {
+                    _ui.m_listChapter.GetChildAt(i).visible = false;
+                    continue;
+                }
                 UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
+                int index = i - 1;
                 int chapterID = (int)listItem.target.data;
-                StoryChapterCfg chapterCfg = _chapterCfgs[i];
+                StoryChapterCfg chapterCfg = _chapterCfgs[index];
                 int starCountChapter = InstanceZonesDataManager.GetChapterStarCount(chapterCfg.id, chapterCfg.type, chapterCfg.subType);
                 listItem.m_content.m_txtCurProgress.text = starCountChapter.ToString();
                 listItem.m_content.m_txtMaxProgress.text = chapterCfg.bonusStar3.ToString();
@@ -255,7 +282,8 @@ namespace GFGGame
             {
                 _time = currentChapterIndex - 1;
             }
-            else { 
+            else
+            {
                 _time = currentChapterIndex;
             }
             _timeCount = 0;
@@ -308,19 +336,30 @@ namespace GFGGame
                 float distance = Mathf.Abs(listCenter - itemCenter);
                 if (distance < item.width)
                 {
-                    float distanceRange = 1 + (1 - distance / itemWidth) * 0.25f;//使放大动画有渐进效果
+                    float distanceRange = 1 + (1 - distance / itemWidth) * 0.3f;//使放大动画有渐进效果
                     item.SetScale(distanceRange, distanceRange);//设置放大比例
-
-                    
+                    //设置颜色变化
+                    if (distance < item.width / 2)
+                    {
+                        UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
+                        listItem.m_content.m_compPic.m_pic.color = new Color(1.0f, 1.0f, 1.0f, 1.000f);
+                    }
+                    else
+                    {
+                        UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
+                        listItem.m_content.m_compPic.m_pic.color = new Color(0.4f, 0.4f, 0.4f, 1.000f);
+                    }
                 }
                 else
                 {
+                    //设置颜色变化
+                    UI_ListChapterItem listItem = UI_ListChapterItem.Proxy(_ui.m_listChapter.GetChildAt(i));
+                    listItem.m_content.m_compPic.m_pic.color = new Color(0.4f, 0.4f, 0.4f, 1.000f);
                     item.SetScale(1.0f, 1.0f);
                 }
-                float distanceX = ((1-(listCenter - itemCenter)) / itemWidth) * 0.05f;//使放大动画有渐进效果
-                item.y = - _ui.m_listChapter.height * distanceX;
+                float distanceX = ((1 - (listCenter - itemCenter)) / itemWidth) * 0.05f;//使放大动画有渐进效果
+                item.y = -_ui.m_listChapter.height * distanceX;
             }
         }
-
     }
 }

+ 26 - 1
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryChapterView.cs

@@ -57,6 +57,7 @@ namespace GFGGame
             _valueBarController = new ValueBarController(_ui.m_valueBar);
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
             _ui.m_btnHome.onClick.Add(OnClickBtnHome);
+            _ui.m_chapter.m_compChapterScroll.m_imgBegin.onClick.Add(OnClickNext);
             _ui.m_bonusBox1.target.onClick.Add(() =>
             {
                 OnClickBonusBox(_ui.m_bonusBox1, 0);
@@ -103,6 +104,16 @@ namespace GFGGame
 
             Timers.inst.AddUpdate(CheckGuide);
 
+            int chapterNum = StoryChapterCfgArray.Instance.GetCfgsBysubType(currentDifficulty).Count;
+            if (MainStoryDataManager.CurrentChapterOrder == chapterNum)
+            {
+                _ui.m_chapter.m_compChapterScroll.m_imgBegin.visible = false;
+            }
+            else
+            {
+                _ui.m_chapter.m_compChapterScroll.m_imgBegin.visible = true;
+            }
+
         }
 
         protected override void OnHide()
@@ -131,6 +142,18 @@ namespace GFGGame
             GameController.GoBackToMainView();
         }
 
+        private void OnClickNext()
+        {
+            if (MainStoryDataManager.CheckChapterUnlock(_chapterID+1))
+            {
+                ViewManager.Show<StoryChapterView>(new object[] { _chapterID+1, currentDifficulty }, new object[] { typeof(StoryChapterListView).FullName, new object[] { currentDifficulty } });
+            }
+            else
+            {
+                PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡");
+            }
+        }
+
         private IEnumerator InitChapter()
         {
             StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
@@ -157,7 +180,7 @@ namespace GFGGame
             _comEff.visible = false;
             for (int i = 0; i < 20; i++)
             {
-                GObject obj = _ui.m_chapter.m_compChapterScroll.target.GetChild("g" + (i + 1));
+                GObject obj = _ui.m_chapter.m_compChapterScroll.target.GetChild("g" + (19 - i + 1));
                 obj.SetPosition(obj.x, starPosY - lineGap * i - 300, 0); ;
                 StoryLevelCfg levelCfg = i < list.Count ? list[i] : null;
                 UI_CompStoryLevelItem levelItem = UI_CompStoryLevelItem.Proxy(obj);
@@ -401,6 +424,8 @@ namespace GFGGame
 
         }
 
+
+
     }
 }
 

+ 15 - 2
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -422,8 +422,21 @@ namespace GFGGame
                 new object[] { typeof(MainUIView).FullName, this.viewData });
             isOpen = false;
             ;
-
-
+            List<StoryChapterCfg> _chapterCfgs = StoryChapterCfgArray.Instance.GetCfgsBysubType(0);
+            for (int i = 0; i < _chapterCfgs.Count; i++)
+            {
+                StoryChapterCfg chapterCfg = _chapterCfgs[i];
+                if (i == _chapterCfgs.Count - 1)
+                {
+                    ViewManager.Show<StoryChapterView>(new object[] { chapterCfg.id, 0 }, new object[] { typeof(StoryChapterListView).FullName, new object[] { 0 } });
+                    return;
+                }
+                else if (!MainStoryDataManager.CheckChapterUnlock(chapterCfg.id))
+                {
+                    ViewManager.Show<StoryChapterView>(new object[] { chapterCfg.id - 1, 0 }, new object[] { typeof(StoryChapterListView).FullName, new object[] { 0 } });
+                    return;
+                }
+            }
             // });
         }
 

BIN
GameClient/Assets/ResIn/UI/Main/Main_fui.bytes