From a51aad2ddcf0cb2ffc8e77cac145f6f5d70ffc6b Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期四, 04 四月 2019 11:47:52 +0800
Subject: [PATCH] 3335 灵宠坐骑技能整合

---
 System/Pet/PetModel.cs | 1779 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 895 insertions(+), 884 deletions(-)

diff --git a/System/Pet/PetModel.cs b/System/Pet/PetModel.cs
index 187f61f..0fc2050 100644
--- a/System/Pet/PetModel.cs
+++ b/System/Pet/PetModel.cs
@@ -1,908 +1,919 @@
-锘縰sing Snxxz.UI;
-using System;
+锘縰sing System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text.RegularExpressions;
 using UnityEngine;
-[XLua.LuaCallCSharp]
-public class PetBackpack//瀹犵墿鑳屽寘
-{
-    public int PetClass;//瀹犵墿闃剁骇
-    public int PetStatus;//瀹犵墿褰撳墠鐘舵�� 1涓哄嚭鎴� 0鏈嚭鎴�
-    public int ItemPlace;//瀹犵墿浣嶇疆绱㈠紩
-    public int[] PetSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
-    public int petExp; //瀹犵墿褰撳墠缁忛獙
 
-}
-public enum PetEnum
-{
-    PetDan = 0,//鐏靛疇涓�
-    PetDebris = 1,//鐏靛疇纰庣墖
-    PetStone = 2,//鐏靛疇榄傜煶
-}
-public class PetModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
-{
-    public Dictionary<int, int> _TagPetItem = new Dictionary<int, int>();//鍏充簬鐏靛吔榄傜煶
-    public Dictionary<int, PetBackpack> _DicPetBack = new Dictionary<int, PetBackpack>();//瀹犵墿鑳屽寘鍒楄〃
-    public Dictionary<int, int> _PetSkillAcquire = new Dictionary<int, int>();//鐏靛疇宸茶幏寰楃殑鎶�鑳斤紙鍚岀被鎶�鑳藉彧瀛樻渶楂樼瓑绾э級1.鎶�鑳絋ypeID锛�2.鎶�鑳絀D
-    public delegate void Delegate_HB701(HB701_tagMCPetLV info);
-    public delegate void Delegate_Ha339(HA339_tagMCAttrFruitEatCntList info);
-    public static event Delegate_Ha339 Event_Ha339;//鐏靛吔榄傜煶
-    public delegate void Delegate_H0704();
-    public static event Delegate_H0704 Event_H0704Add;//鐏靛疇娣诲姞(杩涢樁)
-    public static Action<int> Event_H0704Update;//鐏靛疇鍒锋柊
-    public delegate void SpiritPetPlay(int _toPlay = 0);//瀹犵墿鏄惁鍑烘垬
-    public static event SpiritPetPlay Event_SpiritPetPlay;
-    public int PetNow = 0;//鐢ㄦ潵淇濆瓨鍑烘垬鐨勭伒瀹�
-    public bool Wait = true;//(浣跨敤鐏靛疇涓�)绛夊緟鍥炲寘
-    public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//瑙i攣鎸夐挳绾㈢偣锛堢伒瀹犵孩鐐瑰瓙绾э級
-    public Dictionary<int, Redpoint> PetRedpoint = new Dictionary<int, Redpoint>();//鐏靛疇鍒楄〃
-    public Dictionary<int, Redpoint> CultivateRedPoint = new Dictionary<int, Redpoint>();//鐏靛疇鍩瑰吇鎸夐挳绾㈢偣
-    private List<PetInfoConfig> Sortpet = new List<PetInfoConfig>();//鐢ㄤ簬绾㈢偣鎺掑簭
-
-    public int MinAtkNunber = 0;//鐏靛疇鏈�灏忔敾鍑诲姏
-    public int MaxAtkNunber = 0;//鐏靛疇鏈�澶ф敾鍑诲姏
-
-    public int PetStoneItemId = 0;//鐢ㄦ潵璁板綍鍧愰獞榄傜煶鐨処D
-
-    public bool IsOk = false;
-    private int PetDanExp = 0;//鐏靛疇涓圭粡楠�
-    public List<int> ListEffectSkill = new List<int>();
-    PackModel _playerPack;
-    PackModel playerPack
-    {
-        get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
-    }
-
-    public Dictionary<int, string> petLvNameDict { get; private set; }
-    public int curPetId { get; set; }
-    public int petUpgradeToolId { get; set; }
-
-    public event Action PlayerLoginOkData;
-    private Dictionary<int, int> DicDefaultPet = new Dictionary<int, int>();
-    List<PetInfoConfig> allPetConfigs = new List<PetInfoConfig>();
-
-    Dictionary<int, int> integrationSkills = new Dictionary<int, int>();
-    Dictionary<int, List<int>> integrationPetSkills = new Dictionary<int, List<int>>();
-    Dictionary<int, int> petSkills = new Dictionary<int, int>();
-
-    public override void Init()
-    {
-        ToAddSorting();
-        playerPack.refreshItemCountEvent += OnItemRefreshEvent;
-        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
-        PetAttributeWin.IsRedPointCultivate += IsRedPointCultivate;
-        PetNumberPreservation();
-
-        petLvNameDict = new Dictionary<int, string>();
-        FuncConfigConfig petLvName = FuncConfigConfig.Get("PetQuality");
-        int[] petLvArray = ConfigParse.GetMultipleStr<int>(petLvName.Numerical1);
-        string[] petLvNameArray = ConfigParse.GetMultipleStr(petLvName.Numerical2);
-        for (int i = 0; i < petLvArray.Length; i++)
-        {
-            if (!petLvNameDict.ContainsKey(petLvArray[i]))
-            {
-                petLvNameDict.Add(petLvArray[i], petLvNameArray[i]);
-            }
-        }
-
-        petUpgradeToolId = int.Parse(FuncConfigConfig.Get("PetUpItem").Numerical1);
-        string str = FuncConfigConfig.Get("PetSkillEffect").Numerical1;
-        int[] listeffect = ConfigParse.GetMultipleStr<int>(str);
-        ListEffectSkill.Clear();
-        for (int i = 0; i < listeffect.Length; i++)
-        {
-            ListEffectSkill.Add(listeffect[i]);
-        }
-        string PetRedDotstr = FuncConfigConfig.Get("MountPetRedDot").Numerical2;
-        DicDefaultPet = ConfigParse.GetDic<int, int>(PetRedDotstr);
-        PetDanExp = int.Parse(FuncConfigConfig.Get("PetUpItem").Numerical2);
-
-        var funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration");
-        var intArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
-        for (int i = 0; i < intArray.Length; i++)
+namespace Snxxz.UI
+{
+    public class PetBackpack//瀹犵墿鑳屽寘
+    {
+        public int PetClass;//瀹犵墿闃剁骇
+        public int PetStatus;//瀹犵墿褰撳墠鐘舵�� 1涓哄嚭鎴� 0鏈嚭鎴�
+        public int ItemPlace;//瀹犵墿浣嶇疆绱㈠紩
+        public int[] PetSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
+        public int petExp; //瀹犵墿褰撳墠缁忛獙
+    }
+
+    public enum PetEnum
+    {
+        PetDan = 0,//鐏靛疇涓�
+        PetDebris = 1,//鐏靛疇纰庣墖
+        PetStone = 2,//鐏靛疇榄傜煶
+    }
+
+    public class PetModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
+    {
+        public Dictionary<int, int> _TagPetItem = new Dictionary<int, int>();//鍏充簬鐏靛吔榄傜煶
+        public Dictionary<int, PetBackpack> _DicPetBack = new Dictionary<int, PetBackpack>();//瀹犵墿鑳屽寘鍒楄〃
+        public Dictionary<int, int> _PetSkillAcquire = new Dictionary<int, int>();//鐏靛疇宸茶幏寰楃殑鎶�鑳斤紙鍚岀被鎶�鑳藉彧瀛樻渶楂樼瓑绾э級1.鎶�鑳絋ypeID锛�2.鎶�鑳絀D
+        public delegate void Delegate_HB701(HB701_tagMCPetLV info);
+        public delegate void Delegate_Ha339(HA339_tagMCAttrFruitEatCntList info);
+        public static event Delegate_Ha339 Event_Ha339;//鐏靛吔榄傜煶
+        public delegate void Delegate_H0704();
+        public static event Delegate_H0704 Event_H0704Add;//鐏靛疇娣诲姞(杩涢樁)
+        public static Action<int> Event_H0704Update;//鐏靛疇鍒锋柊
+        public delegate void SpiritPetPlay(int _toPlay = 0);//瀹犵墿鏄惁鍑烘垬
+        public static event SpiritPetPlay Event_SpiritPetPlay;
+        public int PetNow = 0;//鐢ㄦ潵淇濆瓨鍑烘垬鐨勭伒瀹�
+        public bool Wait = true;//(浣跨敤鐏靛疇涓�)绛夊緟鍥炲寘
+        public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//瑙i攣鎸夐挳绾㈢偣锛堢伒瀹犵孩鐐瑰瓙绾э級
+        public Dictionary<int, Redpoint> PetRedpoint = new Dictionary<int, Redpoint>();//鐏靛疇鍒楄〃
+        public Dictionary<int, Redpoint> CultivateRedPoint = new Dictionary<int, Redpoint>();//鐏靛疇鍩瑰吇鎸夐挳绾㈢偣
+        private List<PetInfoConfig> Sortpet = new List<PetInfoConfig>();//鐢ㄤ簬绾㈢偣鎺掑簭
+
+        public int MinAtkNunber = 0;//鐏靛疇鏈�灏忔敾鍑诲姏
+        public int MaxAtkNunber = 0;//鐏靛疇鏈�澶ф敾鍑诲姏
+
+        public int PetStoneItemId = 0;//鐢ㄦ潵璁板綍鍧愰獞榄傜煶鐨処D
+
+        public bool IsOk = false;
+        private int PetDanExp = 0;//鐏靛疇涓圭粡楠�
+        public List<int> ListEffectSkill = new List<int>();
+        PackModel _playerPack;
+        PackModel playerPack
         {
-            var skillConfig = SkillConfig.Get(intArray[i]);
-            if (skillConfig != null)
+            get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
+        }
+
+        public Dictionary<int, string> petLvNameDict { get; private set; }
+        public int curPetId { get; set; }
+        public int petUpgradeToolId { get; set; }
+
+        public event Action PlayerLoginOkData;
+        private Dictionary<int, int> DicDefaultPet = new Dictionary<int, int>();
+        List<PetInfoConfig> allPetConfigs = new List<PetInfoConfig>();
+
+        Dictionary<SkillEffectValue, int> integrationSkills = new Dictionary<SkillEffectValue, int>();
+        Dictionary<SkillEffectValue, List<int>> integrationPetSkills = new Dictionary<SkillEffectValue, List<int>>();
+        Dictionary<int, SkillEffectValue> petSkillEffectValues = new Dictionary<int, SkillEffectValue>();
+        Dictionary<int, int> petSkills = new Dictionary<int, int>();
+
+        public override void Init()
+        {
+            ToAddSorting();
+            playerPack.refreshItemCountEvent += OnItemRefreshEvent;
+            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
+            PetAttributeWin.IsRedPointCultivate += IsRedPointCultivate;
+            PetNumberPreservation();
+
+            petLvNameDict = new Dictionary<int, string>();
+            FuncConfigConfig petLvName = FuncConfigConfig.Get("PetQuality");
+            int[] petLvArray = ConfigParse.GetMultipleStr<int>(petLvName.Numerical1);
+            string[] petLvNameArray = ConfigParse.GetMultipleStr(petLvName.Numerical2);
+            for (int i = 0; i < petLvArray.Length; i++)
             {
-                integrationSkills.Add(skillConfig.Effect1, intArray[i]);
+                if (!petLvNameDict.ContainsKey(petLvArray[i]))
+                {
+                    petLvNameDict.Add(petLvArray[i], petLvNameArray[i]);
+                }
+            }
+
+            petUpgradeToolId = int.Parse(FuncConfigConfig.Get("PetUpItem").Numerical1);
+            string str = FuncConfigConfig.Get("PetSkillEffect").Numerical1;
+            int[] listeffect = ConfigParse.GetMultipleStr<int>(str);
+            ListEffectSkill.Clear();
+            for (int i = 0; i < listeffect.Length; i++)
+            {
+                ListEffectSkill.Add(listeffect[i]);
+            }
+            string PetRedDotstr = FuncConfigConfig.Get("MountPetRedDot").Numerical2;
+            DicDefaultPet = ConfigParse.GetDic<int, int>(PetRedDotstr);
+            PetDanExp = int.Parse(FuncConfigConfig.Get("PetUpItem").Numerical2);
+
+            var funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration");
+            var intArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
+            for (int i = 0; i < intArray.Length; i++)
+            {
+                var skillConfig = SkillConfig.Get(intArray[i]);
+                if (skillConfig != null)
+                {
+                    var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
+                    integrationSkills.Add(effectValue, intArray[i]);
+                }
+            }
+
+            var configs = PetInfoConfig.GetValues();
+            foreach (var config in configs)
+            {
+                for (int i = 0; i < config.SkillID.Length; i++)
+                {
+                    var skillConfig = SkillConfig.Get(config.SkillID[i]);
+                    var effectValue = SkillConfig.GetSkillEffectValue(skillConfig);
+
+                    if (integrationSkills.ContainsKey(effectValue))
+                    {
+                        List<int> skills = null;
+                        if (!integrationPetSkills.TryGetValue(effectValue, out skills))
+                        {
+                            skills = new List<int>();
+                            integrationPetSkills.Add(effectValue, skills);
+                        }
+                        skills.Add(config.SkillID[i]);
+                    }
+
+                    petSkills.Add(config.SkillID[i], config.ID);
+                    petSkillEffectValues.Add(config.SkillID[i], effectValue);
+                }
             }
         }
 
-        var configs = PetInfoConfig.GetValues();
-        foreach (var config in configs)
+        public override void UnInit()
         {
-            for (int i = 0; i < config.SkillID.Length; i++)
+            playerPack.refreshItemCountEvent -= OnItemRefreshEvent;
+            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
+            PetAttributeWin.IsRedPointCultivate -= IsRedPointCultivate;
+        }
+
+        public void OnBeforePlayerDataInitialize()
+        {
+            Wait = true;
+            IsOk = false;
+            _TagPetItem.Clear();
+            _DicPetBack.Clear();
+            PetNow = 0;
+            MinAtkNunber = 0;
+            MaxAtkNunber = 0;
+            curPetId = 0;
+        }
+
+        public void OnPlayerLoginOk()
+        {
+            GlobalTimeEvent.Instance.secondEvent -= secondEvent;
+            GlobalTimeEvent.Instance.secondEvent += secondEvent;
+            SinglePack singPack = playerPack.GetSinglePack(PackType.PetPack);
+            if (singPack == null) return;
+            foreach (var index in singPack.GetAllItems().Keys)
             {
-                var skillConfig = SkillConfig.Get(config.SkillID[i]);
-                if (integrationSkills.ContainsKey(skillConfig.Effect1))
-                {
-                    List<int> skills = null;
-                    if (!integrationPetSkills.TryGetValue(skillConfig.Effect1, out skills))
-                    {
-                        skills = new List<int>();
-                        integrationPetSkills.Add(skillConfig.Effect1, skills);
-                    }
-                    skills.Add(config.SkillID[i]);
-                }
-
-                petSkills.Add(config.SkillID[i], config.ID);
+                OnItemRefreshEvent(singPack.type, index, singPack.GetAllItems()[index].itemId);
             }
-        }
-    }
-
-    public override void UnInit()
-    {
-        playerPack.refreshItemCountEvent -= OnItemRefreshEvent;
-        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
-        PetAttributeWin.IsRedPointCultivate -= IsRedPointCultivate;
-    }
-
-    public void OnBeforePlayerDataInitialize()
-    {
-        Wait = true;
-        IsOk = false;
-        _TagPetItem.Clear();
-        _DicPetBack.Clear();
-        PetNow = 0;
-        MinAtkNunber = 0;
-        MaxAtkNunber = 0;
-        curPetId = 0;
-    }
-
-    public void OnPlayerLoginOk()
-    {
-        GlobalTimeEvent.Instance.secondEvent -= secondEvent;
-        GlobalTimeEvent.Instance.secondEvent += secondEvent;
-        SinglePack singPack = playerPack.GetSinglePack(PackType.PetPack);
-        if (singPack == null) return;
-        foreach (var index in singPack.GetAllItems().Keys)
-        {
-            OnItemRefreshEvent(singPack.type, index, singPack.GetAllItems()[index].itemId);
-        }
-        IsOk = true;
-        if (PlayerLoginOkData != null)
-        {
-            PlayerLoginOkData();
-        }
-    }
-    private DateTime dateTimeA;
-    private void secondEvent()
-    {
-        if (!Wait)
-        {
-            TimeSpan timeS = DateTime.Now - dateTimeA;
-            if (timeS.Seconds >= 2f)
-            {
-                Wait = true;
-            }
-        }
-        else
-        {
-            dateTimeA = DateTime.Now;
-        }
-    }
-
-    #region 鍙戦�佹湇鍔$璇锋眰
-    public void SendPetSwitchQuest(int petIndex)
-    {
-        C1603_tagCPetStateChange tag_Cpet = new C1603_tagCPetStateChange();
-        tag_Cpet.PetID = (uint)petIndex;
-        tag_Cpet.State = 1;
-        GameNetSystem.Instance.SendInfo(tag_Cpet);
-    }
-
-    public void SendBreakPetLockQuest(int petId)
-    {
-        CA702_tagCMActivatePet CMPet = new CA702_tagCMActivatePet();
-        CMPet.PetNPCID = (uint)petId;
-        GameNetSystem.Instance.SendInfo(CMPet);
-        if (ItemOperateUtility.Instance.useItemModel != null)
-        {
-            ItemOperateUtility.Instance.useItemModel = null;
-        }
-    }
-
-    public void SendPetTrainQuest(int petIndex, int number)
-    {
-        CA704_tagCMPetClassUP _tagCA704 = new CA704_tagCMPetClassUP();
-        _tagCA704.PetItemIndex = (byte)petIndex;
-        _tagCA704.UseItemCnt = (ushort)number;
-        GameNetSystem.Instance.SendInfo(_tagCA704);
-    }
-    #endregion
-
-
-    private void OnItemRefreshEvent(PackType type, int index, int id)
-    {
-        PetH0704(playerPack.GetItemByIndex(type, index));
-        if (type == PackType.Item)
-        {
-            if (_TagPetItem.ContainsKey(id))
-            {
-                PetStoneRed();
-            }
-            PetActivateRedPoint();
-            GetCultivateRedPoint();
-
-        }
-    }
-    private void OnFuncStateChange(int obj)
-    {
-        if (obj == 6)
-        {
-            PetStoneRed();
-            PetActivateRedPoint();
-            GetCultivateRedPoint();
-        }
-    }
-
-    private const int Redpoint_key1 = 1050201;
-    private Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_PetKey2, Redpoint_key1);
-    private void PetStoneRed()//鐏靛疇榄傜煶绾㈢偣
-    {
-        redPointStre1.state = RedPointState.None;
-        if (!FuncOpen.Instance.IsFuncOpen(6))
-        {
-            return;
-        }
-        int type = 0;
-        foreach (var key in _TagPetItem.Keys)
-        {
-            if (_TagPetItem[key] >= AttrFruitConfig.Get(key).MaxUseCnt)
-            {
-                continue;
-            }
-            type += playerPack.GetItemCountByID(PackType.Item, key);
-
-        }
-        if (type > 0)
-        {
-            redPointStre1.state = RedPointState.Simple;
-            return;
-        }
-    }
-    private void PetNumberPreservation()//鐢ㄦ潵瀵圭伒瀹犱釜鏁拌繘琛屼繚瀛�
-    {
-        if (PetRedpoint.Count != 0)
-        {
-            return;
-        }
-        int type = 0;
-        if (allPetConfigs.Count <= 0)
-        {
-            allPetConfigs = PetInfoConfig.GetValues();
-        }
-        //  var allPetConfigs = PetInfoConfig.GetValues();
-        foreach (var config in allPetConfigs)
-        {
-            if (!DeblockingRedPoint.ContainsKey(config.ID))
-            {
-                type += 1;
-                int petID = config.ID;
-                int RedPoint_Mountkey = MainRedDot.RedPoint_PetKey2 * 10 + type;
-                Redpoint redPointMountStare = new Redpoint(MainRedDot.RedPoint_PetKey2, RedPoint_Mountkey);
-                PetRedpoint.Add(petID, redPointMountStare);//鍒楄〃
-
-                int RedPoint_Mountkey1 = RedPoint_Mountkey * 10 + type;
-                Redpoint redPointMountStare1 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey1);
-                DeblockingRedPoint.Add(petID, redPointMountStare1);//瑙i攣鎸夐挳
-                int RedPoint_Mountkey2 = RedPoint_Mountkey1 * 10 + type;
-                Redpoint redPointMountStare2 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey2);
-                CultivateRedPoint.Add(petID, redPointMountStare2);
-            }
-        }
-    }
-
-    private void PetActivateRedPoint()//鐏靛疇婵�娲荤孩鐐�
-    {
-        foreach (var key in PetRedpoint.Keys)
-        {
-            DeblockingRedPoint[key].state = RedPointState.None;
-        }
-        if (!FuncOpen.Instance.IsFuncOpen(6))
-        {
-            return;
-        }
-        // var configs = PetInfoConfig.GetValues();
-        if (allPetConfigs.Count <= 0)
-        {
-            allPetConfigs = PetInfoConfig.GetValues();
-        }
-        foreach (var config in allPetConfigs)
-        {
-            int unlockItemID = config.UnLockNeedItemID;
-            int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID);
-            int unlockItemCnt = config.UnLockNeedItemCnt;
-            if (itemCount >= unlockItemCnt && !_DicPetBack.ContainsKey(config.ID) && FuncOpen.Instance.IsFuncOpen(6))
-            {
-                DeblockingRedPoint[config.ID].state = RedPointState.Simple;
-            }
-        }
-    }
-    private void IsRedPointCultivate()
-    {
-        GetCultivateRedPoint();
-    }
-    private void ToAddSorting()
-    {
-        Sortpet.Clear();
-        if (allPetConfigs.Count <= 0)
-        {
-            allPetConfigs = PetInfoConfig.GetValues();
-        }
-        Sortpet = allPetConfigs;
-        Sortpet.Sort(Compare);
-    }
-    int Compare(PetInfoConfig x, PetInfoConfig y)//鏁扮粍鎺掑垪
-    {
-        if (x.Sort.CompareTo(y.Sort) != 0)
-        {
-            return x.Sort.CompareTo(y.Sort);
-        }
-        return 1;
-    }
-    public void GetCultivateRedPoint()//鐏靛疇鍩瑰吇绾㈢偣
-    {
-        foreach (var key in CultivateRedPoint.Keys)
-        {
-            CultivateRedPoint[key].state = RedPointState.None;
-        }
-        if (!FuncOpen.Instance.IsFuncOpen(6))
-        {
-            return;
-        }
-        if (_DicPetBack.Count <= 0)
-        {
-            return;
-        }
-        int GetPetId = 0;
-        int petLv = 100;
-        int itemCount = playerPack.GetItemCountByID(PackType.Item, 4151);
-        List<int> ListInt = new List<int>();
-        for (int i = 0; i < Sortpet.Count; i++)
-        {
-            int petID = Sortpet[i].ID;
-            int MaxLv = PetInfoConfig.Get(petID).MaxRank;
-            if (_DicPetBack.ContainsKey(petID) && _DicPetBack[petID].PetClass < MaxLv)
-            {
-                int _NeedExp = PetClassCostConfig.GetPetIdAndRank(petID, _DicPetBack[petID].PetClass).UpNeedExp;
-                int NeedExp = _NeedExp - _DicPetBack[petID].petExp;
-                int NeedNumber = Mathf.CeilToInt((float)NeedExp / PetDanExp);
-                if (itemCount >= NeedNumber)
-                {
-                    ListInt.Add(petID);
-                }
-            }
-        }
-
-        foreach (var key in _DicPetBack.Keys)//鍥犱负鏈夋垚灏变换鍔¢檺鍒舵墍鏈� 绗竴鍙潗楠戠孩鐐归�昏緫鐗规畩鍐�
-        {
-            if (DicDefaultPet.ContainsKey(key) && DicDefaultPet[key] > _DicPetBack[key].PetClass
-                && itemCount > 0 && CultivateRedPoint.ContainsKey(key))
-            {
-                CultivateRedPoint[key].state = RedPointState.Simple;
-                return;
-            }
-        }
-        List<int> IntListSkill = new List<int>();
-        for (int i = 0; i < ListInt.Count; i++)//閫夋嫨鍑哄崌绾х伒瀹犵瓑绾ф渶浣庝笖鏈夋妧鑳芥湭瑙i攣鐨勪笖缁忛獙鏈�鎺ヨ繎
-        {
-            if (_DicPetBack.ContainsKey(ListInt[i]))
-            {
-                var PetConfig = PetInfoConfig.Get(ListInt[i]);
-                if (PetConfig == null)
-                {
-                    return;
-                }
-                int[] SkillUnLockInt = PetConfig.SkillUnLock;
-                int SkillLvMax = SkillUnLockInt[(SkillUnLockInt.Length - 1)];
-                if (_DicPetBack[(ListInt[i])].PetClass < SkillLvMax)
-                {
-                    IntListSkill.Add((ListInt[i]));
-                }
-            }
-        }
-        int SkillPetId = GetRedPointPetID(IntListSkill);
-        if (SkillPetId != 0 && CultivateRedPoint.ContainsKey(SkillPetId))
-        {
-            CultivateRedPoint[SkillPetId].state = RedPointState.Simple;
-            return;
-        }
-
-
-        for (int i = 0; i < ListInt.Count; i++)//閫夋嫨鍑虹瓑绾ф渶浣庣殑鐏靛疇
-        {
-            if (_DicPetBack.ContainsKey(ListInt[i]))
-            {
-                if (_DicPetBack[(ListInt[i])].PetClass < petLv)
-                {
-                    petLv = _DicPetBack[(ListInt[i])].PetClass;
-                    GetPetId = (ListInt[i]);
-                }
-            }
-        }
-        if (GetPetId != 0 && CultivateRedPoint.ContainsKey(GetPetId))
-        {
-            CultivateRedPoint[GetPetId].state = RedPointState.Simple;
-            return;
-        }
-    }
-
-
-    private int GetRedPointPetID(List<int> PetList)
-    {
-        int GetSkillMinLv = 999;
-        for (int i = 0; i < PetList.Count; i++)
-        {
-            int SkillminLv = GetSkillLvDis(PetList[i]);
-            if (SkillminLv < GetSkillMinLv && SkillminLv!=0)
-            {
-                GetSkillMinLv = SkillminLv;
-            }
-        }
-
-        int petId = 0;
-        int ExpNumber = 999999999;
-        for (int i = 0; i < PetList.Count; i++)
-        {
-            int SkillLv = GetSkillLvDis(PetList[i]);
-            if (SkillLv > GetSkillMinLv || SkillLv==0)
-            {
-                continue;
-            }
-            var Pet1 = PetClassCostConfig.GetPetIdAndRank(PetList[i], SkillLv);
-            var Pet2 = PetClassCostConfig.GetPetIdAndRank(PetList[i], _DicPetBack[(PetList[i])].PetClass);
-            int Exp = Pet1.NeedExpTotal - Pet2.NeedExpTotal - _DicPetBack[(PetList[i])].petExp;
-            if (Exp < ExpNumber)
-            {
-                ExpNumber = Exp;
-                petId = PetList[i];
-            }
-        }
-        return petId;
-    }
-    private int GetSkillLvDis(int PetId)//鑾峰彇绂诲崌绾ф渶杩戠殑鎶�鑳界瓑绾�
-    {
-        int SkillLv = 0;
-        var petInfo = PetInfoConfig.Get(PetId);
-        if (petInfo == null)
-        {
-            return 0;
-        }
-        int[] ListPetSkillUnLock = petInfo.SkillUnLock;
-        for (int i = 0; i < ListPetSkillUnLock.Length; i++)
-        {
-            if (_DicPetBack.ContainsKey(PetId) && ListPetSkillUnLock[i] > _DicPetBack[PetId].PetClass)
-            {
-                SkillLv = ListPetSkillUnLock[i];
-                return SkillLv;
-            }
-        }
-        return SkillLv;
-    }
-    public int GetMinPetExp()
-    {
-        foreach (var key in CultivateRedPoint.Keys)//褰撳瓨鍦ㄥ煿鍏荤孩鐐规椂锛岄�変腑褰撴湁绾㈢偣鐨勯偅鍙�
-        {
-            if (CultivateRedPoint[key].state == RedPointState.Simple)
-            {
-                return key;
-            }
-        }
-
-        List<int> IntListSkill = new List<int>();
-        foreach (var key in _DicPetBack.Keys)
-        {
-            var petConfig = PetInfoConfig.Get(key);
-            if (_DicPetBack[key].PetClass < petConfig.MaxRank)
-            {
-                IntListSkill.Add(key);
-            }
-        }
-        int SkillPetId = GetRedPointPetID(IntListSkill);
-        if (SkillPetId != 0)
-        {
-            return SkillPetId;
-        }
-        int GetPetId = 0;
-        int GetPetLv = 999;
-
-        foreach (var key in _DicPetBack.Keys)//鏃犵孩鐐规椂璺宠浆閫変腑绛夌骇鏈�浣庣殑
-        {
-            var config = PetInfoConfig.Get(key);
-            if (_DicPetBack[key].PetClass < GetPetLv && _DicPetBack[key].PetClass < config.MaxRank)
-            {
-                GetPetId = key;
-                GetPetLv = _DicPetBack[key].PetClass;
-            }
-        }
-        return GetPetId;
-    }
-    private int GetPetSkillMaxLv(int PetID)
-    {
-        int maxskillLV = 0;
-        int[] curPetUnlocks;
-        PetInfoConfig petInfo = PetInfoConfig.Get(PetID);
-        if (petInfo != null)
-        {
-            curPetUnlocks = petInfo.SkillUnLock;
-            maxskillLV = curPetUnlocks[(curPetUnlocks.Length) - 1];
-        }
-        return maxskillLV;
-    }
-    public void PetA339(HA339_tagMCAttrFruitEatCntList info)
-    {
-        for (int i = 0; i < info.count; i++)
-        {
-            var configItem = ItemConfig.Get((int)info.EatCntList[i].ItemID);
-            if (configItem == null)
-            {
-                continue;
-            }
-            if (_TagPetItem.ContainsKey((int)info.EatCntList[i].ItemID))
-            {
-                _TagPetItem[(int)info.EatCntList[i].ItemID] = (int)info.EatCntList[i].EatCnt;
-                if (Event_Ha339 != null)
-                    Event_Ha339(info);
-            }
-            else
-            {
-                if (configItem.Type == 28)
-                {
-                    _TagPetItem.Add((int)info.EatCntList[i].ItemID, (int)info.EatCntList[i].EatCnt);
-
-                }
-            }
-        }
-        PetStoneRed();
-    }
-
-    private void AddPetSkill(int[] intlist)
-    {
-        for (int i = 0; i < intlist.Length; i++)
-        {
-            var skillPet = SkillConfig.Get(intlist[i]);
-            if (_PetSkillAcquire.ContainsKey(skillPet.SkillTypeID))
-            {
-                int skilllv = SkillConfig.Get(_PetSkillAcquire[skillPet.SkillTypeID]).SkillLV;
-                if (skillPet.SkillLV > skilllv)
-                {
-                    _PetSkillAcquire[skillPet.SkillTypeID] = skillPet.SkillID;
-                }
-            }
-            else
-            {
-                _PetSkillAcquire.Add(skillPet.SkillTypeID, skillPet.SkillID);
-            }
-        }
-    }
-
-    public void PetH0704(ItemModel info)//瀹犵墿鑳屽寘鍒楄〃
-    {
-        if (info == null)
-            return;
-
-        if (info.packType == PackType.PetPack)
-        {
-            Dictionary<int, int[]> _dic = Analysis(info.itemInfo.userData);
-            if (GetUseDataModel(200, _dic) != null)
-            {
-                int petId = _dic[200][0];
-                int petLv = 0;
-                int petState = 0;
-                int[] petSkill = null;
-                int petIndex = info.gridIndex;
-                int petExp = 0;
-                if (GetUseDataModel(201, _dic) != null)
-                {
-                    petSkill = _dic[201];//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
-                }
-
-                if (GetUseDataModel(202, _dic) != null)
-                {
-                    petLv = _dic[202][0] + 1;//瀹犵墿闃剁骇
-                }
-
-                if (GetUseDataModel(204, _dic) != null)
-                {
-                    petState = _dic[204][0];//瀹犵墿褰撳墠鐘舵��;
-                }
-
-                if (GetUseDataModel(208, _dic) != null)
-                {
-                    petExp = _dic[208][0]; //瀹犵墿缁忛獙
-                }
-
-                if (!_DicPetBack.ContainsKey(petId))
-                {
-
-                    PetBackpack _petBack = new PetBackpack();
-                    _petBack.PetClass = petLv;
-                    _petBack.petExp = petExp; //瀹犵墿缁忛獙
-                    _petBack.PetStatus = petState;//瀹犵墿褰撳墠鐘舵��
-                    if (_petBack.PetStatus == 1)
-                    {
-                        PetNow = petId;
-                    }
-
-                    if (petSkill != null)
-                    {
-                        _petBack.PetSkill = petSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
-                        AddPetSkill(_petBack.PetSkill);
-                    }
-                    else
-                    {
-                        _petBack.PetSkill = null;
-                    }
-                    _petBack.ItemPlace = petIndex;//瀹犵墿浣嶇疆绱㈠紩
-                    _DicPetBack.Add(petId, _petBack);
-                    if (Event_H0704Add != null && IsOk)
-                    {
-                        Event_H0704Add();
-                    }
-
-                }
-                else
-                {
-                    _DicPetBack[petId].PetClass = petLv;
-                    _DicPetBack[petId].PetStatus = petState;
-                    _DicPetBack[petId].petExp = petExp; //瀹犵墿缁忛獙
-                    if (petSkill != null)
-                    {
-                        _DicPetBack[petId].PetSkill = petSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
-                        AddPetSkill(_DicPetBack[petId].PetSkill);
-                    }
-                    else
-                    {
-                        _DicPetBack[petId].PetSkill = null;
-                    }
-
-                    _DicPetBack[petId].ItemPlace = petIndex;
-                    if (Event_H0704Update != null && IsOk)
-                    {
-                        Event_H0704Update(petId);
-                    }
-                    if (_DicPetBack[petId].PetStatus == 1)
-                    {
-                        PetNow = petId;
-                        if (Event_SpiritPetPlay != null && IsOk)
-                        {
-                            Event_SpiritPetPlay(petState);
-
-                        }
-                    }
-                }
-            }
-        }
-        PetStoneRed();
-        PetActivateRedPoint();
-        GetCultivateRedPoint();
-        GetPetMinAndMaxAttack();
-    }
-
-    public int[] GetUseDataModel(int key, Dictionary<int, int[]> useDataDict)
-    {
-        int[] list = null;
-        if (useDataDict != null)
-        {
-            useDataDict.TryGetValue(key, out list);
-        }
-        return list;
-    }
-
-    private void GetPetMinAndMaxAttack()
-    {
-        if (_DicPetBack.Count <= 0)
-        {
-            return;
-        }
-        MinAtkNunber = 0;
-        MaxAtkNunber = 0;
-        foreach (var key in _DicPetBack.Keys)
-        {
-            PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(key, _DicPetBack[key].PetClass);
-            MinAtkNunber += _tagPetClass.AtkAdd;
-            MaxAtkNunber += _tagPetClass.AtkAdd;
-        }
-    }
-
-    public static Regex userData = new Regex(@"'([0-9]+)':\[(.*?)\]", RegexOptions.Singleline);
-
-    public Dictionary<int, int[]> Analysis(string val)//姝e垯琛ㄨ揪寮忕殑瀛楃涓插垎鍓�
-    {
-        if (!userData.IsMatch(val))
-        {
-            return null;
-        }
-        else
-        {
-            Dictionary<int, int[]> dics = new Dictionary<int, int[]>();
-            foreach (Match match in userData.Matches(val))
-            {
-                int id = int.Parse(match.Groups[1].Value);
-                string str = match.Groups[2].Value;
-                string[] vals = str.Split(',');
-                int[] intarray = new int[vals.Length];
-                for (int i = 0; i < vals.Length; i++)
-                {
-                    int intval = int.Parse(vals[i].Replace('\'', ' '));
-                    intarray[i] = intval;
-                }
-                if (!dics.ContainsKey(id))
-                {
-                    dics.Add(id, intarray);
-                }
-            }
-            return dics;
-        }
-    }
-
-    public bool IsHint(PetEnum petEnum, int id = 0)//True鎻愮ず锛孎alse涓嶆彁绀�
-    {
-        bool iSHint = false;
-        switch (petEnum)
-        {
-            case PetEnum.PetDan:
-                foreach (var key in _DicPetBack.Keys)
-                {
-                    PetInfoConfig petConfig = PetInfoConfig.Get(key);
-                    if (petConfig.MaxRank > _DicPetBack[key].PetClass)
-                    {
-                        iSHint = true;
-                    }
-                }
-                return iSHint;
-            case PetEnum.PetDebris:
-                if (allPetConfigs.Count <= 0)
-                {
-                    allPetConfigs = PetInfoConfig.GetValues();
-                }
-                foreach (var value in allPetConfigs)
-                {
-                    if (value.UnLockNeedItemID == id)
-                    {
-                        if (!_DicPetBack.ContainsKey(value.ID))
-                        {
-                            iSHint = true;
-                        }
-                    }
-                }
-                return iSHint;
-            case PetEnum.PetStone:
-                int _maxuse = AttrFruitConfig.Get(id).MaxUseCnt;
-                if (_TagPetItem.ContainsKey(id))
-                {
-                    if (_maxuse > _TagPetItem[id])
-                    {
-                        iSHint = true;
-                    }
-                }
-                return iSHint;
-            default:
-                return true;
-        }
-    }
-
-    public int IsPetPanelRedPointState()//鐢ㄤ簬鍒ゆ柇褰撳墠鐏靛疇椤电鏄惁鏈夌孩鐐逛寒璧�
-    {
-        int Type = 0;
-        foreach (var value in DeblockingRedPoint.Values)
-        {
-            if (value.state == RedPointState.Simple)
-            {
-                Type = 2;
-                return Type;
-            }
-        }
-        if (MainRedDot.Instance.redPonintPetFunc2.state == RedPointState.Simple)
-        {
-            Type = 1;
-            return Type;
-        }
-        return Type;
-
-    }
-
-    #region 棰勮瀹犵墿纰庣墖灞炴��
-    Dictionary<int, int> petAttrDict = new Dictionary<int, int>();
-    public Dictionary<int, int> GetPetAttrAddDict(int petCode)
-    {
-        PetInfoConfig infoConfig = PetInfoConfig.Get(petCode);
-        petAttrDict.Clear();
-        if (infoConfig == null) return petAttrDict;
-
-        int maxRank = infoConfig.MaxRank;
-        PetClassCostConfig cost = PetClassCostConfig.GetPetIdAndRank(petCode, maxRank);
-        int allAtkAdd = 0;
-        if (cost != null)
-        {
-            allAtkAdd = cost.AtkAdd;
-        }
-        petAttrDict.Add(7, allAtkAdd);
-        return petAttrDict;
-    }
-    #endregion
+            IsOk = true;
+            if (PlayerLoginOkData != null)
+            {
+                PlayerLoginOkData();
+            }
+        }
 
-    #region 鎶�鑳芥暣鍚�
-    public ICollection<int> GetPetTotalSkills()
-    {
-        return petSkills.Keys;
-    }
-
-    public bool TryGetIntegrationSkill(int effect, out int skillId)
-    {
-        return integrationSkills.TryGetValue(effect, out skillId);
-    }
-
-    public bool TryGetPetSkills(int effect,out List<int> skills)
-    {
-        return integrationPetSkills.TryGetValue(effect, out skills);
-    }
-
-    public bool TryGetPetId(int skillId,out int petId)
-    {
-        return petSkills.TryGetValue(skillId, out petId);
-    }
-
-    public bool IsSkillUnlock(int skillId)
-    {
-        var config = SkillConfig.Get(skillId);
-        if (config == null)
+        private DateTime dateTimeA;
+        private void secondEvent()
         {
+            if (!Wait)
+            {
+                TimeSpan timeS = DateTime.Now - dateTimeA;
+                if (timeS.Seconds >= 2f)
+                {
+                    Wait = true;
+                }
+            }
+            else
+            {
+                dateTimeA = DateTime.Now;
+            }
+        }
+
+        #region 鍙戦�佹湇鍔$璇锋眰
+        public void SendPetSwitchQuest(int petIndex)
+        {
+            C1603_tagCPetStateChange tag_Cpet = new C1603_tagCPetStateChange();
+            tag_Cpet.PetID = (uint)petIndex;
+            tag_Cpet.State = 1;
+            GameNetSystem.Instance.SendInfo(tag_Cpet);
+        }
+
+        public void SendBreakPetLockQuest(int petId)
+        {
+            CA702_tagCMActivatePet CMPet = new CA702_tagCMActivatePet();
+            CMPet.PetNPCID = (uint)petId;
+            GameNetSystem.Instance.SendInfo(CMPet);
+            if (ItemOperateUtility.Instance.useItemModel != null)
+            {
+                ItemOperateUtility.Instance.useItemModel = null;
+            }
+        }
+
+        public void SendPetTrainQuest(int petIndex, int number)
+        {
+            CA704_tagCMPetClassUP _tagCA704 = new CA704_tagCMPetClassUP();
+            _tagCA704.PetItemIndex = (byte)petIndex;
+            _tagCA704.UseItemCnt = (ushort)number;
+            GameNetSystem.Instance.SendInfo(_tagCA704);
+        }
+        #endregion
+
+
+        private void OnItemRefreshEvent(PackType type, int index, int id)
+        {
+            PetH0704(playerPack.GetItemByIndex(type, index));
+            if (type == PackType.Item)
+            {
+                if (_TagPetItem.ContainsKey(id))
+                {
+                    PetStoneRed();
+                }
+                PetActivateRedPoint();
+                GetCultivateRedPoint();
+
+            }
+        }
+        private void OnFuncStateChange(int obj)
+        {
+            if (obj == 6)
+            {
+                PetStoneRed();
+                PetActivateRedPoint();
+                GetCultivateRedPoint();
+            }
+        }
+
+        private const int Redpoint_key1 = 1050201;
+        private Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_PetKey2, Redpoint_key1);
+        private void PetStoneRed()//鐏靛疇榄傜煶绾㈢偣
+        {
+            redPointStre1.state = RedPointState.None;
+            if (!FuncOpen.Instance.IsFuncOpen(6))
+            {
+                return;
+            }
+            int type = 0;
+            foreach (var key in _TagPetItem.Keys)
+            {
+                if (_TagPetItem[key] >= AttrFruitConfig.Get(key).MaxUseCnt)
+                {
+                    continue;
+                }
+                type += playerPack.GetItemCountByID(PackType.Item, key);
+
+            }
+            if (type > 0)
+            {
+                redPointStre1.state = RedPointState.Simple;
+                return;
+            }
+        }
+        private void PetNumberPreservation()//鐢ㄦ潵瀵圭伒瀹犱釜鏁拌繘琛屼繚瀛�
+        {
+            if (PetRedpoint.Count != 0)
+            {
+                return;
+            }
+            int type = 0;
+            if (allPetConfigs.Count <= 0)
+            {
+                allPetConfigs = PetInfoConfig.GetValues();
+            }
+            //  var allPetConfigs = PetInfoConfig.GetValues();
+            foreach (var config in allPetConfigs)
+            {
+                if (!DeblockingRedPoint.ContainsKey(config.ID))
+                {
+                    type += 1;
+                    int petID = config.ID;
+                    int RedPoint_Mountkey = MainRedDot.RedPoint_PetKey2 * 10 + type;
+                    Redpoint redPointMountStare = new Redpoint(MainRedDot.RedPoint_PetKey2, RedPoint_Mountkey);
+                    PetRedpoint.Add(petID, redPointMountStare);//鍒楄〃
+
+                    int RedPoint_Mountkey1 = RedPoint_Mountkey * 10 + type;
+                    Redpoint redPointMountStare1 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey1);
+                    DeblockingRedPoint.Add(petID, redPointMountStare1);//瑙i攣鎸夐挳
+                    int RedPoint_Mountkey2 = RedPoint_Mountkey1 * 10 + type;
+                    Redpoint redPointMountStare2 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey2);
+                    CultivateRedPoint.Add(petID, redPointMountStare2);
+                }
+            }
+        }
+
+        private void PetActivateRedPoint()//鐏靛疇婵�娲荤孩鐐�
+        {
+            foreach (var key in PetRedpoint.Keys)
+            {
+                DeblockingRedPoint[key].state = RedPointState.None;
+            }
+            if (!FuncOpen.Instance.IsFuncOpen(6))
+            {
+                return;
+            }
+            // var configs = PetInfoConfig.GetValues();
+            if (allPetConfigs.Count <= 0)
+            {
+                allPetConfigs = PetInfoConfig.GetValues();
+            }
+            foreach (var config in allPetConfigs)
+            {
+                int unlockItemID = config.UnLockNeedItemID;
+                int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID);
+                int unlockItemCnt = config.UnLockNeedItemCnt;
+                if (itemCount >= unlockItemCnt && !_DicPetBack.ContainsKey(config.ID) && FuncOpen.Instance.IsFuncOpen(6))
+                {
+                    DeblockingRedPoint[config.ID].state = RedPointState.Simple;
+                }
+            }
+        }
+        private void IsRedPointCultivate()
+        {
+            GetCultivateRedPoint();
+        }
+        private void ToAddSorting()
+        {
+            Sortpet.Clear();
+            if (allPetConfigs.Count <= 0)
+            {
+                allPetConfigs = PetInfoConfig.GetValues();
+            }
+            Sortpet = allPetConfigs;
+            Sortpet.Sort(Compare);
+        }
+        int Compare(PetInfoConfig x, PetInfoConfig y)//鏁扮粍鎺掑垪
+        {
+            if (x.Sort.CompareTo(y.Sort) != 0)
+            {
+                return x.Sort.CompareTo(y.Sort);
+            }
+            return 1;
+        }
+        public void GetCultivateRedPoint()//鐏靛疇鍩瑰吇绾㈢偣
+        {
+            foreach (var key in CultivateRedPoint.Keys)
+            {
+                CultivateRedPoint[key].state = RedPointState.None;
+            }
+            if (!FuncOpen.Instance.IsFuncOpen(6))
+            {
+                return;
+            }
+            if (_DicPetBack.Count <= 0)
+            {
+                return;
+            }
+            int GetPetId = 0;
+            int petLv = 100;
+            int itemCount = playerPack.GetItemCountByID(PackType.Item, 4151);
+            List<int> ListInt = new List<int>();
+            for (int i = 0; i < Sortpet.Count; i++)
+            {
+                int petID = Sortpet[i].ID;
+                int MaxLv = PetInfoConfig.Get(petID).MaxRank;
+                if (_DicPetBack.ContainsKey(petID) && _DicPetBack[petID].PetClass < MaxLv)
+                {
+                    int _NeedExp = PetClassCostConfig.GetPetIdAndRank(petID, _DicPetBack[petID].PetClass).UpNeedExp;
+                    int NeedExp = _NeedExp - _DicPetBack[petID].petExp;
+                    int NeedNumber = Mathf.CeilToInt((float)NeedExp / PetDanExp);
+                    if (itemCount >= NeedNumber)
+                    {
+                        ListInt.Add(petID);
+                    }
+                }
+            }
+
+            foreach (var key in _DicPetBack.Keys)//鍥犱负鏈夋垚灏变换鍔¢檺鍒舵墍鏈� 绗竴鍙潗楠戠孩鐐归�昏緫鐗规畩鍐�
+            {
+                if (DicDefaultPet.ContainsKey(key) && DicDefaultPet[key] > _DicPetBack[key].PetClass
+                    && itemCount > 0 && CultivateRedPoint.ContainsKey(key))
+                {
+                    CultivateRedPoint[key].state = RedPointState.Simple;
+                    return;
+                }
+            }
+            List<int> IntListSkill = new List<int>();
+            for (int i = 0; i < ListInt.Count; i++)//閫夋嫨鍑哄崌绾х伒瀹犵瓑绾ф渶浣庝笖鏈夋妧鑳芥湭瑙i攣鐨勪笖缁忛獙鏈�鎺ヨ繎
+            {
+                if (_DicPetBack.ContainsKey(ListInt[i]))
+                {
+                    var PetConfig = PetInfoConfig.Get(ListInt[i]);
+                    if (PetConfig == null)
+                    {
+                        return;
+                    }
+                    int[] SkillUnLockInt = PetConfig.SkillUnLock;
+                    int SkillLvMax = SkillUnLockInt[(SkillUnLockInt.Length - 1)];
+                    if (_DicPetBack[(ListInt[i])].PetClass < SkillLvMax)
+                    {
+                        IntListSkill.Add((ListInt[i]));
+                    }
+                }
+            }
+            int SkillPetId = GetRedPointPetID(IntListSkill);
+            if (SkillPetId != 0 && CultivateRedPoint.ContainsKey(SkillPetId))
+            {
+                CultivateRedPoint[SkillPetId].state = RedPointState.Simple;
+                return;
+            }
+
+
+            for (int i = 0; i < ListInt.Count; i++)//閫夋嫨鍑虹瓑绾ф渶浣庣殑鐏靛疇
+            {
+                if (_DicPetBack.ContainsKey(ListInt[i]))
+                {
+                    if (_DicPetBack[(ListInt[i])].PetClass < petLv)
+                    {
+                        petLv = _DicPetBack[(ListInt[i])].PetClass;
+                        GetPetId = (ListInt[i]);
+                    }
+                }
+            }
+            if (GetPetId != 0 && CultivateRedPoint.ContainsKey(GetPetId))
+            {
+                CultivateRedPoint[GetPetId].state = RedPointState.Simple;
+                return;
+            }
+        }
+
+
+        private int GetRedPointPetID(List<int> PetList)
+        {
+            int GetSkillMinLv = 999;
+            for (int i = 0; i < PetList.Count; i++)
+            {
+                int SkillminLv = GetSkillLvDis(PetList[i]);
+                if (SkillminLv < GetSkillMinLv && SkillminLv != 0)
+                {
+                    GetSkillMinLv = SkillminLv;
+                }
+            }
+
+            int petId = 0;
+            int ExpNumber = 999999999;
+            for (int i = 0; i < PetList.Count; i++)
+            {
+                int SkillLv = GetSkillLvDis(PetList[i]);
+                if (SkillLv > GetSkillMinLv || SkillLv == 0)
+                {
+                    continue;
+                }
+                var Pet1 = PetClassCostConfig.GetPetIdAndRank(PetList[i], SkillLv);
+                var Pet2 = PetClassCostConfig.GetPetIdAndRank(PetList[i], _DicPetBack[(PetList[i])].PetClass);
+                int Exp = Pet1.NeedExpTotal - Pet2.NeedExpTotal - _DicPetBack[(PetList[i])].petExp;
+                if (Exp < ExpNumber)
+                {
+                    ExpNumber = Exp;
+                    petId = PetList[i];
+                }
+            }
+            return petId;
+        }
+        private int GetSkillLvDis(int PetId)//鑾峰彇绂诲崌绾ф渶杩戠殑鎶�鑳界瓑绾�
+        {
+            int SkillLv = 0;
+            var petInfo = PetInfoConfig.Get(PetId);
+            if (petInfo == null)
+            {
+                return 0;
+            }
+            int[] ListPetSkillUnLock = petInfo.SkillUnLock;
+            for (int i = 0; i < ListPetSkillUnLock.Length; i++)
+            {
+                if (_DicPetBack.ContainsKey(PetId) && ListPetSkillUnLock[i] > _DicPetBack[PetId].PetClass)
+                {
+                    SkillLv = ListPetSkillUnLock[i];
+                    return SkillLv;
+                }
+            }
+            return SkillLv;
+        }
+        public int GetMinPetExp()
+        {
+            foreach (var key in CultivateRedPoint.Keys)//褰撳瓨鍦ㄥ煿鍏荤孩鐐规椂锛岄�変腑褰撴湁绾㈢偣鐨勯偅鍙�
+            {
+                if (CultivateRedPoint[key].state == RedPointState.Simple)
+                {
+                    return key;
+                }
+            }
+
+            List<int> IntListSkill = new List<int>();
+            foreach (var key in _DicPetBack.Keys)
+            {
+                var petConfig = PetInfoConfig.Get(key);
+                if (_DicPetBack[key].PetClass < petConfig.MaxRank)
+                {
+                    IntListSkill.Add(key);
+                }
+            }
+            int SkillPetId = GetRedPointPetID(IntListSkill);
+            if (SkillPetId != 0)
+            {
+                return SkillPetId;
+            }
+            int GetPetId = 0;
+            int GetPetLv = 999;
+
+            foreach (var key in _DicPetBack.Keys)//鏃犵孩鐐规椂璺宠浆閫変腑绛夌骇鏈�浣庣殑
+            {
+                var config = PetInfoConfig.Get(key);
+                if (_DicPetBack[key].PetClass < GetPetLv && _DicPetBack[key].PetClass < config.MaxRank)
+                {
+                    GetPetId = key;
+                    GetPetLv = _DicPetBack[key].PetClass;
+                }
+            }
+            return GetPetId;
+        }
+        private int GetPetSkillMaxLv(int PetID)
+        {
+            int maxskillLV = 0;
+            int[] curPetUnlocks;
+            PetInfoConfig petInfo = PetInfoConfig.Get(PetID);
+            if (petInfo != null)
+            {
+                curPetUnlocks = petInfo.SkillUnLock;
+                maxskillLV = curPetUnlocks[(curPetUnlocks.Length) - 1];
+            }
+            return maxskillLV;
+        }
+        public void PetA339(HA339_tagMCAttrFruitEatCntList info)
+        {
+            for (int i = 0; i < info.count; i++)
+            {
+                var configItem = ItemConfig.Get((int)info.EatCntList[i].ItemID);
+                if (configItem == null)
+                {
+                    continue;
+                }
+                if (_TagPetItem.ContainsKey((int)info.EatCntList[i].ItemID))
+                {
+                    _TagPetItem[(int)info.EatCntList[i].ItemID] = (int)info.EatCntList[i].EatCnt;
+                    if (Event_Ha339 != null)
+                        Event_Ha339(info);
+                }
+                else
+                {
+                    if (configItem.Type == 28)
+                    {
+                        _TagPetItem.Add((int)info.EatCntList[i].ItemID, (int)info.EatCntList[i].EatCnt);
+
+                    }
+                }
+            }
+            PetStoneRed();
+        }
+
+        private void AddPetSkill(int[] intlist)
+        {
+            for (int i = 0; i < intlist.Length; i++)
+            {
+                var skillPet = SkillConfig.Get(intlist[i]);
+                if (_PetSkillAcquire.ContainsKey(skillPet.SkillTypeID))
+                {
+                    int skilllv = SkillConfig.Get(_PetSkillAcquire[skillPet.SkillTypeID]).SkillLV;
+                    if (skillPet.SkillLV > skilllv)
+                    {
+                        _PetSkillAcquire[skillPet.SkillTypeID] = skillPet.SkillID;
+                    }
+                }
+                else
+                {
+                    _PetSkillAcquire.Add(skillPet.SkillTypeID, skillPet.SkillID);
+                }
+            }
+        }
+
+        public void PetH0704(ItemModel info)//瀹犵墿鑳屽寘鍒楄〃
+        {
+            if (info == null)
+                return;
+
+            if (info.packType == PackType.PetPack)
+            {
+                Dictionary<int, int[]> _dic = Analysis(info.itemInfo.userData);
+                if (GetUseDataModel(200, _dic) != null)
+                {
+                    int petId = _dic[200][0];
+                    int petLv = 0;
+                    int petState = 0;
+                    int[] petSkill = null;
+                    int petIndex = info.gridIndex;
+                    int petExp = 0;
+                    if (GetUseDataModel(201, _dic) != null)
+                    {
+                        petSkill = _dic[201];//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
+                    }
+
+                    if (GetUseDataModel(202, _dic) != null)
+                    {
+                        petLv = _dic[202][0] + 1;//瀹犵墿闃剁骇
+                    }
+
+                    if (GetUseDataModel(204, _dic) != null)
+                    {
+                        petState = _dic[204][0];//瀹犵墿褰撳墠鐘舵��;
+                    }
+
+                    if (GetUseDataModel(208, _dic) != null)
+                    {
+                        petExp = _dic[208][0]; //瀹犵墿缁忛獙
+                    }
+
+                    if (!_DicPetBack.ContainsKey(petId))
+                    {
+
+                        PetBackpack _petBack = new PetBackpack();
+                        _petBack.PetClass = petLv;
+                        _petBack.petExp = petExp; //瀹犵墿缁忛獙
+                        _petBack.PetStatus = petState;//瀹犵墿褰撳墠鐘舵��
+                        if (_petBack.PetStatus == 1)
+                        {
+                            PetNow = petId;
+                        }
+
+                        if (petSkill != null)
+                        {
+                            _petBack.PetSkill = petSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
+                            AddPetSkill(_petBack.PetSkill);
+                        }
+                        else
+                        {
+                            _petBack.PetSkill = null;
+                        }
+                        _petBack.ItemPlace = petIndex;//瀹犵墿浣嶇疆绱㈠紩
+                        _DicPetBack.Add(petId, _petBack);
+                        if (Event_H0704Add != null && IsOk)
+                        {
+                            Event_H0704Add();
+                        }
+
+                    }
+                    else
+                    {
+                        _DicPetBack[petId].PetClass = petLv;
+                        _DicPetBack[petId].PetStatus = petState;
+                        _DicPetBack[petId].petExp = petExp; //瀹犵墿缁忛獙
+                        if (petSkill != null)
+                        {
+                            _DicPetBack[petId].PetSkill = petSkill;//瀹犵墿褰撳墠瀛︿範鐨勬妧鑳�
+                            AddPetSkill(_DicPetBack[petId].PetSkill);
+                        }
+                        else
+                        {
+                            _DicPetBack[petId].PetSkill = null;
+                        }
+
+                        _DicPetBack[petId].ItemPlace = petIndex;
+                        if (Event_H0704Update != null && IsOk)
+                        {
+                            Event_H0704Update(petId);
+                        }
+                        if (_DicPetBack[petId].PetStatus == 1)
+                        {
+                            PetNow = petId;
+                            if (Event_SpiritPetPlay != null && IsOk)
+                            {
+                                Event_SpiritPetPlay(petState);
+
+                            }
+                        }
+                    }
+                }
+            }
+            PetStoneRed();
+            PetActivateRedPoint();
+            GetCultivateRedPoint();
+            GetPetMinAndMaxAttack();
+        }
+
+        public int[] GetUseDataModel(int key, Dictionary<int, int[]> useDataDict)
+        {
+            int[] list = null;
+            if (useDataDict != null)
+            {
+                useDataDict.TryGetValue(key, out list);
+            }
+            return list;
+        }
+
+        private void GetPetMinAndMaxAttack()
+        {
+            if (_DicPetBack.Count <= 0)
+            {
+                return;
+            }
+            MinAtkNunber = 0;
+            MaxAtkNunber = 0;
+            foreach (var key in _DicPetBack.Keys)
+            {
+                PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(key, _DicPetBack[key].PetClass);
+                MinAtkNunber += _tagPetClass.AtkAdd;
+                MaxAtkNunber += _tagPetClass.AtkAdd;
+            }
+        }
+
+        public static Regex userData = new Regex(@"'([0-9]+)':\[(.*?)\]", RegexOptions.Singleline);
+
+        public Dictionary<int, int[]> Analysis(string val)//姝e垯琛ㄨ揪寮忕殑瀛楃涓插垎鍓�
+        {
+            if (!userData.IsMatch(val))
+            {
+                return null;
+            }
+            else
+            {
+                Dictionary<int, int[]> dics = new Dictionary<int, int[]>();
+                foreach (Match match in userData.Matches(val))
+                {
+                    int id = int.Parse(match.Groups[1].Value);
+                    string str = match.Groups[2].Value;
+                    string[] vals = str.Split(',');
+                    int[] intarray = new int[vals.Length];
+                    for (int i = 0; i < vals.Length; i++)
+                    {
+                        int intval = int.Parse(vals[i].Replace('\'', ' '));
+                        intarray[i] = intval;
+                    }
+                    if (!dics.ContainsKey(id))
+                    {
+                        dics.Add(id, intarray);
+                    }
+                }
+                return dics;
+            }
+        }
+
+        public bool IsHint(PetEnum petEnum, int id = 0)//True鎻愮ず锛孎alse涓嶆彁绀�
+        {
+            bool iSHint = false;
+            switch (petEnum)
+            {
+                case PetEnum.PetDan:
+                    foreach (var key in _DicPetBack.Keys)
+                    {
+                        PetInfoConfig petConfig = PetInfoConfig.Get(key);
+                        if (petConfig.MaxRank > _DicPetBack[key].PetClass)
+                        {
+                            iSHint = true;
+                        }
+                    }
+                    return iSHint;
+                case PetEnum.PetDebris:
+                    if (allPetConfigs.Count <= 0)
+                    {
+                        allPetConfigs = PetInfoConfig.GetValues();
+                    }
+                    foreach (var value in allPetConfigs)
+                    {
+                        if (value.UnLockNeedItemID == id)
+                        {
+                            if (!_DicPetBack.ContainsKey(value.ID))
+                            {
+                                iSHint = true;
+                            }
+                        }
+                    }
+                    return iSHint;
+                case PetEnum.PetStone:
+                    int _maxuse = AttrFruitConfig.Get(id).MaxUseCnt;
+                    if (_TagPetItem.ContainsKey(id))
+                    {
+                        if (_maxuse > _TagPetItem[id])
+                        {
+                            iSHint = true;
+                        }
+                    }
+                    return iSHint;
+                default:
+                    return true;
+            }
+        }
+
+        public int IsPetPanelRedPointState()//鐢ㄤ簬鍒ゆ柇褰撳墠鐏靛疇椤电鏄惁鏈夌孩鐐逛寒璧�
+        {
+            int Type = 0;
+            foreach (var value in DeblockingRedPoint.Values)
+            {
+                if (value.state == RedPointState.Simple)
+                {
+                    Type = 2;
+                    return Type;
+                }
+            }
+            if (MainRedDot.Instance.redPonintPetFunc2.state == RedPointState.Simple)
+            {
+                Type = 1;
+                return Type;
+            }
+            return Type;
+
+        }
+
+        #region 棰勮瀹犵墿纰庣墖灞炴��
+        Dictionary<int, int> petAttrDict = new Dictionary<int, int>();
+        public Dictionary<int, int> GetPetAttrAddDict(int petCode)
+        {
+            PetInfoConfig infoConfig = PetInfoConfig.Get(petCode);
+            petAttrDict.Clear();
+            if (infoConfig == null) return petAttrDict;
+
+            int maxRank = infoConfig.MaxRank;
+            PetClassCostConfig cost = PetClassCostConfig.GetPetIdAndRank(petCode, maxRank);
+            int allAtkAdd = 0;
+            if (cost != null)
+            {
+                allAtkAdd = cost.AtkAdd;
+            }
+            petAttrDict.Add(7, allAtkAdd);
+            return petAttrDict;
+        }
+        #endregion
+
+        #region 鎶�鑳芥暣鍚�
+        public ICollection<int> GetPetTotalSkills()
+        {
+            return petSkills.Keys;
+        }
+
+        public bool TryGetIntegrationSkill(SkillEffectValue effect, out int skillId)
+        {
+            return integrationSkills.TryGetValue(effect, out skillId);
+        }
+
+        public bool TryGetPetSkills(SkillEffectValue effect, out List<int> skills)
+        {
+            return integrationPetSkills.TryGetValue(effect, out skills);
+        }
+
+        public bool TryGetPetId(int skillId, out int petId)
+        {
+            return petSkills.TryGetValue(skillId, out petId);
+        }
+
+        public bool IsSkillUnlock(int skillId)
+        {
+            var config = SkillConfig.Get(skillId);
+            if (config == null)
+            {
+                return false;
+            }
+            var effect = SkillConfig.GetSkillEffectValue(config);
+
+            if (integrationPetSkills.ContainsKey(effect)
+                && !integrationPetSkills[effect].Contains(skillId))
+            {
+                var skills = integrationPetSkills[effect];
+                foreach (var id in skills)
+                {
+                    if (IsSkillUnlock(id))
+                    {
+                        return true;
+                    }
+                }
+            }
+            else
+            {
+                if (petSkills.ContainsKey(skillId))
+                {
+                    var petId = petSkills[skillId];
+                    if (!_DicPetBack.ContainsKey(petId))
+                    {
+                        return false;
+                    }
+                    var petInfo = _DicPetBack[petId];
+                    if (petInfo.PetClass >= GetSkillUnlockLevel(skillId))
+                    {
+                        return true;
+                    }
+                }
+            }
             return false;
         }
-        if (integrationPetSkills.ContainsKey(config.Effect1)
-            && !integrationPetSkills[config.Effect1].Contains(skillId))
+
+        public int GetSkillUnlockLevel(int skillId)
         {
-            var skills = integrationPetSkills[config.Effect1];
-            foreach (var id in skills)
+            var petId = 0;
+            if (TryGetPetId(skillId, out petId))
             {
-                if (IsSkillUnlock(id))
+                var petConfig = PetInfoConfig.Get(petId);
+                var index = 0;
+                for (int i = 0; i < petConfig.SkillID.Length; i++)
                 {
-                    return true;
+                    if (petConfig.SkillID[i] == skillId)
+                    {
+                        index = i;
+                    }
+                }
+                if (index < petConfig.SkillUnLock.Length)
+                {
+                    return petConfig.SkillUnLock[index];
                 }
             }
+            return 0;
         }
-        else
-        {
-            if (petSkills.ContainsKey(skillId))
-            {
-                var petId = petSkills[skillId];
-                if (!_DicPetBack.ContainsKey(petId))
-                {
-                    return false;
-                }
-                var petInfo = _DicPetBack[petId];
-                if (petInfo.PetClass >= GetSkillUnlockLevel(skillId))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    public int GetSkillUnlockLevel(int skillId)
-    {
-        var petId = 0;
-        if (TryGetPetId(skillId, out petId))
-        {
-            var petConfig = PetInfoConfig.Get(petId);
-            var index = 0;
-            for (int i = 0; i < petConfig.SkillID.Length; i++)
-            {
-                if (petConfig.SkillID[i] == skillId)
-                {
-                    index = i;
-                }
-            }
-            if (index < petConfig.SkillUnLock.Length)
-            {
-                return petConfig.SkillUnLock[index];
-            }
-        }
-        return 0;
-    }
-    #endregion
+        #endregion
+    }
 }

--
Gitblit v1.8.0