From bae41593e19d32046f77ed1f036089e015380b99 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 30 七月 2025 22:25:18 +0800
Subject: [PATCH] 117 【武将】武将系统 - 布阵临时版

---
 Main/Component/UI/Common/DragItem.cs      |  124 ++++++--
 Main/Component/UI/Common/DragContainer.cs |    7 
 Main/System/Hero/UIHeroController.cs      |    2 
 Main/System/Team/TeamConst.cs             |    5 
 Main/Core/GameEngine/Common/Equation.cs   |  157 +++++-----
 Main/System/Team/TeamType.cs              |    6 
 Main/Utility/ComponentExtersion.cs        |    1 
 Main/System/HeroUI/HeroPosWin.cs          |  152 ++++++++++
 Main/System/Team/TeamManager.cs           |   10 
 Main/System/HeroUI/HeroScenePosCell.cs    |   62 ++++
 Main/System/Hero/HeroManager.cs           |   13 
 Main/System/Team/TeamBase.cs              |   68 +++-
 Main/System/Team/TeamHero.cs              |   11 
 Main/Config/ConfigParse.cs                |   62 +++-
 Main/System/HeroUI/HeroPosHeadCell.cs     |   39 ++
 Main/System/HeroUI/HeroHeadBaseCell.cs    |    2 
 Main/System/HeroUI/HeroSelectBehaviour.cs |    4 
 Main/System/HeroUI/HeroUIManager.cs       |  107 ++++++
 18 files changed, 629 insertions(+), 203 deletions(-)

diff --git a/Main/Component/UI/Common/DragContainer.cs b/Main/Component/UI/Common/DragContainer.cs
index 175d1fa..d10b95d 100644
--- a/Main/Component/UI/Common/DragContainer.cs
+++ b/Main/Component/UI/Common/DragContainer.cs
@@ -6,11 +6,12 @@
 using System.Collections;
 
 
-    public class DragContainer:MonoBehaviour {
+public class DragContainer : MonoBehaviour
+{
 
+    public int pos;
 
-
-    }
+}
 
 
 
diff --git a/Main/Component/UI/Common/DragItem.cs b/Main/Component/UI/Common/DragItem.cs
index 22b102b..7cfee77 100644
--- a/Main/Component/UI/Common/DragItem.cs
+++ b/Main/Component/UI/Common/DragItem.cs
@@ -1,4 +1,4 @@
-锘�//--------------------------------------------------------
+//--------------------------------------------------------
 //    [Author]:           鐜╀釜娓告垙
 //    [  Date ]:           Monday, July 31, 2017
 //--------------------------------------------------------
@@ -6,53 +6,103 @@
 using System.Collections;
 using UnityEngine.EventSystems;
 using System;
+using UnityEngine.Events;
 
-    public class DragItem:MonoBehaviour,ICanvasRaycastFilter,IBeginDragHandler,IDragHandler,IEndDragHandler {
+/// <summary>
+/// 鎷栨嫿缁勪欢锛屽疄鐜版嫋鎷藉姛鑳藉苟闄愬埗鎷栨嫿鑼冨洿
+/// </summary>
+public class DragItem:MonoBehaviour,ICanvasRaycastFilter,IBeginDragHandler,IDragHandler,IEndDragHandler 
+{
+    // 鎷栨嫿鍖哄煙闄愬埗
+    [SerializeField]
+    RectTransform m_Area;
+    public RectTransform area { get { return m_Area; } }
 
-        [SerializeField]
-        RectTransform m_Area;
-        public RectTransform area { get { return m_Area; } }
+    // 鏄惁鍏佽灏勭嚎妫�娴�
+    [SerializeField]
+    bool m_RaycastTarget = true;
+    public bool raycastTarget {
+        get { return m_RaycastTarget; }
+        private set { m_RaycastTarget = value; }
+    }
 
-        [SerializeField]
-        bool m_RaycastTarget = true;
-        public bool raycastTarget {
-            get { return m_RaycastTarget; }
-            private set { m_RaycastTarget = value; }
-        }
+    [SerializeField] public int pos;
 
-        RectTransform m_RectTransform;
-        public RectTransform rectTransform { get { return this.transform as RectTransform; } }
+    private Vector3 orgScale;
 
-        public void OnBeginDrag(PointerEventData eventData) {
-            raycastTarget = false;
-            this.transform.position = UIUtility.ClampWorldPosition(area,eventData);
-        }
+    // 褰撳墠瀵硅薄鐨凴ectTransform缁勪欢
+    public RectTransform rectTransform { get { return this.transform as RectTransform; } }
 
-        public void OnDrag(PointerEventData eventData) {
-            this.transform.position = UIUtility.ClampWorldPosition(area,eventData);
-        }
+    /// <summary>
+    /// 寮�濮嬫嫋鎷芥椂璋冪敤
+    /// </summary>
+    public void OnBeginDrag(PointerEventData eventData)
+    {
+        raycastTarget = false;
+        this.transform.position = UIUtility.ClampWorldPosition(area, eventData);
+        orgScale = rectTransform.localScale;
+        rectTransform.localScale = orgScale * 1.2f;
+    }
 
-        public void OnEndDrag(PointerEventData eventData) {
-            raycastTarget = true;
-            if(eventData.pointerEnter == null) {
-                return;
+    /// <summary>
+    /// 鎷栨嫿杩囩▼涓皟鐢�
+    /// </summary>
+    public void OnDrag(PointerEventData eventData) {
+        this.transform.position = UIUtility.ClampWorldPosition(area,eventData);
+        
+        // 妫�娴嬫槸鍚﹁繘鍏ョ洰鏍囧尯鍩�
+        if (eventData.pointerEnter != null) {
+            var target = eventData.pointerEnter.transform;
+            if (target != null) {
+                // 杩涘叆鐩爣鍖哄煙锛屾斁澶� 1.2 鍊�
+                target.localScale = Vector3.one * 1.2f;
             }
-
-            var container = eventData.pointerEnter.GetComponent<DragContainer>();
-            if(container == null) {
-                return;
+        } else {
+            // 绂诲紑鐩爣鍖哄煙锛屾仮澶嶅ぇ灏�
+            if (eventData.pointerPress != null) {
+                var target = eventData.pointerPress.transform;
+                if (target != null) {
+                    target.localScale = Vector3.one;
+                }
             }
-
-            var contain = UIUtility.RectTransformContain(eventData.pointerEnter.transform as RectTransform,rectTransform);
-            if(contain) {
-                rectTransform.position = eventData.pointerEnter.transform.position;
-            }
-        }
-
-        public bool IsRaycastLocationValid(Vector2 sp,Camera eventCamera) {
-            return raycastTarget;
         }
     }
 
+    /// <summary>
+    /// 缁撴潫鎷栨嫿鏃惰皟鐢�
+    /// </summary>
+    public Action<int, int> onEndDragEvent;
+
+    public void OnEndDrag(PointerEventData eventData) {
+        raycastTarget = true;
+        rectTransform.localScale = orgScale;
+        
+        if (eventData.pointerEnter == null)
+        {
+            onEndDragEvent?.Invoke(pos, -1);
+            return;
+        }
+
+        var container = eventData.pointerEnter.GetComponent<DragContainer>();
+        if(container == null) {
+            onEndDragEvent?.Invoke(pos, -1);
+            return;
+        }
+
+        // var contain = UIUtility.RectTransformContain(eventData.pointerEnter.transform as RectTransform,rectTransform);
+        // if(contain) {
+        //     rectTransform.position = eventData.pointerEnter.transform.position;
+        // }
+        onEndDragEvent?.Invoke(pos, container.pos);
+    }
+
+    /// <summary>
+    /// 鍒ゆ柇灏勭嚎妫�娴嬫槸鍚︽湁鏁�
+    /// </summary>
+    public bool IsRaycastLocationValid(Vector2 sp,Camera eventCamera) {
+        return raycastTarget;
+    }
+}
+
 
 
diff --git a/Main/Config/ConfigParse.cs b/Main/Config/ConfigParse.cs
index 4ad01b1..355e980 100644
--- a/Main/Config/ConfigParse.cs
+++ b/Main/Config/ConfigParse.cs
@@ -187,31 +187,53 @@
         }
 
         s = s.Replace(" ", string.Empty);
-        if (!userDataRegex.IsMatch(s))
-        {
+
+
+        var dict = JsonMapper.ToObject<Dictionary<string, string[]>>(s);
+
+        if (dict == null || dict.Count == 0)
             return null;
-        }
-        else
+
+        Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();
+
+        foreach (var item in dict)
         {
-            Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
-            foreach (Match match in userDataRegex.Matches(s))
+            List<int> list = new List<int>();
+            for (int i = 0; i < item.Value.Length; i++)
             {
-                int id = int.Parse(match.Groups[1].Value);
-                string str = match.Groups[2].Value;
-                string[] vals = str.Split(',');
-                List<int> list = new List<int>();
-                for (int i = 0; i < vals.Length; i++)
-                {
-                    int intval = int.Parse(vals[i].Replace('\'', ' '));
-                    list.Add(intval);
-                }
-                if (!dics.ContainsKey(id))
-                {
-                    dics.Add(id, list);
-                }
+                list.Add(int.Parse(item.Value[i]));
             }
-            return dics;
+            if (list.Count != 0)
+                result[int.Parse(item.Key)] = list;
         }
+
+        return result;
+
+        //if (!userDataRegex.IsMatch(s))
+        //{
+        //    return null;
+        //}
+        //else
+        //{
+        //    Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
+        //    foreach (Match match in userDataRegex.Matches(s))
+        //    {
+        //        int id = int.Parse(match.Groups[1].Value);
+        //        string str = match.Groups[2].Value;
+        //        string[] vals = str.Split(',');
+        //        List<int> list = new List<int>();
+        //        for (int i = 0; i < vals.Length; i++)
+        //        {
+        //            int intval = int.Parse(vals[i].Replace('\'', ' '));
+        //            list.Add(intval);
+        //        }
+        //        if (!dics.ContainsKey(id))
+        //        {
+        //            dics.Add(id, list);
+        //        }
+        //    }
+        //    return dics;
+        //}
     }
 
     public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr)
diff --git a/Main/Core/GameEngine/Common/Equation.cs b/Main/Core/GameEngine/Common/Equation.cs
index 31445db..9fd64c8 100644
--- a/Main/Core/GameEngine/Common/Equation.cs
+++ b/Main/Core/GameEngine/Common/Equation.cs
@@ -1,4 +1,4 @@
-锘縰sing System;
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
@@ -6,15 +6,30 @@
 using UnityEngine;
 
  
+/// <summary>
+/// 鍏紡璁$畻妯″潡锛屾敮鎸佸姩鎬佸彉閲忔浛鎹㈠拰澶氱杩愮畻绗﹁绠椼��
+/// </summary>
 public class Equation : Singleton<Equation>
 {
+    /// <summary>
+    /// 鏀寔鐨勮繍绠楃鍒楄〃銆�
+    /// </summary>
     public static readonly List<char> operatorList = new List<char>() { '*', '-', '+', '/', '^', '!', '@', '%', ';', '#', '$', '~', '&' };
 
+    /// <summary>
+    /// 鐢ㄤ簬涓存椂瀛楃涓叉瀯寤虹殑鍏变韩瀹炰緥銆�
+    /// </summary>
     public static StringBuilder textBuilder = new StringBuilder();
 
+    /// <summary>
+    /// 瀛樺偍鍙橀噺鍚嶅拰鍊肩殑閿�煎鍒楄〃銆�
+    /// </summary>
     private List<KeyValuePair<string, string>> keyValueDic = new List<KeyValuePair<string, string>>();
 
-    public readonly Regex replaecRegex = new Regex(@"[a-zA-Z]{2,50}");
+    /// <summary>
+    /// 鐢ㄤ簬鍖归厤鍙橀噺鍚嶇殑姝e垯琛ㄨ揪寮忋��
+    /// </summary>
+    public static readonly Regex replaecRegex = new Regex(@"[a-zA-Z]{2,50}");
 
     public T Eval<T>(string equation) where T : struct
     {
@@ -34,6 +49,11 @@
         return val;
     }
 
+    /// <summary>
+    /// 鏇挎崲鍏紡涓殑鍙橀噺鍚嶄负瀵瑰簲鐨勫�笺��
+    /// </summary>
+    /// <param name="equation">鍘熷鍏紡瀛楃涓层��</param>
+    /// <returns>鏇挎崲鍚庣殑鍏紡瀛楃涓层��</returns>
     private string GetEquation(string equation)
     {
         try
@@ -41,35 +61,30 @@
             MatchCollection matchArray = replaecRegex.Matches(equation);
             textBuilder.Length = 0;
             int length = 0;
+
             if (matchArray != null)
             {
-                for (int i = 0; i < matchArray.Count; i++)
+                foreach (Match match in matchArray)
                 {
-                    Match match = matchArray[i];
-                    textBuilder.Append(equation.Substring(length, match.Index - length));
+                    // 娣诲姞闈炲彉閲忛儴鍒�
+                    textBuilder.Append(equation, length, match.Index - length);
                     length = match.Index + match.Length;
-                    bool _replace = false;
-                    for (int j = 0; j < keyValueDic.Count; j++)
-                    {
-                        if (match.Value.Equals(keyValueDic[j].Key))
-                        {
-                            textBuilder.Append(keyValueDic[j].Value);
-                            _replace = true;
-                            break;
-                        }
-                    }
-                    if (!_replace)
-                    {
-                        textBuilder.Append(0);
-                    }
+
+                    // 鏌ユ壘鍙橀噺瀵瑰簲鐨勫��
+                    var foundPair = keyValueDic.Find(x => x.Key.Equals(match.Value));
+                    string replacement = foundPair.Equals(default(KeyValuePair<string, string>)) ? "0" : foundPair.Value;
+                    textBuilder.Append(replacement ?? "0");
                 }
             }
-            textBuilder.Append(equation.Substring(length, equation.Length - length));
+
+            // 娣诲姞鍓╀綑閮ㄥ垎
+            textBuilder.Append(equation, length, equation.Length - length);
         }
         catch (Exception e)
         {
-            Debug.Log(e.Message);
+            Debug.LogError($"鍏紡鍙橀噺鏇挎崲澶辫触: {e.Message}");
         }
+
         return textBuilder.ToString();
     }
 
@@ -129,6 +144,9 @@
             }
             return false;
         }
+        /// <summary>
+        /// 瑙f瀽鍏紡涓殑瀛愯〃杈惧紡锛堟嫭鍙峰唴鐨勯儴鍒嗭級銆�
+        /// </summary>
         private void Subsection()
         {
             try
@@ -137,39 +155,37 @@
                 int startIndex = 0;
                 int length = 0;
                 int index = 0;
+
                 for (int i = 0; i < equation.Length; i++)
                 {
                     if (equation[i] == '(')
                     {
-                        i = i + 1;
+                        i++;
                         startIndex = i;
+
+                        // 鎻愬彇鎷彿鍐呯殑瀛愯〃杈惧紡
                         while (i < equation.Length && (equation[i] != ')' || bracketCnt > 0))
                         {
-                            if (equation[i] == '(')
-                            {
-                                bracketCnt++;
-                            }
-                            else if (equation[i] == ')')
-                            {
-                                bracketCnt--;
-                            }
+                            if (equation[i] == '(') bracketCnt++;
+                            else if (equation[i] == ')') bracketCnt--;
                             length++;
-                            i = i + 1;
+                            i++;
                         }
+
+                        // 澶勭悊瀛愯〃杈惧紡
                         subEquations.Add(new EquationParse(equation.Substring(startIndex, length)));
-                        length = 0;
-                        equationBuilder.Append('=');
-                        equationBuilder.Append(index);
-                        equationBuilder.Append('=');
+                        equationBuilder.Append($"={index}=");
                         index++;
+                        length = 0;
                         continue;
                     }
+
                     equationBuilder.Append(equation[i]);
                 }
             }
             catch (Exception e)
             {
-                Debug.Log(e.Message);
+                Debug.LogError($"瀛愯〃杈惧紡瑙f瀽澶辫触: {e.Message}");
             }
         }
 
@@ -270,57 +286,38 @@
             }
         }
 
+        /// <summary>
+        /// 鏍规嵁杩愮畻绗︾被鍨嬭绠楃粨鏋溿��
+        /// </summary>
+        /// <param name="leftValue">宸︽搷浣滄暟銆�</param>
+        /// <param name="rightValue">鍙虫搷浣滄暟銆�</param>
+        /// <param name="operatorType">杩愮畻绗︾被鍨嬨��</param>
+        /// <returns>璁$畻缁撴灉銆�</returns>
         public static double GetResult(string leftValue, string rightValue, OperatorType operatorType)
         {
-            double _leftValue = 0, _rightValue = 0;
-            try
+            if (!double.TryParse(leftValue, out double _leftValue) || !double.TryParse(rightValue, out double _rightValue))
             {
-                double.TryParse(leftValue, out _leftValue);
-                double.TryParse(rightValue, out _rightValue);
+                Debug.LogError($"鏃犳硶灏嗗瓧绗︿覆杞崲涓烘暟鍊�: {leftValue} 鎴� {rightValue}");
+                return 0;
             }
-            catch (Exception)
-            {
-                Debug.LogErrorFormat("瀛楃涓蹭笉鑳借浆涓烘暟鍊納0}   {1}", leftValue, rightValue);
-            }
+
             switch (operatorType)
             {
-                case OperatorType.Plus:
-                    return _leftValue + _rightValue;
-                case OperatorType.Subtract:
-                    return _leftValue - _rightValue;
-                case OperatorType.Ride:
-                    return _leftValue * _rightValue;
-                case OperatorType.Divide:
-                    if (_rightValue == 0)
-                    {
-                        _rightValue = 1;
-                    }
-                    return _leftValue / _rightValue;
-                case OperatorType.Pow:
-                    return Math.Pow(_leftValue, _rightValue);
-                case OperatorType.Min:
-                    return Math.Min(_leftValue, _rightValue);
-                case OperatorType.Max:
-                    return Math.Max(_leftValue, _rightValue);
-                case OperatorType.Remain:
-                    return _leftValue % _rightValue;
-                case OperatorType.Random:
-                    {
-                        return UnityEngine.Random.Range((float)_leftValue, (float)_rightValue);
-                    }
-                case OperatorType.Floor:
-                    return Math.Floor(_leftValue);
-                case OperatorType.Ceil:
-                    return Math.Ceiling((float)_leftValue);
-                case OperatorType.RandomInt:
-                    {
-                        return UnityEngine.Random.Range((int)_leftValue, (int)_rightValue);
-                    }
-                case OperatorType.Sqrt:
-                    return Math.Sqrt(_leftValue);
-
+                case OperatorType.Plus:      return _leftValue + _rightValue;
+                case OperatorType.Subtract:  return _leftValue - _rightValue;
+                case OperatorType.Ride:      return _leftValue * _rightValue;
+                case OperatorType.Divide:    return _rightValue == 0 ? _leftValue : _leftValue / _rightValue;
+                case OperatorType.Pow:       return Math.Pow(_leftValue, _rightValue);
+                case OperatorType.Min:       return Math.Min(_leftValue, _rightValue);
+                case OperatorType.Max:       return Math.Max(_leftValue, _rightValue);
+                case OperatorType.Remain:    return _leftValue % _rightValue;
+                case OperatorType.Random:    return UnityEngine.Random.Range((float)_leftValue, (float)_rightValue);
+                case OperatorType.Floor:     return Math.Floor(_leftValue);
+                case OperatorType.Ceil:      return Math.Ceiling((float)_leftValue);
+                case OperatorType.RandomInt: return UnityEngine.Random.Range((int)_leftValue, (int)_rightValue);
+                case OperatorType.Sqrt:      return Math.Sqrt(_leftValue);
+                default:                     return 0;
             }
-            return 0;
         }
         public static OperatorType GetOperatorType(char _operator)
         {
diff --git a/Main/System/Hero/HeroManager.cs b/Main/System/Hero/HeroManager.cs
index e1311d0..af90076 100644
--- a/Main/System/Hero/HeroManager.cs
+++ b/Main/System/Hero/HeroManager.cs
@@ -90,10 +90,17 @@
     {
         return heroInfoDict.Values.ToList();
     }
-    
-    public List<string> GetHeroGuidList()
+
+    public List<string> GetHeroGuidList(int job = 0, int country = 0)
     {
-        return heroInfoDict.Keys.ToList();
+        if (job == 0 && country == 0)
+            return heroInfoDict.Keys.ToList();
+            
+        return heroInfoDict.Keys.Where((x) =>
+        {
+            HeroInfo heroInfo = heroInfoDict[x];
+            return heroInfo.heroConfig.Class == job && heroInfo.heroConfig.Country == country;
+        }).ToList();
     }
 
     public List<HeroInfo> GetPowerfulHeroList()
diff --git a/Main/System/Hero/UIHeroController.cs b/Main/System/Hero/UIHeroController.cs
index 0ed25fe..c2291e3 100644
--- a/Main/System/Hero/UIHeroController.cs
+++ b/Main/System/Hero/UIHeroController.cs
@@ -35,7 +35,7 @@
 			instanceGO = pool.Request();
 			instanceGO.transform.SetParent(transform);
 			//transform 鐨凱ivot Y鏄�0锛岃instanceGO 灞呬腑
-			instanceGO.transform.localPosition = new Vector3(0, transform.GetComponent<RectTransform>().sizeDelta.y * 0.5f);
+			instanceGO.transform.localPosition = new Vector3(0, instanceGO.GetComponent<RectTransform>().sizeDelta.y * 0.5f);
 
 			//instanceGO.transform.localPosition = Vector3.zero;
 			instanceGO.transform.localScale = Vector3.one;
diff --git a/Main/System/HeroUI/HeroHeadBaseCell.cs b/Main/System/HeroUI/HeroHeadBaseCell.cs
index ecd7d68..f4f83d6 100644
--- a/Main/System/HeroUI/HeroHeadBaseCell.cs
+++ b/Main/System/HeroUI/HeroHeadBaseCell.cs
@@ -195,7 +195,7 @@
         }
 
         countryImg.SetSprite("herocountry" + heroConfig.Country);
-        lvText.text = lv.ToString();
+        lvText.text = lv == 0 ? "": Language.Get("L1094") + lv;
 
         awakeLvRect.SetActive(awakelv > 0);
         awakeLvText.text = awakelv.ToString();
diff --git a/Main/System/HeroUI/HeroPosHeadCell.cs b/Main/System/HeroUI/HeroPosHeadCell.cs
index d0cfd2d..2eb1b0a 100644
--- a/Main/System/HeroUI/HeroPosHeadCell.cs
+++ b/Main/System/HeroUI/HeroPosHeadCell.cs
@@ -1,4 +1,5 @@
-锘縰sing UnityEngine;
+锘縰sing System.Collections.Generic;
+using UnityEngine;
 using UnityEngine.UI;
 
 public class HeroPosHeadCell : MonoBehaviour
@@ -10,7 +11,43 @@
 
     public void Display(int index)
     {
+        var guid = HeroUIManager.Instance.heroOnTeamSortList[index];
+        var hero = HeroManager.Instance.GetHero(guid);
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        selectRect.SetActive(team.GetHero(guid) != null);
 
+        heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, () =>
+        {
+            Click(hero, index);
+        });
+        nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel);
+        
+        jobImg.SetSprite("herojob" + hero.heroConfig.Class);
+    }
+
+    void Click(HeroInfo hero, int index)
+    {
+        //妫�鏌ユ槸鍚﹀彲涓婇樀锛屾煡鎵句笂闃典綅缃紝鏄剧ず鍕鹃�夛紝椋炲叆涓婇樀浣嶇疆
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        int pos;
+        if (selectRect.gameObject.activeSelf)
+        {
+            selectRect.SetActive(false);
+            if (team.RemoveHero(hero, out pos))
+            { 
+                //閫氱煡鍒锋柊锛堜笅闃碉級
+                HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos }, -1, Vector3.zero);
+            }
+            return;
+        }
+
+        team.AddHero(hero, out pos);
+        if (pos != -1)
+        {
+            selectRect.SetActive(true);
+            //閫氱煡鍒锋柊锛屼笂闃碉紝鍥剧墖椋炲叆锛堜笂闃典綅缃級
+            HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos }, index, heroHeadBaseCell.transform.position);
+        }
     }
 }
 
diff --git a/Main/System/HeroUI/HeroPosWin.cs b/Main/System/HeroUI/HeroPosWin.cs
index 1b0d552..473db70 100644
--- a/Main/System/HeroUI/HeroPosWin.cs
+++ b/Main/System/HeroUI/HeroPosWin.cs
@@ -2,9 +2,10 @@
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
+using DG.Tweening;
 
 /// <summary>
-/// 姝﹀皢甯冮樀: functionOrder锛氬竷闃电被鍨�
+/// 姝﹀皢甯冮樀: 濡傛灉鍙互鍚屾椂鎵撳紑澶氫釜甯冮樀鐣岄潰 鍒欎娇鐢� functionOrder锛氬竷闃电被鍨�
 /// </summary>
 public class HeroPosWin : UIBase
 {
@@ -21,6 +22,7 @@
     [SerializeField] ScrollerController heroListScroller;
     [SerializeField] Transform heroListEmpty;
     [SerializeField] Toggle showConnTipToggleBtn;
+    private bool isToggleOn = false;
     [SerializeField] HeroSelectBehaviour fiterManager;  //姝﹀皢绛涢��
 
     [SerializeField] Button oneKeyOnBtn;     //涓�閿笂闃�
@@ -32,7 +34,10 @@
 
     //缇佺粖
     [SerializeField] HeroConnectionCell connetionForm;
+    [SerializeField] HeroHeadBaseCell flyHead;
+    [SerializeField] CanvasGroup flyAlphaTween;
 
+    Sequence sequence;
 
     protected override void InitComponent()
     {
@@ -43,7 +48,7 @@
                 return;
             }
 
-            HeroUIManager.Instance.selectTeamType = TeamType.Arena;
+            HeroUIManager.Instance.selectTeamType = (TeamType)HeroUIManager.Instance.GetSelectTeamTypeByAttackType(0);
             Refresh();
         });
         defendTeamBtn.AddListener(() =>
@@ -52,15 +57,26 @@
             {
                 return;
             }
-            HeroUIManager.Instance.selectTeamType = TeamType.ArenaDefense;
+            HeroUIManager.Instance.selectTeamType = (TeamType)HeroUIManager.Instance.GetSelectTeamTypeByAttackType(1);
             Refresh();
         });
+
+        showConnTipToggleBtn.AddListener((value) =>
+        {
+            isToggleOn = showConnTipToggleBtn.isOn;
+        });
+        oneKeyOnBtn.AddListener(OneKeyOnPos);
+        saveBtn.AddListener(SaveTeam);
+
+        backBtn.AddListener(CloseWindow);
     }
 
 
     protected override void OnPreOpen()
     {
+        HeroUIManager.Instance.SortHeroOnTeamList();    //鎵撳紑鐣岄潰鍜屼繚瀛橈紙鏈嶅姟绔級鏇存柊闃靛鏄埛鏂�
         heroListScroller.OnRefreshCell += OnRefreshCell;
+        HeroUIManager.Instance.OnTeamPosChangeEvent += TeamChangeEvent;
         CreateScroller();
         Refresh();
     }
@@ -76,22 +92,47 @@
         OnBattleTeamAttrPer();
         RefreshOnTeamCountry();
         RefreshOnTeamBtn();
+        RefreshTeamHero();
+
+        if (HeroUIManager.Instance.heroOnTeamSortList.Count == 0)
+        {
+            heroListEmpty.SetActive(true);
+            heroListScroller.SetActive(false);
+        }
+        else
+        {
+            heroListEmpty.SetActive(false);
+            heroListScroller.SetActive(true);
+        }
+
+        showConnTipToggleBtn.isOn = isToggleOn;
+
+        fiterManager.Display(0, 0, 0, SelectJobCountry);
+
+        flyAlphaTween.alpha = 0;
+        flyHead.transform.localScale = Vector3.zero;
+        fightPowerText.text = "1234k";
     }
 
-
+    void SelectJobCountry(int job, int country)
+    {
+        HeroUIManager.Instance.selectTeamPosJob = job;
+        HeroUIManager.Instance.selectTeamPosCountry = country;
+        HeroUIManager.Instance.SortHeroOnTeamList();
+    }
 
     void OnRefreshCell(ScrollerDataType type, CellView cell)
     {
-        var _cell = cell as HeroCardLineCell;
+        var _cell = cell as HeroPosLineCell;
         _cell.Display(cell.index);
     }
 
     void CreateScroller()
     {
         heroListScroller.Refresh();
-        for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++)
+        for (int i = 0; i < HeroUIManager.Instance.heroOnTeamSortList.Count; i++)
         {
-            if (i % 4 == 0)
+            if (i % 5 == 0)
             {
                 heroListScroller.AddCell(ScrollerDataType.Header, i);
             }
@@ -108,6 +149,8 @@
         {
             for (int i = 0; i < team.serverHeroes.Length; i++)
             {
+                if (team.serverHeroes[i] == null)
+                    continue;
                 var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid);
                 if (hero != null)
                 {
@@ -181,7 +224,102 @@
 
     }
 
+    void RefreshTeamHero()
+    {
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        for (int i = 0; i < sceneHero.Length; i++)
+        {
+            var teamHero = team.tempHeroes[i];
+            if (teamHero == null)
+            {
+                sceneHero[i].SetActive(false);
+            }
+            else
+            {
+                sceneHero[i].SetActive(true);
+                sceneHero[i].Display(teamHero.guid, i);
+                //鎸塻cenePosImgs 椤哄簭鎺掑簭瀵瑰簲浣嶇疆
+                sceneHero[i].transform.position = scenePosImgs[i].transform.position;
+
+            }
+
+        }
 
 
+    }
 
+    /// <summary>
+    /// 鐐瑰嚮涓婇樀锛屾嫋鎷夛紝涓�閿瓑瑙﹀彂锛�
+    /// </summary>
+    /// <param name="posList">瑕佸埛鏂扮殑甯冮樀浣嶇疆</param>
+    /// <param name="flyFrom">澶т簬-1浠h〃鏄偣鍑讳笂闃碉紝闇�瑕佽〃鐜伴琛屾晥鏋�</param>
+    void TeamChangeEvent(List<int> posList, int flyFrom, Vector3 startPos)
+    {
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        foreach (var i in posList)
+        {
+            var teamHero = team.tempHeroes[i];
+            if (teamHero == null)
+            {
+                sceneHero[i].SetActive(false);
+            }
+            else
+            {
+                sceneHero[i].SetActive(true);
+                sceneHero[i].Display(teamHero.guid, i, flyFrom >= 0);
+                //鎸塻cenePosImgs 椤哄簭鎺掑簭瀵瑰簲浣嶇疆
+                sceneHero[i].transform.position = scenePosImgs[i].transform.position;
+
+            }
+        }
+
+        //琛ㄧ幇椋炲叆锛岃繛缁偣鍑讳笉鍚屽ご鍍忚Е鍙戠殑璇濆垯閲嶇疆
+        if (flyFrom > -1)
+        {
+            var flyHero = HeroManager.Instance.GetHero(HeroUIManager.Instance.heroOnTeamSortList[flyFrom]);
+            if (flyHero == null)
+                return;
+
+            //鍏堝仠姝� sequence
+            if (sequence != null)
+            {
+                sequence.Kill();
+            }
+            sequence = DOTween.Sequence();
+
+
+            flyAlphaTween.alpha = 1;
+            flyHead.Init(flyHero.heroId, flyHero.SkinID);
+            flyHead.transform.position = startPos;
+            var targetPos = scenePosImgs[posList[0]].transform.position;
+            flyHead.transform.localScale = Vector3.one;
+            sequence.Append(flyHead.transform.DOMove(targetPos, HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad))
+                .Join(flyHead.transform.DOScale(new Vector3(0.5f, 0.5f, 0.5f), HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad))
+                .Join(flyAlphaTween.DOFade(0f, HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad));
+        }
+    }
+
+    void OneKeyOnPos()
+    {
+        var guidList = HeroUIManager.Instance.SelectRecommend();
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        team.RemoveAllHeroes();
+        for (int i = 0; i < guidList.Count; i++)
+        {
+            team.AddHero(HeroManager.Instance.GetHero(guidList[i]), i);
+        }
+        List<int> posList = new List<int>();
+        for (int i = 0; i < guidList.Count; i++)
+        {
+            posList.Add(i);
+        }
+        TeamChangeEvent(posList, -1, Vector3.zero);
+        heroListScroller.m_Scorller.RefreshActiveCellViews();
+    }
+
+    void SaveTeam()
+    {
+        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+        team.SaveTeam();
+    }
 }
\ No newline at end of file
diff --git a/Main/System/HeroUI/HeroScenePosCell.cs b/Main/System/HeroUI/HeroScenePosCell.cs
index 29ebb39..2cc5cd1 100644
--- a/Main/System/HeroUI/HeroScenePosCell.cs
+++ b/Main/System/HeroUI/HeroScenePosCell.cs
@@ -1,5 +1,9 @@
+using System;
+using System.Linq;
+using Cysharp.Threading.Tasks;
 using UnityEngine;
 using UnityEngine.UI;
+using System.Collections.Generic;
 
 //甯冮樀涓殑 姝﹀皢瑙掕壊
 public class HeroScenePosCell : MonoBehaviour
@@ -12,19 +16,69 @@
     [SerializeField] Text lvText;
     [SerializeField] UIHeroController heroModel;
     [SerializeField] Image posCircleImg;
+    [SerializeField] UIAlphaTween suggestForm;
+    [SerializeField] DragItem dragObj;
+    [SerializeField] Transform objForfly;  //鐐瑰嚮椋炲叆鐨勬椂鍊欑殑鏄鹃殣鎺у埗
 
-    public void Display(string guid)
+    public void Display(string guid, int index, bool isFly = false)
     {
         var hero = HeroManager.Instance.GetHero(guid);
+        this.transform.localScale = Vector3.one;
 
-        lvText.text = Language.Get("L1094") + hero.heroLevel.ToString();
+        lvText.text = Language.Get("L1099", hero.heroLevel);
         var heroConfig = hero.heroConfig;
         countryImg.SetSprite("herocountry" + heroConfig.Country);
-        heroModel.Create(heroConfig.SkinIDList[hero.SkinIndex], heroConfig.UIScale);
-
+        heroModel.Create(heroConfig.SkinIDList[hero.SkinIndex]);
 
         nameText.text = hero.breakLevel == 0 ? heroConfig.Name : Language.Get("herocardbreaklv", heroConfig.Name, hero.breakLevel);
+        posCircleImg.SetSprite("heroposcircle" + heroConfig.Quality);
 
+        //涓嶆槸鎺ㄨ崘浣嶅垯鎻愮ず
+        if (heroConfig.AtkDistType == 1 && TeamConst.TeamPos2Array.Contains(index) ||
+            heroConfig.AtkDistType == 2 && TeamConst.TeamPos1Array.Contains(index))
+        {
+            suggestForm.SetActive(true);
+            jobTip.text = Language.Get("heroClass" + heroConfig.Class);
+            posTip.text = Language.Get("heroAtkDistType" + heroConfig.AtkDistType);
+        }
+        else
+        {
+            suggestForm.SetActive(false);
+        }
+
+        dragObj.onEndDragEvent += SwitchPos;
+
+        heroBtn.AddListener(() =>
+        {
+            var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+            team.RemoveHero(index);
+            //閫氱煡鍒锋柊锛堜笅闃碉級
+            HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { index }, -1, Vector3.zero);
+
+        });
+
+        if (isFly)
+        {
+            //鐐瑰嚮椋炲叆 寤惰繜鏄剧ず
+            objForfly.SetActive(false);
+            DelayShow();
+        }
+        else
+        {
+            objForfly.SetActive(true);
+        }
+    }
+
+    void SwitchPos(int pos1, int pos2)
+    {
+        Debug.Log("浜ゆ崲浣嶇疆:" + pos1 + "   " + pos2);
+    }
+
+    async UniTask DelayShow()
+    {
+        //寤惰繜0.5绉掓樉绀�
+        await UniTask.Delay(TimeSpan.FromSeconds(HeroUIManager.clickFlyPosTime));
+        objForfly.SetActive(true);
     }
 }
 
diff --git a/Main/System/HeroUI/HeroSelectBehaviour.cs b/Main/System/HeroUI/HeroSelectBehaviour.cs
index ced69f9..2430711 100644
--- a/Main/System/HeroUI/HeroSelectBehaviour.cs
+++ b/Main/System/HeroUI/HeroSelectBehaviour.cs
@@ -89,8 +89,8 @@
     //鍒锋柊灞曞紑鏀惰捣鐘舵��
     void RefreshFolState()
     {
-        unFoldBtn.SetActive(foldState == 1);
-        foldBtn.SetActive(foldState == 0);
+        unFoldForm.SetActive(foldState == 1);
+        foldForm.SetActive(foldState == 0);
     }
 }
 
diff --git a/Main/System/HeroUI/HeroUIManager.cs b/Main/System/HeroUI/HeroUIManager.cs
index f36047c..1efeaae 100644
--- a/Main/System/HeroUI/HeroUIManager.cs
+++ b/Main/System/HeroUI/HeroUIManager.cs
@@ -1,6 +1,7 @@
 锘縰sing System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 
 using UnityEngine;
@@ -8,12 +9,11 @@
 //姝﹀皢鐩稿叧鐣岄潰鐨勬搷浣滄暟鎹鐞�
 public class HeroUIManager : GameSystemManager<HeroUIManager>
 {
-    //姝﹀皢鍒楄〃鐣岄潰
+    #region 姝﹀皢鍒楄〃鐣岄潰
     public List<string> heroSortList { get; private set; } = new List<string>();  //涓婇樀涓轰富绾跨殑鍒楄〃
+    #endregion
 
-    public List<string> heroOnTeamSortList { get; private set; } = new List<string>();    //涓嶅悓涓婇樀鐨勫垪琛ㄦ帓搴�
 
-    public TeamType selectTeamType = TeamType.Story;  //褰撳墠閫変腑鐨勬槸鍝釜闃靛, 甯冮樀鐩稿叧閫昏緫浣跨敤
 
     public void OnBeforePlayerDataInitialize()
     {
@@ -35,8 +35,12 @@
 
     }
 
-    public bool waitResortHeroList = false;
 
+
+    public void QueryUnLockHeroPack()
+    {
+        //瑙i攣鏇村鐨勬灏嗚儗鍖�
+    }
 
     //鍒锋柊鏃舵満, 鎵撳紑姝﹀皢鐣岄潰 鎴栬�� 鍏抽棴鍔熻兘鐣岄潰
     public void SortHeroList()
@@ -86,10 +90,21 @@
         return heroA.heroId.CompareTo(heroB.heroId);
     }
 
+    #region 甯冮樀鐣岄潰
+    public List<string> heroOnTeamSortList { get; private set; } = new List<string>();    //涓嶅悓涓婇樀鐨勫垪琛ㄦ帓搴�
+
+    public TeamType selectTeamType = TeamType.Story;  //褰撳墠閫変腑鐨勬槸鍝釜闃靛, 甯冮樀鐩稿叧閫昏緫浣跨敤
+    public int selectTeamPosJob = 0;    //甯冮樀鐣岄潰 绛涢�夎亴涓�
+    public int selectTeamPosCountry = 0;    //甯冮樀鐣岄潰 绛涢�夊浗瀹�
+
+    public const float clickFlyPosTime = 0.5f;  //鐐瑰嚮鍒楄〃涓殑姝﹀皢鍥炬爣鏃�, 椋炲叆甯冮樀鐨勬椂闂�
+
+    public event Action<List<int>, int, Vector3> OnTeamPosChangeEvent; //甯冮樀鍙樺寲 浣嶇疆锛屽垪琛ㄧ殑璧烽绱㈠紩锛岃捣椋炲潗鏍�
+
 
     public void SortHeroOnTeamList()
     {
-        heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList();
+        heroOnTeamSortList = HeroManager.Instance.GetHeroGuidList(selectTeamPosJob, selectTeamPosCountry);
         heroOnTeamSortList.Sort(CmpHeroByTeamType);
     }
 
@@ -136,10 +151,6 @@
 
 
 
-    public void QueryUnLockHeroPack()
-    {
-        //瑙i攣鏇村鐨勬灏嗚儗鍖�
-    }
 
     //涓婇樀闃熶紞涓悇涓浗瀹剁殑姝﹀皢鏁伴噺
     public Dictionary<HeroCountry, int> GetCountryHeroCountByTeamType(TeamType teamType)
@@ -151,6 +162,8 @@
         {
             for (int i = 0; i < team.serverHeroes.Length; i++)
             {
+                if (team.serverHeroes[i] == null)
+                    continue;
                 var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid);
                 if (hero != null)
                 {
@@ -197,7 +210,81 @@
             return AttackType == 0 ? (int)TeamType.Arena : (int)TeamType.ArenaDefense;
         }
 
-        
+
         return (int)TeamType.Story;
     }
+
+
+    public void NotifyOnTeamPosChangeEvent(List<int> posList, int flyIndex, Vector3 startPos)
+    {
+        OnTeamPosChangeEvent?.Invoke(posList, flyIndex, startPos);
+    }
+
+    //鎺ㄨ崘闃靛
+    public List<string> SelectRecommend()
+    {
+        //鎺ㄨ崘闃靛鐨勭畻娉曢�昏緫
+        //鑷姩閫夋嫨浼樺厛绾э細姝﹀皢绛夌骇锛炵獊鐮寸瓑绾э紴姝﹀皢瑙夐啋闃剁骇锛炴灏嗗搧璐紴姝﹀皢鍚炲櫖鏄熺骇锛炴灏咺D
+        var tmpList = HeroManager.Instance.GetHeroGuidList();
+        tmpList.Sort(CmpHeroByTeamType);
+
+
+        //鎺ㄨ崘鏈�澶�6涓紝瀛樺湪鐩稿悓heroid锛屽垯璺宠繃
+        List<string> selectHeroList = new List<string>();
+        List<int> selectHeroIDList = new List<int>();
+        for (int i = 0; i < tmpList.Count; i++)
+        {
+            if (selectHeroList.Count >= TeamConst.MaxTeamHeroCount)
+                break;
+
+            string guid = tmpList[i];
+            HeroInfo heroInfo = HeroManager.Instance.GetHero(guid);
+            if (selectHeroIDList.Contains(heroInfo.heroId))
+                continue;
+            //濡傛灉閲嶅浜�,璺宠繃
+            if (selectHeroList.Contains(guid))
+                continue;
+            selectHeroList.Add(guid);
+            selectHeroIDList.Add(heroInfo.heroId);
+        }
+        return selectHeroList;
+    }
+
+
+    int CmpHeroRecommend(string guidA, string guidB)
+    {
+        HeroInfo heroA = HeroManager.Instance.GetHero(guidA);
+        HeroInfo heroB = HeroManager.Instance.GetHero(guidB);
+        if (heroA == null || heroB == null)
+        {
+            return 0;
+        }
+
+        // 鎺掑簭瑙勫垯锛氭灏嗙瓑绾э紴绐佺牬绛夌骇锛炴灏嗚閱掗樁绾э紴姝﹀皢鍝佽川锛炴灏嗗悶鍣槦绾э紴姝﹀皢ID
+        if (heroA.heroLevel != heroB.heroLevel)
+        {
+            return heroA.heroLevel > heroB.heroLevel ? -1 : 1;
+        }
+        if (heroA.breakLevel != heroB.breakLevel)
+        {
+            return heroA.breakLevel > heroB.breakLevel ? -1 : 1;
+        }
+        if (heroA.awakeLevel != heroB.awakeLevel)
+        {
+            return heroA.awakeLevel > heroB.awakeLevel ? -1 : 1;
+        }
+        if (heroA.Quality != heroB.Quality)
+        {
+            return heroA.Quality > heroB.Quality ? -1 : 1;
+        }
+        if (heroA.heroStar != heroA.heroStar)
+        {
+            return heroA.heroStar > heroB.heroStar ? -1 : 1;
+        }
+
+        return heroA.heroId.CompareTo(heroB.heroId);
+    }
+
+
+    #endregion
 }
diff --git a/Main/System/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
index e0f4653..14622c7 100644
--- a/Main/System/Team/TeamBase.cs
+++ b/Main/System/Team/TeamBase.cs
@@ -28,7 +28,7 @@
     private int ShapeType;
     public int ServerShapeType { get; private set; }
 
-    public TeamHero[] tempHeroes = new TeamHero[TeamConst.MaxTeamHeroCount];
+    public TeamHero[] tempHeroes { get; private set; }  = new TeamHero[TeamConst.MaxTeamHeroCount];
 
     public TeamHero[] serverHeroes { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
 
@@ -99,7 +99,7 @@
     {
         if (IsEmpty())
         {
-            Debug.LogError("Cannot save an empty team. You should at least have one hero in the team.");
+            SysNotifyMgr.Instance.ShowTip("HeroFunc3");
             return;
         }
 
@@ -109,6 +109,7 @@
         savePack.PosCnt = (byte)GetTeamHeroCount();
         savePack.HeroPosList = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos[savePack.PosCnt];
 
+        int index = 0;
         foreach (var hero in tempHeroes)
         {
             if (hero != null)
@@ -122,15 +123,17 @@
                     continue;
                 }
 
-                savePack.HeroPosList[posNum] = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos
+                savePack.HeroPosList[index] = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos
                 {
                     ItemIndex = (ushort)heroInfo.itemHero.gridIndex,
-                    PosNum = (byte)posNum
+                    PosNum = (byte)(posNum + 1)
                 };
+                index++;
             }
         }
-
         GameNetSystem.Instance.SendInfo(savePack);
+        SysNotifyMgr.Instance.ShowTip("HeroFunc4");
+        //闈炰富绾块樀瀹瑰鎴风鑷繁鍋氭垬鍔涘彉鍖栵紝涓荤嚎闃靛鏈嶅姟绔垬鍔涘彉鏇翠細鍚屾鎺ㄩ��
     }
 
     public void OnChangeShapeType(int newShapeType)
@@ -144,7 +147,7 @@
         ShapeType = newShapeType;
     }
 
-    //  hero info could be null if the hero is removed from the team
+    
     public void RefreshServerData(int shapeType, int positionIndex, HeroInfo heroInfo)
     {
         TeamHero teamHero = heroInfo == null ? null : new TeamHero(heroInfo, positionIndex, this);
@@ -185,6 +188,19 @@
         return null;
     }
 
+    public TeamHero GetHeroByHeroID(int heroId)
+    { 
+        foreach (var hero in tempHeroes)
+        {
+            if (hero != null && hero.heroId == heroId)
+            {
+                return hero;
+            }
+        }
+        return null;
+    }
+
+
     public TeamHero GetServerHero(string guid)
     {
         foreach (var hero in serverHeroes)
@@ -210,6 +226,7 @@
         return false;
     }
 
+    //瀹㈡埛绔粠0寮�濮嬶紝鏈嶅姟绔粠1寮�濮�
     public int GetEmptyPosition()
     {
         for (int i = 0; i < tempHeroes.Length; i++)
@@ -223,13 +240,13 @@
     }
 
     //  甯冮樀鎺ュ彛
-    public void SetTeamHero(int posNum, TeamHero hero)
+    private void SetTeamHero(int posNum, TeamHero hero)
     {
         tempHeroes[posNum] = hero;
     }
 
     //  甯冮樀鎺ュ彛
-    public void SetServerTeamHero(int posNum, TeamHero hero)
+    private void SetServerTeamHero(int posNum, TeamHero hero)
     {
         serverHeroes[posNum] = hero;
         tempHeroes[posNum] = hero;
@@ -259,41 +276,44 @@
 
 
     //  add鍙彲鑳芥槸鐐逛笅闈㈠崱鐗�
-    public bool AddHero(HeroInfo heroInfo)
+    public bool AddHero(HeroInfo heroInfo, out int pos)
     {
+        pos = -1;
         if (heroInfo == null || heroInfo.itemHero == null) return false;
 
-
-        //  濡傛灉褰撳墠鑻遍泟宸茬粡鍦ㄩ槦浼嶉噷浜� 灏变笉澶勭悊浜�
-        if (GetHero(heroInfo.itemHero.guid) != null)
+        // 鍚屼竴鑻遍泟 鍙兘涓婇樀涓�涓�
+        if (GetHeroByHeroID(heroInfo.heroId) != null)
         {
-            return false; // Hero already in team
+            SysNotifyMgr.Instance.ShowTip("HeroFunc2");
+            return false; 
         }
         else
         {
-            int emptyPosition = GetEmptyPosition();
+            pos = GetEmptyPosition();
 
-            if (emptyPosition < 0)
+            if (pos < 0)
             {
-                Debug.LogError("No empty position available in the team.");
+                SysNotifyMgr.Instance.ShowTip("HeroFunc1");
                 return false; // No empty position available
             }
 
-            TeamHero teamHero = new TeamHero(heroInfo, GetEmptyPosition(), this);
+            TeamHero teamHero = new TeamHero(heroInfo, pos, this);
             SetTeamHero(teamHero.positionNum, teamHero);
             return true;
         }
     }
 
 
-    public bool RemoveHero(HeroInfo heroInfo)
+    public bool RemoveHero(HeroInfo heroInfo, out int pos)
     {
+        pos = -1;
         if (heroInfo == null || heroInfo.itemHero == null) return false;
 
         TeamHero teamHero = GetHero(heroInfo.itemHero.guid);
 
         if (teamHero != null)
         {
+            pos = teamHero.positionNum;
             //  浠庡綋鍓嶉槦浼嶉噷绉婚櫎璇ヨ嫳闆�
             SetTeamHero(teamHero.positionNum, null);
             return true;
@@ -319,6 +339,18 @@
         return false; // Hero not found
     }
 
+    public bool RemoveHero(int pos)
+    {
+        SetTeamHero(pos, null);
+        return true;
+    }
+
+    public void RemoveAllHeroes()
+    {
+        tempHeroes = new TeamHero[TeamConst.MaxTeamHeroCount];
+    }
+
+
     public void SwapPosition(int index1, int index2)
     {
         if (index1 < 0 || index1 >= tempHeroes.Length || index2 < 0 || index2 >= tempHeroes.Length)
diff --git a/Main/System/Team/TeamConst.cs b/Main/System/Team/TeamConst.cs
index 15cd264..093d8d4 100644
--- a/Main/System/Team/TeamConst.cs
+++ b/Main/System/Team/TeamConst.cs
@@ -4,4 +4,9 @@
 {
     public const int MaxTeamHeroCount = 6;//鏈�澶у竷闃垫暟閲�
     public const int MaxTeamSlotCount = 7;//鏈�澶фЫ浣嶆暟閲� 鍖呭惈boss鐨勪腑闂翠綅缃� 甯冮樀鐨勬椂鍊欎笉鑳界敤杩欎釜
+
+    
+    public static readonly int[] TeamPos1Array  = new int[] {0, 1, 2}; //鍓嶆帓浣�
+    public static readonly int[] TeamPos2Array = new int[] {3, 4, 5};  //鍚庢帓浣�
+    
 }
\ No newline at end of file
diff --git a/Main/System/Team/TeamHero.cs b/Main/System/Team/TeamHero.cs
index 0e2a2cd..0597344 100644
--- a/Main/System/Team/TeamHero.cs
+++ b/Main/System/Team/TeamHero.cs
@@ -14,7 +14,7 @@
     {
         get; private set;
     }
-    public int positionNum;
+    public int positionNum; //娉ㄦ剰鏈嶅姟绔殑1鍙蜂綅鏄�1锛屽鎴风鍦ㄤ娇鐢ㄦ椂鏄�0锛岄�氫俊鍜岀瓥鍒掓矡閫氱敤1
 
 //  鎴樺満鏁版嵁
     public int ObjID = 0;// 鎴樻枟鍗曚綅鍞竴ID
@@ -41,7 +41,7 @@
         maxHp = (long)fightObj.MaxHPEx * GeneralDefine.HundredMillion + (long)fightObj.MaxHP;
         rage = (int)fightObj.AngreXP;
 
-        positionNum = fightObj.PosNum;
+        positionNum = fightObj.PosNum - 1;
 
         //  銆愰噸瑕併�戞垬鏂楁瀯鎴愰噷娌℃湁鍗$墝鐨刧uid
         guid = string.Empty;
@@ -76,12 +76,7 @@
 
     public void OnSwapPosition(TeamHero teamHero)
     {
-        int tempPosNum = positionNum;
-        positionNum = teamHero.positionNum;
-        teamHero.positionNum = tempPosNum;
-
-        teamBase.tempHeroes[positionNum] = this;
-        teamBase.tempHeroes[teamHero.positionNum] = teamHero;
+        teamBase.SwapPosition(positionNum, teamHero.positionNum);
 
         Update();
     }
diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 38c6ec8..7c000a5 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -47,7 +47,7 @@
 				// 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...] 
 				int teamType = teamMsg / 10000;
 				int shapeType = (teamMsg % 10000) / 100;
-				int positionIndex = teamMsg % 100;
+				int positionIndex = teamMsg % 100 - 1;	//甯冮樀浣嶇疆锛氭湇鍔$涓� 1  瀹㈡埛绔负0
 
 				if (teamTypeShapeTypePositionDict.ContainsKey((TeamType)teamType))
 				{
@@ -86,7 +86,7 @@
 				else
 				{
 					//  闃熶紞閲屾湁杩欎釜鑻遍泟锛屼絾鏄湪闃熶紞淇℃伅閲屾病鏈変簡 缃┖ 锛堣绉诲嚭闃熶紞锛�
-					team.SetTeamHero(teamHero.positionNum, null);
+					team.RemoveHero(teamHero.positionNum);
 				}
 			}
 			//	鍘熸潵闃熶紞閲屾病杩欎釜鑻遍泟
@@ -97,7 +97,7 @@
 				if (teamTypeShapeTypePositionDict.ContainsKey(team.teamType))
 				{
 					KeyValuePair<int, int> shapeTypePosition = teamTypeShapeTypePositionDict[team.teamType];
-					team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, null);
+					team.RefreshServerData(shapeTypePosition.Key, shapeTypePosition.Value, heroInfo);
 				}
 			}
 		}
@@ -128,7 +128,7 @@
 			// 鎵�鍦ㄩ樀瀹逛俊鎭垪琛� [闃靛绫诲瀷*10000+闃靛瀷绫诲瀷*100+浣嶇疆缂栧彿, ...] 
 			int teamType = teamMsg / 10000;
 			int shapeType = (teamMsg % 10000) / 100;
-			int positionIndex = teamMsg % 100;
+			int positionIndex = teamMsg % 100 - 1; //甯冮樀浣嶇疆锛氭湇鍔$涓� 1  瀹㈡埛绔负0
 
 			TeamBase team = GetTeam((TeamType)teamType);
 
@@ -152,7 +152,7 @@
 		{
 			team = new TeamBase(teamType);
 			// team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
-			// teamDict.Add(teamType, team);
+			teamDict.Add(teamType, team);
 		}
 
 		return team;
diff --git a/Main/System/Team/TeamType.cs b/Main/System/Team/TeamType.cs
index 2b1654a..8140550 100644
--- a/Main/System/Team/TeamType.cs
+++ b/Main/System/Team/TeamType.cs
@@ -6,9 +6,9 @@
 	//	PVE
 	Story = 1,
 	//	PVP 杩涙敾
-	Arena = 21,
+	Arena = 2,
 	//	PVP 闃插畧
-	ArenaDefense = 22,
-	Tower = 3,
+	ArenaDefense = 3,
+	Tower = 4,
 }
 
diff --git a/Main/Utility/ComponentExtersion.cs b/Main/Utility/ComponentExtersion.cs
index 5df6987..4418798 100644
--- a/Main/Utility/ComponentExtersion.cs
+++ b/Main/Utility/ComponentExtersion.cs
@@ -120,6 +120,7 @@
         {
             return;
         }
+        _toggle.onValueChanged.RemoveAllListeners();
         _toggle.onValueChanged.AddListener(_action);
     }
 

--
Gitblit v1.8.0