Browse Source

Merge branch 'master' of http://10.108.64.190:3000/gfg/client

guodong 1 year ago
parent
commit
2887055831

+ 40 - 14
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryChapterListView.cs

@@ -11,6 +11,7 @@ namespace GFGGame
         private int curTab;
         private int subType = ConstInstanceZonesSubType.Normal;
         private List<StoryChapterCfg> _chapterCfgs;
+        private int chapterIndex = 1;
         public override void Dispose()
         {
             if (_ui != null)
@@ -55,10 +56,15 @@ namespace GFGGame
             base.OnShown();
 
             subType = 0;//MainStoryDataManager.GetChapterSubType(MainStoryDataManager.currentChapterCfgId);
-            if (this.viewData != null && (this.viewData as object[]).Length > 0)
+            if (this.viewData != null && (this.viewData as object[]).Length == 1)
             {
                 subType = (int)(this.viewData as object[])[0];
             }
+            else if (this.viewData != null && (this.viewData as object[]).Length > 1)
+            {
+                subType = (int)(this.viewData as object[])[0];
+                chapterIndex = (int)(this.viewData as object[])[1];
+            }
             _ui.m_listType.selectedIndex = subType;
             _ui.m_listChapter.touchable = false;
             UpdateList();
@@ -81,7 +87,7 @@ namespace GFGGame
 
         private void OnClickBtnBack()
         {
-           // GameController.GoBackToMainView();
+            // GameController.GoBackToMainView();
             this.Hide();
             //ViewManager.Show<MainUIView>();
             //ViewManager.Show<StoryChapterListView>();
@@ -98,7 +104,7 @@ namespace GFGGame
         private void OnClickListTypeItem()
         {
             this.subType = _ui.m_listType.selectedIndex;
-            UpdateList();
+            UpdateList(true);
         }
         private void OnClickListChapterItem(EventContext context)
         {
@@ -118,8 +124,16 @@ namespace GFGGame
             {
                 if (MainStoryDataManager.CheckChapterUnlock(chapterID))
                 {
-                    ViewManager.Show<StoryChapterView>(new object[] { chapterID, _ui.m_listType.selectedIndex });
-                    this.Hide();
+                    if (chapterIndex == chapterCfg.order)
+                    {
+                        this.Hide();
+                    }
+                    else
+                    {
+                        ViewManager.Show<StoryChapterView>(new object[] { chapterID, _ui.m_listType.selectedIndex });
+                        this.Hide();
+                    }
+
                 }
                 else
                 {
@@ -203,7 +217,7 @@ namespace GFGGame
             int i = 0;
             if (_time < _ui.m_listChapter.numChildren)
             {
-                i = _time;
+                i = Mathf.Max(0, _time);
             }
             else
             {
@@ -223,7 +237,7 @@ namespace GFGGame
             _time += (int)param;
         }
 
-        private void UpdateList()
+        private void UpdateList( bool isView = false)
         {
             _chapterCfgs = StoryChapterCfgArray.Instance.GetCfgsBysubType(subType);
             //这里+2,只是为了list左右两边为空白的表现,对于数据没啥意义
@@ -273,19 +287,31 @@ namespace GFGGame
                 }
                 UI_ListChapterItem.ProxyEnd();
             }
-            _ui.m_listChapter.ScrollToView(currentChapterIndex);
-            int childrenCount = _ui.m_listChapter.numChildren - 1;
-            if (currentChapterIndex == childrenCount - 1)
+            if (isView)
             {
-                _time = currentChapterIndex - 2;
+                _ui.m_listChapter.ScrollToView(currentChapterIndex -1, false, true);
             }
-            else if (currentChapterIndex >= 1 && currentChapterIndex <= childrenCount - 2)
+            else
+            {
+                _ui.m_listChapter.ScrollToView(chapterIndex - 1, false, true);
+            }
+            
+            int childrenCount = _ui.m_listChapter.numChildren - 1;
+            if (currentChapterIndex >= 1 && currentChapterIndex <= childrenCount - 1)
             {
-                _time = currentChapterIndex - 1;
+                if (isView)
+                {
+                    _time = currentChapterIndex - 2;
+                }
+                else
+                {
+                    _time = chapterIndex - 2;
+                }
+                
             }
             else
             {
-                _time = currentChapterIndex;
+                _time = chapterIndex;
             }
             _timeCount = 0;
             Timers.inst.Add(0.1f, _ui.m_listChapter.numChildren , OnTimerUpdate, 1);

+ 75 - 5
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryChapterView.cs

@@ -16,18 +16,35 @@ namespace GFGGame
         private GObject _unPasslevelItem;
         private GObject _endLevelItem;
         private EffectUI _effectUI1;
+        private EffectUI _effectUI2;
         private GComponent _comEff;
+        private GComponent _effFirst;
+
+        //当前章节索引
+        private int newIndex;
+        //y轴移动索引
+        private float indexY;
+        private GameObject gamey;
+        //特效类型数组,这里后面可以二维数组,放向左和向右的
+        private string[] effArray = new string[2]{ "ZJ_JuQing","ZJ_ZD"  };
 
         private int currentDifficulty;
         public override void Dispose()
         {
             EffectUIPool.Recycle(_effectUI1);
             _effectUI1 = null;
+            EffectUIPool.Recycle(_effectUI2);
+            _effectUI2 = null;
             if (_comEff != null)
             {
                 _comEff.RemoveFromParent();
                 _comEff.Dispose();
             }
+            if (_effFirst != null)
+            {
+                _effFirst.RemoveFromParent();
+                _effFirst.Dispose();
+            }
             if (_valueBarController != null)
             {
                 _valueBarController.Dispose();
@@ -47,7 +64,7 @@ namespace GFGGame
             _ui = UI_StoryChapterUI.Create();
             viewCom = _ui.target;
             isfullScreen = true;
-            isReturnView = true;
+            isReturnView = false;
         }
 
         protected override void OnInit()
@@ -76,6 +93,10 @@ namespace GFGGame
             _comEff = new GComponent();
             _comEff = UIPackage.CreateObject(UI_MainUI.PACKAGE_NAME, "ComEff").asCom;
             _effectUI1 = EffectUIPool.CreateEffectUI(_comEff.GetChild("holder").asGraph, "ui_gk", "ui_gk_sg");
+
+            _effFirst = new GComponent();
+            _effFirst = UIPackage.CreateObject(UI_MainUI.PACKAGE_NAME, "ComEff").asCom;
+
         }
         protected override void AddEventListener()
         {
@@ -97,8 +118,23 @@ namespace GFGGame
             }
             MainStoryDataManager.currentChapterCfgId = _chapterID;
 
+            //由于这里会切换特效,所以切换界面时进行清空
+            EffectUIPool.Recycle(_effectUI2);
+            _effectUI2 = null;
+            if (_effFirst != null)
+            {
+                _effFirst.RemoveFromParent();
+            }
+
+            StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(_chapterID);
+            newIndex = StoryUtil.GetChapterOrder(chapterCfg.id);
+            indexY = 115.0f * (float)StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(chapterCfg.type, chapterCfg.subType, chapterCfg.id).Count;
+            gamey = GameObject.Find("Stage/GRoot/GComponent/StoryChapterUI/CompChapter/Container/Container");
+
             Timers.inst.StartCoroutine(InitChapter());
 
+            Timers.inst.Add(0.5f,1,SetContainerY);
+
             _valueBarController.OnShown();
 
             _ui.target.touchable = true;
@@ -114,7 +150,6 @@ namespace GFGGame
             {
                 _ui.m_chapter.m_compChapterScroll.m_imgBegin.visible = true;
             }
-
         }
 
         protected override void OnHide()
@@ -124,7 +159,7 @@ namespace GFGGame
             _endLevelItem = null;
             // _ui.m_chapter.RemoveChildren(0, 0, true);
             _valueBarController.OnHide();
-
+            Timers.inst.Remove(SetContainerY);
             Timers.inst.Remove(CheckGuide);
         }
 
@@ -141,7 +176,8 @@ namespace GFGGame
         
         private void OnClickSwitchBack()
         {
-            ViewManager.Show<StoryChapterListView>( null, new object[] { typeof(StoryChapterView).FullName, this.viewData });
+            Timers.inst.Remove(SetContainerY);
+            ViewManager.Show<StoryChapterListView>(new object[] { currentDifficulty , newIndex }, new object[] { typeof(StoryChapterView).FullName, this.viewData });
         }
 
         private void OnClickBtnHome()
@@ -153,6 +189,7 @@ namespace GFGGame
         {
             if (MainStoryDataManager.CheckChapterUnlock(_chapterID+1))
             {
+                Timers.inst.Remove(SetContainerY);
                 ViewManager.Show<StoryChapterView>(new object[] { _chapterID+1, currentDifficulty });
             }
             else
@@ -185,12 +222,15 @@ namespace GFGGame
             int lineGap = 4500 / list.Count;
 
             _comEff.visible = false;
+            _effFirst.visible = false;
             for (int i = 0; i < 20; i++)
             {
                 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);
+                levelItem.m_fightBg.visible = true;
+                levelItem.m_loaDialogBg.visible = true;
                 if (levelCfg != null && MainStoryDataManager.CheckLevelUnlock(levelCfg.id))
                 {
                     UnlockCount++;
@@ -267,6 +307,23 @@ namespace GFGGame
                         _unPasslevelItem = levelItem.target;
                         levelItem.target.AddChild(_comEff);
                         _comEff.visible = true;
+
+                        //设置解锁特效
+                        //string effName;
+                        //if ( currentDifficulty == 0 )
+                        //{
+                        //    effName = effArray[levelItem.m_c1.selectedIndex];
+                        //}
+                        //else
+                        //{
+                        //    effName = effArray[levelItem.m_c1.selectedIndex] + "_Blue";
+                        //}
+                        //_effectUI2 = EffectUIPool.CreateEffectUI(_effFirst.GetChild("holder").asGraph, "ui_zj", effName);
+                        //levelItem.target.AddChild(_effFirst);
+                        //levelItem.m_fightBg.visible = false;
+                        //levelItem.m_loaDialogBg.visible = false;
+                        //_effFirst.visible = true;
+                        //Timers.inst.Add(1.7f, 1, HideEffect, obj);
                     }
                     if (levelCfg.order > endLevel)
                     {
@@ -281,8 +338,21 @@ namespace GFGGame
                 UI_CompStoryLevelItem.ProxyEnd();
             }
             yield return new WaitForEndOfFrame();
-            _ui.m_chapter.m_compChapterScroll.target.y = Mathf.Max(0, _ui.m_chapter.target.height - _ui.m_chapter.m_compChapterScroll.target.height);
 
+            _ui.m_chapter.m_compChapterScroll.target.y =Mathf.Max(1 , _ui.m_chapter.target.height - _ui.m_chapter.m_compChapterScroll.target.height);
+            gamey.transform.position = new Vector3(0, indexY, 0);
+        }
+
+        private void SetContainerY(object param = null)
+        {
+            _ui.m_chapter.m_compChapterScroll.target.y = Mathf.Max(0, _ui.m_chapter.target.height - _ui.m_chapter.m_compChapterScroll.target.height - 1);
+        }
+
+        private void HideEffect(object param = null)
+        {
+            //UI_CompStoryLevelItem.Proxy(param as GObject).m_fightBg.visible = true;
+            _comEff.visible = true;
+            //_effFirst.visible = false;
         }
 
         private void OnClickLevelItem(EventContext context)

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

@@ -37,7 +37,7 @@ namespace GFGGame
                     {
                         index = 1;
                     }
-                    ViewManager.Show<StoryChapterListView>(new object[] { index }, null, true);
+                    ViewManager.Show<StoryChapterListView>(new object[] { index , levelCfg.order + 1}, null, true);
                 }
                 else
                 {