Browse Source

添加套装图鉴红点判断

leiyasi 1 year ago
parent
commit
dc0665111b

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Controller/RedDotController.cs

@@ -25,6 +25,7 @@ namespace GFGGame
                 if (parentCom.GetChild("comResDot") != null)
                 {
                     comRedDot = parentCom.GetChild("comResDot").asCom;
+                    comRedDot.visible = true;
                     comRedDot.SetPosition(parentCom.width - comRedDot.width + left, top, 0);
 
                     return;

+ 18 - 0
GameClient/Assets/Game/HotUpdate/Data/RedDotDataManager.cs

@@ -110,6 +110,24 @@ namespace GFGGame
         }
 
         /// <summary>
+        /// 套装收集种类界面奖励可领
+        /// </summary>
+        /// <returns></returns>
+        public bool GetSuitGuideRed(int typeIndex)
+        {
+            List<int> _suitIds = SuitUtil.GetSuitIdList(false, true, typeIndex, 3); //全部已获得套装按照收集度高排序
+            for (int i = 0; i < _suitIds.Count; i++)
+            {
+                int status = DressUpMenuSuitDataManager.GetSuitGuideBonusStatus(_suitIds[i]);
+                if (status == ConstBonusStatus.CAN_GET)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
         /// 根据章节Id判断是否有奖励可领
         /// </summary>
         /// <returns></returns>

+ 12 - 4
GameClient/Assets/Game/HotUpdate/Utils/SuitUtil.cs

@@ -266,12 +266,20 @@ namespace GFGGame
             }
             if (typeId == 0)
             {
-                SuitCfg[] dataArray = SuitCfgArray.Instance.dataArray;
-                foreach (SuitCfg suitCfg in dataArray)
+                SuitGuideMenuCfg[] dataArray = SuitGuideMenuCfgArray.Instance.dataArray;
+                foreach (SuitGuideMenuCfg suitCfg in dataArray)
                 {
-                    if(suitCfg.id != 210000)//特殊处理,隐藏
+                    if (suitCfg.suitIds.Length > 0)
                     {
-                        CheckToAdd(suitCfg.id);
+                        string[] values = suitCfg.suitIds.Split(';');
+                        foreach (string value in values)
+                        {
+                            if (value.Length > 0)
+                            {
+                                int suitId = int.Parse(value);
+                                CheckToAdd(suitId);
+                            }
+                        }
                     }
                 }
             }

+ 41 - 12
GameClient/Assets/Game/HotUpdate/Views/FieldGuide/FieldGuideView.cs

@@ -74,13 +74,38 @@ namespace GFGGame
         }
         private void OnClickBtnBack()
         {
-            // this.Hide();
             _startInAnim = true;
             ViewManager.GoBackFrom(ViewName.FIELD_GUIDE_VIEW);
+            HideAllRedDot();
         }
+
         private void UpdateList()
         {
             _ui.m_listGuide.numItems = _listGuideDatas.Length;
+            UpdateRedDot();
+        }
+
+        private void UpdateRedDot()
+        {
+            int num = _ui.m_listGuide.numChildren;
+            for (int i = 0; i < num; i++)
+            {
+                UI_CompGuideItem listItem = UI_CompGuideItem.Proxy(_ui.m_listGuide.GetChildAt(i));
+
+                bool red = actions[i] == null ? false : actions[i]();
+                RedDotController.Instance.SetComRedDot(listItem.target, red, "", -46, 51);
+
+                UI_CompGuideItem.ProxyEnd();
+            }
+        }
+
+        private void HideAllRedDot()
+        {
+            int num = _ui.m_listGuide.numChildren;
+            for (int i = 0; i < num; i++)
+            {
+                RedDotController.Instance.SetComRedDot(_ui.m_listGuide.GetChildAt(i).asCom, false);
+            }
         }
 
         private void ListGuideItemRenderer(int index, GObject item)
@@ -89,13 +114,12 @@ namespace GFGGame
             int id = _listGuideDatas[index];
             listItem.m_loaderPic.url = "ui://FieldGuide/tujian_tup_" + id;
             listItem.target.data = id;
-            bool red = actions[index] == null ? false : actions[index]();
-            RedDotController.Instance.SetComRedDot(listItem.target, red, "", -46, 51);
+
+
             if (_startInAnim)
             {
                 listItem.m_Init.Play();
             }
-
             UI_CompGuideItem.ProxyEnd();
         }
 
@@ -159,23 +183,28 @@ namespace GFGGame
             {
                 UI_CompGuideItem listItem = UI_CompGuideItem.Proxy(_ui.m_listGuide.GetChildAt(i));
                 int id = (int)listItem.target.data;
-                int haveCount = 0;
-                int totalCount = 1;
-                GetGuideProgress(id, out haveCount, out totalCount);
+                GetGuideProgress(id, out int haveCount, out int totalCount);
                 decimal value = ProgressCalculate(haveCount, totalCount);
                 listItem.m_txtProgress.text = value.ToString();
                 if (playAnim)
                 {
-                    listItem.m_In.Play();
+                    Action complete = null;
                     // µ¹ÊýµÚ¶þ¸ö
-                    if (i == num - 2)
+                    if (i == num - 1)
                     {
-                        yield return new WaitForSeconds(0.02f);
+                        yield return new WaitForSeconds(0.03f);
+                        complete = UpdateRedDot;
                     }
-                    else if (i < num - 2)
+                    else if(i > 0)
                     {
-                        yield return new WaitForSeconds(0.05f);
+                        yield return new WaitForSeconds(0.06f);
                     }
+
+                    listItem.m_In.Play(() =>
+                    {
+                        complete?.Invoke();
+                    });
+
                 }
                 UI_CompGuideItem.ProxyEnd();
             }

+ 111 - 11
GameClient/Assets/Game/HotUpdate/Views/FieldGuide/SuitGuideView.cs

@@ -4,14 +4,14 @@ using UI.CommonGame;
 using System.Collections.Generic;
 using UI.ClothingSynthetic;
 using UnityEngine;
+using System.Collections;
 
 namespace GFGGame
 {
     public class SuitGuideView : BaseWindow
     {
         private UI_SuitGuideUI _ui;
-        private Dictionary<int,List<int>> _menuTypeAllDataDic;
-        private string[] _suitTypeList = { "套装", "故事" };
+        private Dictionary<int, List<int>> _menuTypeAllDataDic;
         private List<UI_SuitTypeItem> _suitTypeItems;
 
         public override void Dispose()
@@ -34,13 +34,13 @@ namespace GFGGame
             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjbg");
 
             _ui.m_suitTypeList.itemRenderer = RenderListSuitType;
-            _ui.m_suitTypeList.numItems = _suitTypeList.Length;
+            _ui.m_suitTypeList.numItems = _ui.m_suitTypeList.numItems;
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
             _ui.m_suitType2Items.itemRenderer = RenderListSuitType2Item;
             _ui.m_suitType2Items.onClickItem.Add(OnClickListSuitType2Item);
             _ui.m_suitTypeList.onClick.Add(OnClickListSuitType);
             InitSuitGuideType();
-            SetType(1);
+            UpdateItemsByType(1);
 
         }
         protected override void AddEventListener()
@@ -51,6 +51,8 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
+            UpdateListSuitTypeRedDots();
+            Timers.inst.StartCoroutine(UpdateRedDot());
         }
 
         protected override void OnHide()
@@ -63,7 +65,7 @@ namespace GFGGame
             EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
         }
 
-        private void SetType(int type)
+        private void UpdateItemsByType(int type)
         {
             _ui.m_c1.SetSelectedIndex(type - 1);
 
@@ -84,7 +86,7 @@ namespace GFGGame
 
             _menuTypeAllDataDic = new Dictionary<int, List<int>>();
             SuitGuideMenuCfg[] menuCfgs = SuitGuideMenuCfgArray.Instance.dataArray;
-            foreach(SuitGuideMenuCfg s in menuCfgs)
+            foreach (SuitGuideMenuCfg s in menuCfgs)
             {
                 if (!_menuTypeAllDataDic.ContainsKey(s.SuitGuideMenuType))
                 {
@@ -159,28 +161,126 @@ namespace GFGGame
         }
 
         /// <summary>
-        /// 初始化上方选择菜单
+        /// 初始化上方选择菜单,同步按钮按下和普通状态的文本
         /// </summary>
         /// <param name="index"></param>
         /// <param name="item"></param>
         private void RenderListSuitType(int index, GObject item)
         {
             UI_Button6 button6 = UI_Button6.Proxy(item);
-            button6.m_title1.text = _suitTypeList[index];
-            button6.target.title = _suitTypeList[index];
+            button6.m_title1.text = button6.target.title;
             UI_Button6.ProxyEnd();
         }
 
         private void OnClickListSuitType(EventContext eventContext)
         {
-            SetType(_ui.m_c1.selectedIndex + 1);
+            UpdateItemsByType(_ui.m_c1.selectedIndex + 1);
+            Timers.inst.StartCoroutine(UpdateRedDot());
+        }
+
+        /// <summary>
+        /// 更新选择菜单的红点
+        /// </summary>
+        private void UpdateListSuitTypeRedDots()
+        {
+            for (int j = 0; j < _ui.m_suitTypeList.numItems; j++)
+            {
+                RedDotController.Instance.SetComRedDot(_ui.m_suitTypeList.GetChildAt(j).asCom, false);
+                for (int i = 0; i < _menuTypeAllDataDic[j + 1].Count; i++)
+                {
+                    bool red = RedDotDataManager.Instance.GetSuitGuideRed(_menuTypeAllDataDic[j + 1][i]);
+                    if (red)
+                    {
+                        RedDotController.Instance.SetComRedDot(_ui.m_suitTypeList.GetChildAt(j).asCom, red, "", -65, 16);
+                        break;
+                    }
+                }
+            }
         }
 
         private void OnClickBtnBack()
         {
-            SetType(1);
+            UpdateItemsByType(1);
             _ui.m_suitTypeItems.target.scrollPane.ScrollTop();
             ViewManager.GoBackFrom(ViewName.SUIT_GUIDE_VIEW);
         }
+
+        private IEnumerator UpdateRedDot()
+        {
+            int selectedIndex = _ui.m_c1.selectedIndex + 1;
+
+            // Hide all existed red dots
+            HideSelectedPageRedDot();
+
+            Transition t = null;
+            switch (selectedIndex)
+            {
+                case 1:
+                    t = _ui.m_suitTypeItems.m_In;
+                    break;
+                case 2:
+                    UI_SuitStoryItem listItem = UI_SuitStoryItem.Proxy(_ui.m_suitType2Items.GetChildAt(_ui.m_suitType2Items.numItems - 1));
+                    t = listItem.m_In;
+                    UI_SuitStoryItem.ProxyEnd();
+                    break;
+            }
+
+            // Wait anim auto play
+            yield return null;
+
+            // Wait anim finished
+            while (t.playing)
+            {
+                yield return null;
+            }
+
+            // Show red dots
+            int num;
+
+            switch (selectedIndex)
+            {
+                case 1:
+                    num = _suitTypeItems.Count;
+                    for (int i = 0; i < num; i++)
+                    {
+                        bool red = RedDotDataManager.Instance.GetSuitGuideRed(_menuTypeAllDataDic[selectedIndex][i]);
+                        RedDotController.Instance.SetComRedDot(_suitTypeItems[i].target, red, "", -254, 130);
+                    }
+                    break;
+                case 2:
+                    num = _ui.m_suitType2Items.numItems;
+                    for (int i = 0; i < num; i++)
+                    {
+                        bool red = RedDotDataManager.Instance.GetSuitGuideRed(_menuTypeAllDataDic[selectedIndex][i]);
+                        RedDotController.Instance.SetComRedDot(_ui.m_suitType2Items.GetChildAt(i).asCom, red, "", -852, 45);
+                    }
+                    break;
+            }
+
+        }
+
+        private void HideSelectedPageRedDot()
+        {
+            int num;
+            int selectedIndex = _ui.m_c1.selectedIndex + 1;
+
+            switch (selectedIndex)
+            {
+                case 1:
+                    num = _suitTypeItems.Count;
+                    for (int i = 0; i < num; i++)
+                    {
+                        RedDotController.Instance.SetComRedDot(_suitTypeItems[i].target.asCom, false);
+                    }
+                    break;
+                case 2:
+                    num = _ui.m_suitType2Items.numItems;
+                    for (int i = 0; i < num; i++)
+                    {
+                        RedDotController.Instance.SetComRedDot(_ui.m_suitType2Items.GetChildAt(i).asCom, false);
+                    }
+                    break;
+            }
+        }
     }
 }

BIN
GameClient/Assets/ResIn/UI/FieldGuide/FieldGuide_fui.bytes