From bddf4df7cbb292011a974b705d6f6d94c0ac6cc1 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 09 十二月 2025 11:44:17 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/Component/UI/Common/FuncOpen.cs |  187 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 140 insertions(+), 47 deletions(-)

diff --git a/Main/Component/UI/Common/FuncOpen.cs b/Main/Component/UI/Common/FuncOpen.cs
index 52491df..1a575b9 100644
--- a/Main/Component/UI/Common/FuncOpen.cs
+++ b/Main/Component/UI/Common/FuncOpen.cs
@@ -1,8 +1,8 @@
 锘縰sing System;
-using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using LitJson;
+using System.Linq;
 
 public class FuncOpen
 {
@@ -92,7 +92,7 @@
     {
         for (int i = 0; i < vNetData.FuncCount; i++)
         {
-            
+
             var funcState = vNetData.FuncStateList[i];
 
             bool bPerFuncIsOpen = false;
@@ -109,6 +109,10 @@
                 funcOpenState[funcState.FuncID] = funcState.State == 1;
                 bAfterFuncIsOpen = funcOpenState[funcState.FuncID];
             }
+
+            awardStateDict[funcState.FuncID] = funcState.AwardState == 1;
+            UpdatePreviewRedpoint();
+
             if (OnFuncStateChangeEvent != null)
             {
                 OnFuncStateChangeEvent(funcState.FuncID);
@@ -118,7 +122,7 @@
 
     private bool IsFuncOpen(int key, out int errorCode)
     {
-        
+
         errorCode = 0;
         var config = FuncOpenLVConfig.Get(key);
         if (config == null)
@@ -129,7 +133,7 @@
         if (config.OpenDay > 0)
         {
             if (config.OpenDay > TimeUtility.OpenDay + 1)
-            { 
+            {
                 errorCode = 2;
                 return false;
             }
@@ -218,53 +222,11 @@
                         SysNotifyMgr.Instance.ShowStringTip(Language.Get("FuncLimit_Mission", TaskManager.Instance.GetNeedFinishTaskCount(config.LimitMissionID)));
                         break;
                     case 5:
-                        SysNotifyMgr.Instance.ShowStringTip(Language.Get("FuncLimit_ManLevel", config.ManLevel/10000, config.ManLevel/100%100, config.ManLevel%100));
+                        SysNotifyMgr.Instance.ShowStringTip(Language.Get("FuncLimit_ManLevel", config.ManLevel / 10000, config.ManLevel / 100 % 100, config.ManLevel % 100));
                         break;
                 }
             }
         }
-    }
-
-
-    public string GetErrorTip(int key)
-    {
-        if (!FuncOpenLVConfig.HasKey(key))
-            return string.Empty;
-        FuncOpenLVConfig config = FuncOpenLVConfig.Get(key);
-        if (!IsFuncOpen(key, out int errorCode))
-        {
-            switch (errorCode)
-            {
-                case 1:
-                    return Language.Get("FuncLimit_Level", config.LimitLV);
-                case 2:
-                    //寮�鏈嶅灏戝ぉ 涓�鑸槸缁勫悎
-                    if (config.LimitLV != 0)
-                    {
-                        return Language.Get("FuncLimit_OpenDay_LV", config.LimitLV, TimeUtility.OpenDay + 1, config.OpenDay);
-
-                    }
-                    else if (config.LimitMissionID != 0)
-                    {
-                        return Language.Get("FuncLimit_OpenDay_Mission", TaskManager.Instance.GetNeedFinishTaskCount(config.LimitMissionID), TimeUtility.OpenDay + 1, config.OpenDay);
-                    }
-                    else if (config.LimiRealmLV != 0)
-                    {
-                        return Language.Get("FuncLimit_OpenDay_Realm", RealmConfig.Get(config.LimiRealmLV).Name, TimeUtility.OpenDay + 1, config.OpenDay);
-                    }
-                    else
-                    {
-                        return Language.Get("FuncLimit_OpenDay", config.OpenDay);
-                    }
-                case 3:
-                    return Language.Get("FuncLimit_Realm", RealmConfig.Get(config.LimiRealmLV).Name);
-                case 4:
-                    return Language.Get("FuncLimit_Mission", TaskManager.Instance.GetNeedFinishTaskCount(config.LimitMissionID));
-                case 5:
-                    return Language.Get("FuncLimit_ManLevel", config.ManLevel/10000, config.ManLevel/100%100, config.ManLevel%100);
-            }
-        }
-        return string.Empty;
     }
 
     public int GetLimitLv(int key)
@@ -300,6 +262,137 @@
         }
         return true;
     }
+
+    #region 鍔熻兘棰勫憡
+    Dictionary<int, bool> awardStateDict = new Dictionary<int, bool>();
+
+    Dictionary<int, int> funcIndexDict = new Dictionary<int, int>();
+    public Dictionary<int, int> GetFuncIndexDict()
+    {
+        if (funcIndexDict.IsNullOrEmpty())
+        {
+            foreach (var funcId in FuncOpenLVConfig.GetKeys())
+            {
+                FuncOpenLVConfig config = FuncOpenLVConfig.Get(funcId);
+                if (config.PreviewIndex > 0)
+                {
+                    funcIndexDict[config.FuncId] = config.PreviewIndex;
+                }
+            }
+        }
+        return funcIndexDict;
+    }
+
+    public List<int> GetSortShowList()
+    {
+        List<int> sortShowList = new List<int>();
+        Dictionary<int, int> indexDict = GetFuncIndexDict();
+        // 鎸夌姸鎬佷紭鍏堢骇鎺掑簭锛氱姸鎬�1锛堝彲棰嗗彇锛�> 鐘舵��0锛堟湭瑙i攣锛�> 鐘舵��2锛堝凡棰嗗彇锛�
+        // 姣忕鐘舵�佸唴鎸� PreviewIndex 鍗囧簭锛岀浉鍚屽垯鎸� FuncId 鍗囧簭
+        sortShowList = indexDict
+            .Select(kv => new { FuncId = kv.Key, PreviewIndex = kv.Value, State = GetState(kv.Key) })
+                .OrderBy(x => x.State == 1 ? 0 : (x.State == 0 ? 1 : 2)) // 鏄犲皠浼樺厛绾э細1鈫�0, 0鈫�1, 2鈫�2
+                .ThenBy(x => x.PreviewIndex)
+                .ThenBy(x => x.FuncId)
+                .Select(x => x.FuncId)
+                .ToList();
+        return sortShowList;
+    }
+
+
+
+    //绗竴涓彲棰嗗彇鐨勭墿鍝佹墍鍦ㄨ绱㈠紩
+    public bool TryGetJumpIndex(out int index)
+    {
+        index = 0;
+        List<int> list = GetSortShowList();
+        if (list.IsNullOrEmpty())
+            return false;
+        for (int i = 0; i < list.Count; i++)
+        {
+            if (GetState(list[i]) == 1)
+            {
+                index = i;
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private bool IsAwardHave(int funcId)
+    {
+        return !awardStateDict.TryGetValue(funcId, out bool state) ? false : state;
+    }
+
+    // 0-鏈В閿� 1-鍙鍙� 2-宸查鍙�
+    public int GetState(int funcId)
+    {
+        if (IsAwardHave(funcId))
+            return 2;
+        return IsFuncOpen(funcId) ? 1 : 0;
+    }
+
+
+
+    public string GetErrorStr(int funcId)
+    {
+        if (!FuncOpenLVConfig.HasKey(funcId))
+            return string.Empty;
+        FuncOpenLVConfig config = FuncOpenLVConfig.Get(funcId);
+        List<string> conditionStrs = new List<string>();
+        if (config.LimitLV > 0)
+        {
+            conditionStrs.Add(Language.Get("FunctionPreviewErr01", config.LimitLV));
+        }
+
+        if (config.LimiRealmLV > 0)
+        {
+            conditionStrs.Add(Language.Get("FunctionPreviewErr02", RealmConfig.Get(config.LimiRealmLV).Name));
+        }
+
+        if (config.LimitMissionID > 0)
+        {
+            conditionStrs.Add(Language.Get("FunctionPreviewErr03", TaskManager.Instance.GetNeedFinishTaskCount(config.LimitMissionID)));
+        }
+
+        if (config.OpenDay > 0)
+        {
+            conditionStrs.Add(Language.Get("FunctionPreviewErr04", config.OpenDay));
+        }
+
+        if (config.ManLevel > 0)
+        {
+            conditionStrs.Add(Language.Get("FunctionPreviewErr05", config.ManLevel / 10000, config.ManLevel / 100 % 100, config.ManLevel % 100));
+        }
+
+        if (conditionStrs.Count == 0)
+        {
+            return string.Empty;
+        }
+        string connector = Language.Get("FunctionPreview01"); // "涓�"
+        string unlockStr = Language.Get("FunctionPreview02"); // "瑙i攣"
+        string result = string.Join(connector, conditionStrs) + unlockStr;
+        return result;
+    }
+
+    public void SendGetAward(int funcId)
+    {
+        var pack = new CA504_tagCMPlayerGetReward();
+        pack.RewardType = 17;
+        pack.DataEx = (uint)funcId;
+        GameNetSystem.Instance.SendInfo(pack);
+    }
+
+    Redpoint redpoint = new Redpoint(MainRedDot.RightFuncRedpoint, MainRedDot.FunctionPreviewRepoint);
+
+    public void UpdatePreviewRedpoint()
+    {
+        redpoint.state = RedPointState.None;
+        if (!TryGetJumpIndex(out int index))
+            return;
+        redpoint.state = RedPointState.Simple;
+    }
+    #endregion
 }
 
 public interface ICheckFuncOpen

--
Gitblit v1.8.0