//--------------------------------------------------------  
 | 
//    [Author]:           第二世界  
 | 
//    [  Date ]:           Tuesday, November 14, 2017  
 | 
//--------------------------------------------------------  
 | 
using UnityEngine;  
 | 
using System.Collections;  
 | 
using UnityEngine.UI;  
 | 
  
 | 
  
 | 
using System;  
 | 
using vnxbqy.UI;  
 | 
using System.Collections.Generic;  
 | 
using EnhancedUI.EnhancedScroller;  
 | 
  
 | 
namespace vnxbqy.UI  
 | 
{  
 | 
  
 | 
    public class PetAttributeMethods : MonoBehaviour  
 | 
    {  
 | 
        [SerializeField] GameObject FragmentUnlockTip;//未解锁面板  
 | 
        [SerializeField] Image m_BGM_Image;//背景框  
 | 
        [SerializeField] Button FragmentBtn;//点击框  
 | 
        [SerializeField] Image ImageIcon;//材料图标  
 | 
        [SerializeField] Text AttAddTxt;//材料数量  
 | 
  
 | 
        [SerializeField] GameObject FullAttTip;//满阶面板  
 | 
        [SerializeField] UIEffect _uiEffect;//特效播放  
 | 
        [SerializeField] GameObject m_PetAttributeWin;  
 | 
        [SerializeField] RawImage _rawImage;  
 | 
  
 | 
        [Header("所有宠物属性加成")]  
 | 
        [SerializeField]  
 | 
        Text allFightText;  
 | 
        [SerializeField] Text allAttackText;  
 | 
        [SerializeField] Text attackSpeed;//攻击速度  
 | 
  
 | 
        [Header("进阶消耗")]  
 | 
        [SerializeField]  
 | 
        GameObject upgradeCostTip;  
 | 
        [SerializeField] Text petlvText;  
 | 
        [SerializeField] IntensifySmoothSlider _ExpSlider;//当前灵兽经验条  
 | 
        [SerializeField] Text expSliderText;  
 | 
        [SerializeField] int costNum = 1;  
 | 
        [SerializeField] float delayTime = 0.2f;  
 | 
        [Header("中间部分UI")]  
 | 
        [SerializeField]  
 | 
        Button petStoneBtn;  
 | 
        [SerializeField] Button petAttrBtn;  
 | 
        [SerializeField] Text curPetNameText;  
 | 
  
 | 
  
 | 
        [Header("宠物技能部分")]  
 | 
        [SerializeField]  
 | 
        ScrollerController curPetSkillCtrl;  
 | 
        [SerializeField] ScrollerController allPetSkillCtrl;  
 | 
  
 | 
        [Header("宠物功能按钮")]  
 | 
        [SerializeField]  
 | 
        Button breakLockBtn;//解锁按钮  
 | 
        [SerializeField] RedpointBehaviour m_RedPointreakLock;  
 | 
        [SerializeField] Button petTrainBtn;//培养按钮  
 | 
        [SerializeField] RedpointBehaviour m_RedPointpetTrain;  
 | 
        [SerializeField] Image m_PetDanIcon1;  
 | 
        [SerializeField] Text m_PetDanText;  
 | 
        [SerializeField] Button petAutoTrainBtn;  
 | 
        [SerializeField] Text petAutoTrainText;  
 | 
  
 | 
        [Header("控制绳子")]  
 | 
        [SerializeField]  
 | 
        GameObject Skillimage1;  
 | 
        [SerializeField]  
 | 
        GameObject Skillimage2;  
 | 
        [SerializeField]  
 | 
        GameObject Skillimage3;  
 | 
        [SerializeField]  
 | 
        GameObject Skillimage4;  
 | 
        [SerializeField]  
 | 
        GameObject Skillimage5;  
 | 
        [SerializeField]   
 | 
        UIEffect m_UIeffect2;//经验条特效  
 | 
        [SerializeField]   
 | 
        Button m_FosterUse;//经验条特效  
 | 
  
 | 
        private int typePetID = 0;  
 | 
        private float timePlay = 0;//灵宠动作播放时间  
 | 
        PetModel m_petModel;  
 | 
        PetModel petmodel { get { return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PetModel>()); } }  
 | 
        PackModel _playerPack;  
 | 
        PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } }  
 | 
        RidingAndPetActivationModel ridingModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } }  
 | 
        PetInfoConfig petInfoConfig;  
 | 
        bool isAutoTrain = false;  
 | 
        List<GameObject> Skillimage = new List<GameObject>();  
 | 
        private void OnEnable()  
 | 
        {  
 | 
            timePlay = 0;  
 | 
             
 | 
            isAutoTrain = false;  
 | 
            breakLockBtn.AddListener(ClickBreakBtn);  
 | 
            petAutoTrainBtn.AddListener(ClickPetAutoTrainBtn);  
 | 
            PetModel.Event_H0704Update += RefreshPetInfoUpdate;  
 | 
            PetModel.Event_H0704Add += RefreshPetInfo;  
 | 
            petStoneBtn.AddListener(() => { WindowCenter.Instance.Open<PetStoneTipsWin>(); });  
 | 
            curPetSkillCtrl.OnRefreshCell += RefreshCurPetSkillCell;  
 | 
            allPetSkillCtrl.OnRefreshCell += RefreshAllPetSkillCell;  
 | 
            CreateAllPetSkill();  
 | 
            StartCoroutine(LoadingFrame());  
 | 
            petTrainBtn.AddListener(ClickPetTrainBtn);  
 | 
            m_FosterUse.SetListener(CheckFosterButton);  
 | 
        }  
 | 
  
 | 
        IEnumerator LoadingFrame()  
 | 
        {  
 | 
            yield return null;  
 | 
            allPetSkillCtrl.JumpIndex(0);  
 | 
        }  
 | 
        private void OnDisable()  
 | 
        {  
 | 
            typePetID = 0;  
 | 
            StopCoroutine("FrameDelay");  
 | 
            PetModel.Event_H0704Update -= RefreshPetInfoUpdate;  
 | 
            PetModel.Event_H0704Add -= RefreshPetInfo;  
 | 
            curPetSkillCtrl.OnRefreshCell -= RefreshCurPetSkillCell;  
 | 
            allPetSkillCtrl.OnRefreshCell -= RefreshAllPetSkillCell;  
 | 
            petStoneBtn.RemoveAllListeners();  
 | 
            breakLockBtn.RemoveAllListeners();  
 | 
            petTrainBtn.RemoveAllListeners();  
 | 
            petAutoTrainBtn.RemoveAllListeners();  
 | 
        }  
 | 
  
 | 
        private void LateUpdate()  
 | 
        {  
 | 
            timePlay += Time.deltaTime;  
 | 
            if (timePlay >= GeneralDefine.PetDanceInterval)  
 | 
            {  
 | 
                timePlay = 0;  
 | 
                if (UI3DModelExhibition.Instance.NpcModelPet != null)  
 | 
                {  
 | 
                    var animator = UI3DModelExhibition.Instance.NpcModelPet.GetComponent<Animator>();  
 | 
                    if (animator != null)  
 | 
                    {  
 | 
                        StartCoroutine("FrameDelay");  
 | 
                    }  
 | 
                }  
 | 
  
 | 
            }  
 | 
        }  
 | 
        #region 修改部分  
 | 
        #region 宠物技能  
 | 
        int[] curPetSkillIds;  
 | 
        int[] curPetUnlocks;  
 | 
        private void CreateCurPetSkill()  
 | 
        {  
 | 
            curPetSkillIds = null;  
 | 
            curPetUnlocks = null;  
 | 
            if (petInfoConfig == null) return;  
 | 
  
 | 
            curPetSkillIds = petInfoConfig.SkillID;  
 | 
            curPetUnlocks = petInfoConfig.SkillUnLock;  
 | 
            curPetSkillCtrl.Refresh();  
 | 
            for (int i = 0; i < Skillimage.Count; i++)  
 | 
            {  
 | 
                Skillimage[i].SetActive(false);  
 | 
            }  
 | 
            for (int i = 0; i < curPetSkillIds.Length; i++)  
 | 
            {  
 | 
                if (i < Skillimage.Count)  
 | 
                {  
 | 
                    Skillimage[i].SetActive(true);  
 | 
                }  
 | 
                curPetSkillCtrl.AddCell(ScrollerDataType.Header, i);  
 | 
            }  
 | 
            curPetSkillCtrl.Restart();  
 | 
        }  
 | 
  
 | 
        private void RefreshCurPetSkillCell(ScrollerDataType type, CellView cell)  
 | 
        {  
 | 
            int skillIdIndex = cell.index;  
 | 
            SkillButtonPet skillButton = cell.transform.GetComponent<SkillButtonPet>();  
 | 
            FunctionUnlockFlyObjectTarget functionUnlockFlyObjectTarget = cell.transform.GetComponent<FunctionUnlockFlyObjectTarget>();  
 | 
            UIEffect uie = cell.transform.GetComponent<UIEffect>();  
 | 
            if (petmodel.ListEffectSkill.Contains(curPetSkillIds[skillIdIndex]))  
 | 
            {  
 | 
                uie.Play();  
 | 
            }  
 | 
            if (petmodel._DicPetBack.ContainsKey(petInfoConfig.ID))  
 | 
            {  
 | 
                PetBackpack _PetBackpack = petmodel._DicPetBack[petInfoConfig.ID];  
 | 
                if (_PetBackpack.PetClass >= curPetUnlocks[skillIdIndex])  
 | 
                {  
 | 
                    skillButton.SetModel(curPetSkillIds[skillIdIndex], curPetUnlocks[skillIdIndex], true, petInfoConfig.ID, SkillType.PetSkill);  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    skillButton.SetModel(curPetSkillIds[skillIdIndex], curPetUnlocks[skillIdIndex], false, petInfoConfig.ID, SkillType.PetSkill);  
 | 
                }  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                skillButton.SetModel(curPetSkillIds[skillIdIndex], curPetUnlocks[skillIdIndex], false, petInfoConfig.ID, SkillType.PetSkill);  
 | 
            }  
 | 
            functionUnlockFlyObjectTarget.IdList = new int[] { curPetSkillIds[skillIdIndex] };  
 | 
            functionUnlockFlyObjectTarget.Z_UnLockType = FunctionUnlockType.Skill;  
 | 
            FunctionUnlockFlyObjectTargetCenter.Register(FunctionUnlockType.Skill, new int[] { curPetSkillIds[skillIdIndex] }, functionUnlockFlyObjectTarget);  
 | 
        }  
 | 
  
 | 
        List<int> displayTotalSkills = new List<int>();  
 | 
        private void SetAllPetSkillModel()  
 | 
        {  
 | 
            displayTotalSkills.Clear();  
 | 
  
 | 
            var skills = petmodel.GetPetTotalSkills();  
 | 
            foreach (var id in skills)  
 | 
            {  
 | 
                var config = SkillConfig.Get(id);  
 | 
                var skillId = 0;  
 | 
                var effect = SkillConfig.GetSkillEffectValue(config);  
 | 
                if (petmodel.TryGetIntegrationSkill(effect, out skillId))  
 | 
                {  
 | 
                    if (!displayTotalSkills.Contains(skillId))  
 | 
                    {  
 | 
                        displayTotalSkills.Add(skillId);  
 | 
                    }  
 | 
                    continue;  
 | 
                }  
 | 
                displayTotalSkills.Add(id);  
 | 
            }  
 | 
  
 | 
            displayTotalSkills.Sort(Compare);  
 | 
        }  
 | 
  
 | 
        private void CreateAllPetSkill()  
 | 
        {  
 | 
            SetAllPetSkillModel();  
 | 
            if (allPetSkillCtrl.GetNumberOfCells(allPetSkillCtrl.m_Scorller) > 0)  
 | 
            {  
 | 
                allPetSkillCtrl.m_Scorller.RefreshActiveCellViews();  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                allPetSkillCtrl.Refresh();  
 | 
                var line = Mathf.CeilToInt((float)displayTotalSkills.Count / 3);  
 | 
                for (int i = 0; i < line; i++)  
 | 
                {  
 | 
                    allPetSkillCtrl.AddCell(ScrollerDataType.Header, i);  
 | 
                }  
 | 
                allPetSkillCtrl.Restart();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void RefreshAllPetSkillCell(ScrollerDataType type, CellView cell)  
 | 
        {  
 | 
            int length = cell.transform.childCount;  
 | 
            for (int i = 0; i < length; i++)  
 | 
            {  
 | 
                int index = cell.index * 3 + i;  
 | 
                SkillButtonPet skillButton = cell.transform.GetChild(i).GetComponent<SkillButtonPet>();  
 | 
                if (index < displayTotalSkills.Count)  
 | 
                {  
 | 
                    var skillId = displayTotalSkills[index];  
 | 
                    skillButton.SetActive(true);  
 | 
                    skillButton.SetModel(skillId, 0, petmodel.IsSkillUnlock(skillId), 0, SkillType.PetSkill, true);  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    skillButton.SetActive(false);  
 | 
                }  
 | 
            }  
 | 
        }  
 | 
  
 | 
        #endregion  
 | 
        private void RefreshPetInfoUpdate(int _petID)  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
            SoundPlayer.Instance.PlayUIAudio(19);  
 | 
            m_UIeffect2.Play();  
 | 
            AllPetAttrCtrl();  
 | 
            curPetSkillCtrl.m_Scorller.RefreshActiveCellViews();  
 | 
            CreateAllPetSkill();  
 | 
            PetPanelAssignment(petInfoConfig.ID, true);  
 | 
        }  
 | 
        private void RefreshPetInfo()  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
            SoundPlayer.Instance.PlayUIAudio(19);  
 | 
            m_UIeffect2.Play();  
 | 
            AllPetAttrCtrl();  
 | 
            curPetSkillCtrl.m_Scorller.RefreshActiveCellViews();  
 | 
            CreateAllPetSkill();  
 | 
            PetPanelAssignment(petInfoConfig.ID, true);  
 | 
        }  
 | 
        public void AllPetAttrCtrl()  
 | 
        {  
 | 
            if (petmodel._DicPetBack.Count <= 0)  
 | 
            {  
 | 
                allFightText.text = "0";  
 | 
                allAttackText.text = "0";  
 | 
                attackSpeed.text = "0";  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                int _MaxNumber = 0;  
 | 
                foreach (var key in petmodel._DicPetBack.Keys)  
 | 
                {  
 | 
                    PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(key, petmodel._DicPetBack[key].PetClass);  
 | 
                    _MaxNumber += _tagPetClass.AtkAdd;  
 | 
                }  
 | 
                allAttackText.text = ((int)(_MaxNumber + ridingModel.GetAllPetAddAttack())).ToString();  
 | 
                int sumFight = 0;  
 | 
                int InitFightPower = 0;  
 | 
                foreach (var petId in petmodel._DicPetBack.Keys)  
 | 
                {  
 | 
                    int _scoreNum = 0;  
 | 
                    int _scoreNumAll = 0;  
 | 
                    PetInfoConfig config = PetInfoConfig.Get(petId);  
 | 
                    InitFightPower += int.Parse(config.InitFightPower);  
 | 
                    int[] strNumberSkill = config.SkillID;  
 | 
                    int[] strSkillUnLock = config.SkillUnLock;  
 | 
                    PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(petId, petmodel._DicPetBack[petId].PetClass);  
 | 
                    for (int i = 0; i < strSkillUnLock.Length; i++)  
 | 
                    {  
 | 
                        if (petmodel._DicPetBack[petId].PetClass >= strSkillUnLock[i])  
 | 
                        {  
 | 
                            SkillConfig skillconfig = SkillConfig.Get(strNumberSkill[i]);  
 | 
                            if (skillconfig != null)  
 | 
                            {  
 | 
                                _scoreNum += skillconfig.FightPower;  
 | 
                            }  
 | 
                        }  
 | 
                    }  
 | 
                    Dictionary<int, int> Dic = new Dictionary<int, int>();  
 | 
                    Dic.Add(78, _tagPetClass.AtkAdd);  
 | 
                    Dic.Add(77, _tagPetClass.AtkAdd);  
 | 
                    _scoreNumAll = UIHelper.GetFightPower(Dic) + _scoreNum;  
 | 
                    sumFight += _scoreNumAll;  
 | 
                }  
 | 
                allFightText.text = (sumFight + InitFightPower).ToString();  
 | 
                attackSpeed.text = ((float)UIHelper.GetPropertyValue(PropertyType.ATKSPEED) / 100).ToString();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        public void RefreshPetUpgradeCostUI(bool isRefresh = false)  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
  
 | 
            upgradeCostTip.SetActive(true);  
 | 
            ItemConfig itemConfig = ItemConfig.Get(petmodel.petUpgradeToolId);  
 | 
            if (itemConfig != null)  
 | 
            {  
 | 
                m_PetDanIcon1.SetSprite(itemConfig.IconKey);  
 | 
                int haveCnt = playerPack.GetItemCountByID(PackType.Item, petmodel.petUpgradeToolId);  
 | 
                m_PetDanText.text = string.Format(Language.Get("Remaining_Z1"), UIHelper.ReplaceLargeNum(haveCnt));  
 | 
            }  
 | 
  
 | 
            StartCoroutine(PlayerTrainAni(isRefresh));  
 | 
        }  
 | 
  
 | 
        IEnumerator PlayerTrainAni(bool isRefresh = false)  
 | 
        {  
 | 
            PetBackpack _PetBackpack = petmodel._DicPetBack[petInfoConfig.ID];  
 | 
            PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(petInfoConfig.ID, _PetBackpack.PetClass);  
 | 
            petlvText.text = Language.Get("LoadIconLV", _PetBackpack.PetClass);  
 | 
            if (!isRefresh)  
 | 
            {  
 | 
                _ExpSlider.delay = 0;  
 | 
                _ExpSlider.ResetStage();  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                if (_PetBackpack.PetClass == 1 && _PetBackpack.petExp == 0)  
 | 
                {  
 | 
                    _ExpSlider.delay = 0;  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    _ExpSlider.delay = 0.1f;  
 | 
                }  
 | 
            }  
 | 
            _ExpSlider.stage = _PetBackpack.PetClass;  
 | 
            _ExpSlider.value = (float)Math.Round((double)_PetBackpack.petExp / _tagPetClass.UpNeedExp, 2, MidpointRounding.AwayFromZero);//经验条的初始化和刷新  
 | 
            expSliderText.text = StringUtility.Contact(_PetBackpack.petExp, "/", _tagPetClass.UpNeedExp);  
 | 
  
 | 
            yield return null;  
 | 
  
 | 
            if (isAutoTrain)  
 | 
            {  
 | 
                CheckPetTrainCondi();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void RefreshPetFuncBtn(bool isUnlock, bool isMaxRank)  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
  
 | 
            if (isUnlock)  
 | 
            {  
 | 
                breakLockBtn.SetActive(false);  
 | 
                if (isMaxRank)  
 | 
                {  
 | 
                    petTrainBtn.SetActive(false);  
 | 
                    petAutoTrainBtn.SetActive(false);  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    petTrainBtn.SetActive(true);  
 | 
                    petAutoTrainBtn.SetActive(true);  
 | 
                }  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                breakLockBtn.SetActive(true);  
 | 
                petTrainBtn.SetActive(false);  
 | 
                petAutoTrainBtn.SetActive(false);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void ClickBreakBtn()  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
  
 | 
            int haveCnt = playerPack.GetItemCountByID(PackType.Item, petInfoConfig.UnLockNeedItemID);  
 | 
            if (haveCnt >= petInfoConfig.UnLockNeedItemCnt)  
 | 
            {  
 | 
                petmodel.SendBreakPetLockQuest(petInfoConfig.ID);  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                ScrollTip.ShowTip(Language.Get("Z1812"));//未达到解锁条件  
 | 
            }  
 | 
        }  
 | 
  
 | 
          
 | 
        private void ClickPetTrainBtn()  
 | 
        {  
 | 
            if (petInfoConfig == null) return;  
 | 
  
 | 
            if (isAutoTrain)  
 | 
            {  
 | 
                isAutoTrain = false;  
 | 
                petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");  
 | 
            }  
 | 
  
 | 
            int haveCnt = playerPack.GetItemCountByID(PackType.Item, petmodel.petUpgradeToolId);  
 | 
            if (haveCnt >= costNum)  
 | 
            {  
 | 
                if (petmodel._DicPetBack.ContainsKey(petInfoConfig.ID))  
 | 
                {  
 | 
                    petmodel.SendPetTrainQuest(petmodel._DicPetBack[petInfoConfig.ID].ItemPlace, 1);  
 | 
                }  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                ItemTipUtility.Show(petmodel.petUpgradeToolId);  
 | 
            }  
 | 
            int petQuality = PetInfoConfig.Get(ModelCenter.Instance.GetModel<PetModel>().TypePetID).Quality;  
 | 
            if (petQuality != 7)  
 | 
                LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(8, petmodel.petUpgradeToolId, costNum, 1, 0);  
 | 
            if (petQuality == 7)  
 | 
                LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(9, petmodel.petUpgradeToolId, costNum, 1, 0);  
 | 
  
 | 
  
 | 
  
 | 
            // petTrainBtn.RemoveAllListeners();  
 | 
        }  
 | 
  
 | 
        private void ClickPetAutoTrainBtn()  
 | 
        {  
 | 
            int haveCnt = playerPack.GetItemCountByID(PackType.Item, petmodel.petUpgradeToolId);  
 | 
            if (haveCnt < costNum)  
 | 
            {  
 | 
                ItemTipUtility.Show(petmodel.petUpgradeToolId);  
 | 
                return;  
 | 
            }  
 | 
  
 | 
            isAutoTrain = !isAutoTrain;  
 | 
            if (isAutoTrain)  
 | 
            {  
 | 
                CheckPetTrainCondi();  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");  
 | 
            }  
 | 
  
 | 
        }  
 | 
  
 | 
          
 | 
        public void CheckPetTrainCondi()  
 | 
        {  
 | 
            int haveCnt = playerPack.GetItemCountByID(PackType.Item, petmodel.petUpgradeToolId);  
 | 
  
 | 
  
 | 
            if (haveCnt >= costNum)  
 | 
            {  
 | 
                if (WindowCenter.Instance.IsOpen<RidingAndPetActivationWin>())  
 | 
                {  
 | 
                    petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");  
 | 
                    isAutoTrain = false;  
 | 
                    return;  
 | 
                }  
 | 
                petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_7");  
 | 
                if (petmodel._DicPetBack.ContainsKey(petInfoConfig.ID))  
 | 
                {  
 | 
  
 | 
                    int exp = PetClassCostConfig.GetPetIdAndRank(petInfoConfig.ID, petmodel._DicPetBack[petInfoConfig.ID].PetClass).UpNeedExp;  
 | 
                    int NeedNum = ridingModel.PetAndHorseNeedDanNum(exp);  
 | 
                    int petQuality = PetInfoConfig.Get(ModelCenter.Instance.GetModel<PetModel>().TypePetID).Quality;  
 | 
                    if (petQuality != 7)  
 | 
                        LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(8, petmodel.petUpgradeToolId, NeedNum, 1, 0);  
 | 
                    if (petQuality == 7)  
 | 
                        LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(9, petmodel.petUpgradeToolId, NeedNum, 1, 0);  
 | 
                    if (haveCnt >= NeedNum)  
 | 
                    {  
 | 
                        if (petmodel.Wait)  
 | 
                        {  
 | 
                            petmodel.Wait = false;  
 | 
                            petmodel.SendPetTrainQuest(petmodel._DicPetBack[petInfoConfig.ID].ItemPlace, NeedNum);  
 | 
                        }  
 | 
                    }  
 | 
                    else  
 | 
                    {  
 | 
                        if (petmodel.Wait)  
 | 
                        {  
 | 
                            petmodel.Wait = false;  
 | 
                            petmodel.SendPetTrainQuest(petmodel._DicPetBack[petInfoConfig.ID].ItemPlace, haveCnt);  
 | 
                        }  
 | 
                    }  
 | 
  
 | 
  
 | 
                }  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");  
 | 
                isAutoTrain = false;  
 | 
  
 | 
            }  
 | 
        }  
 | 
        #endregion  
 | 
  
 | 
        IEnumerator FrameDelay()  
 | 
        {  
 | 
            yield return null;  
 | 
            if (UI3DModelExhibition.Instance.NpcModelPet)  
 | 
            {  
 | 
                var animator = UI3DModelExhibition.Instance.NpcModelPet.GetComponent<Animator>();  
 | 
                animator.Play(GAStaticDefine.State_Dance);  
 | 
            }  
 | 
        }  
 | 
        void CheckFosterButton()  
 | 
        {  
 | 
            if (!petmodel.CheckPetNow())  
 | 
            {  
 | 
                SysNotifyMgr.Instance.ShowTip("FosterPetLockFail");  
 | 
                return;  
 | 
            }  
 | 
                 
 | 
            if(FosterModel.Instance.CheckPetOpen(true))  
 | 
            {  
 | 
                WindowCenter.Instance.Open("FosterWin");  
 | 
            }             
 | 
        }  
 | 
          
 | 
        public void ModelShow(int PetID)  
 | 
        {  
 | 
            SetSkillimage();  
 | 
            petmodel.curPetId = PetID;  
 | 
            isAutoTrain = false;  
 | 
            petInfoConfig = PetInfoConfig.Get(PetID);  
 | 
            if (petInfoConfig.Quality == 7)  
 | 
            {  
 | 
                petmodel.petUpgradeToolId = 4150;  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                petmodel.petUpgradeToolId = 4151;  
 | 
            }  
 | 
            LoadingShowNPC(PetID);  
 | 
            petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");  
 | 
            PetPanelAssignment(PetID);  
 | 
            CreateCurPetSkill();  
 | 
            curPetNameText.text = petInfoConfig.Name;  
 | 
            AllPetAttrCtrl();  
 | 
  
 | 
            if (WindowCenter.Instance.Get<PetAttributeWin>().AchievementGuideEffect2 != null)  
 | 
            {  
 | 
                AchievementGuideEffectPool.Recycle(WindowCenter.Instance.Get<PetAttributeWin>().AchievementGuideEffect2);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        void LoadingShowNPC(int PetID)  
 | 
        {  
 | 
            _rawImage.SetActive(true);  
 | 
  
 | 
            if (typePetID != PetID)  
 | 
            {  
 | 
                if (_uiEffect.IsPlaying)  
 | 
                {  
 | 
                    _uiEffect.StopImediatly();  
 | 
                }  
 | 
                typePetID = PetID;  
 | 
                timePlay = 0;  
 | 
                var npcConfig = NPCConfig.Get(PetID);  
 | 
                UI3DModelExhibition.Instance.ShowNPC(PetID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, _rawImage);  
 | 
                if (UI3DModelExhibition.Instance.NpcModelPet != null)  
 | 
                {  
 | 
                    var animator = UI3DModelExhibition.Instance.NpcModelPet.GetComponent<Animator>();  
 | 
                    if (animator != null)  
 | 
                    {  
 | 
                        if (m_PetAttributeWin.activeSelf)  
 | 
                        {  
 | 
                            StartCoroutine("FrameDelay");  
 | 
                        }  
 | 
                        else  
 | 
                        {  
 | 
                            animator.Play(GAStaticDefine.State_Dance);  
 | 
                        }  
 | 
                    }  
 | 
                }  
 | 
            }  
 | 
        }  
 | 
  
 | 
        public void PetPanelAssignment(int PetID, bool isRefresh = false)//关于面板赋值选择  
 | 
        {  
 | 
            PetInfoConfig PetModel = PetInfoConfig.Get(PetID);  
 | 
            petAttrBtn.RemoveAllListeners();  
 | 
            if (petmodel._DicPetBack.ContainsKey(PetID))  
 | 
            {  
 | 
                petAttrBtn.SetActive(true);  
 | 
                FragmentUnlockTip.SetActive(false);  
 | 
                petAttrBtn.AddListener(() =>  
 | 
                {  
 | 
                    ridingModel.property = PropertyTip.Pet;  
 | 
                    ridingModel.RidingId = PetID;  
 | 
                    WindowCenter.Instance.Open<TargetPetAttrWin>();  
 | 
                    //  WindowCenter.Instance.Get<TargetPetAttrWin>().PropertyMountAndPet(PropertyTip.Pet, PetID);  
 | 
  
 | 
                });  
 | 
                if (petmodel._DicPetBack[PetID].PetClass >= PetModel.MaxRank)//满阶  
 | 
                {  
 | 
                    RefreshPetFuncBtn(true, true);  
 | 
                    upgradeCostTip.SetActive(false);  
 | 
                    FullOrderPanel(PetID);  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    FullAttTip.SetActive(false);  
 | 
                    RefreshPetUpgradeCostUI(isRefresh);  
 | 
                    RefreshPetFuncBtn(true, false);  
 | 
                    m_RedPointpetTrain.redpointId = petmodel.CultivateRedPoint[PetID].id;  
 | 
                }  
 | 
            }  
 | 
            else//未解锁  
 | 
            {  
 | 
                RefreshPetFuncBtn(false, false);  
 | 
                upgradeCostTip.SetActive(false);  
 | 
                NotUnlock(PetID);  
 | 
                petAttrBtn.SetActive(false);  
 | 
                m_RedPointreakLock.redpointId = petmodel.DeblockingRedPoint[PetID].id;  
 | 
            }  
 | 
        }  
 | 
  
 | 
        void NotUnlock(int PetID)  
 | 
        {  
 | 
            FragmentUnlockTip.SetActive(true);  
 | 
            FullAttTip.SetActive(false);  
 | 
            PetInfoConfig PetModel = PetInfoConfig.Get(PetID);  
 | 
            ItemConfig _item = ItemConfig.Get(PetModel.UnLockNeedItemID);  
 | 
            ImageIcon.SetSprite(_item.IconKey);  
 | 
            m_BGM_Image.SetItemBackGround(_item.ItemColor);  
 | 
            if (playerPack.GetItemCountByID(PackType.Item, PetModel.UnLockNeedItemID) < PetModel.UnLockNeedItemCnt)  
 | 
                AttAddTxt.text = "<color=#ff4500>" + playerPack.GetItemCountByID(PackType.Item, PetModel.UnLockNeedItemID) + "</color>/" + PetModel.UnLockNeedItemCnt;  
 | 
            else  
 | 
                AttAddTxt.text = playerPack.GetItemCountByID(PackType.Item, PetModel.UnLockNeedItemID) + "/" + PetModel.UnLockNeedItemCnt;  
 | 
            FragmentBtn.RemoveAllListeners();  
 | 
            FragmentBtn.AddListener(() =>  
 | 
            {  
 | 
                ItemTipUtility.Show(_item.ID);  
 | 
            });  
 | 
        }  
 | 
  
 | 
        void FullOrderPanel(int PetID)  
 | 
        {  
 | 
            PetInfoConfig PetModel = PetInfoConfig.Get(PetID);  
 | 
            PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(PetID, PetModel.MaxRank);  
 | 
            FragmentUnlockTip.SetActive(false);  
 | 
            FullAttTip.SetActive(true);  
 | 
        }  
 | 
        private void SetSkillimage()  
 | 
        {  
 | 
            if (Skillimage.Count <= 0)  
 | 
            {  
 | 
                Skillimage.Add(Skillimage1);  
 | 
                Skillimage.Add(Skillimage2);  
 | 
                Skillimage.Add(Skillimage3);  
 | 
                Skillimage.Add(Skillimage4);  
 | 
                Skillimage.Add(Skillimage5);  
 | 
            }          
 | 
        }  
 | 
  
 | 
        int Compare(int lhs, int rhs)  
 | 
        {  
 | 
            var lhs_unlock = petmodel.IsSkillUnlock(lhs);  
 | 
            var rhs_unlock = petmodel.IsSkillUnlock(rhs);  
 | 
            if (lhs_unlock != rhs_unlock)  
 | 
            {  
 | 
                return -lhs_unlock.CompareTo(rhs_unlock);  
 | 
            }  
 | 
            var lhs_config = SkillConfig.Get(lhs);  
 | 
            var rhs_config = SkillConfig.Get(rhs);  
 | 
            var lhs_Id = 0;  
 | 
            var rhs_Id = 0;  
 | 
            var lhs_effect = SkillConfig.GetSkillEffectValue(lhs_config);  
 | 
            var rhs_effect = SkillConfig.GetSkillEffectValue(rhs_config);  
 | 
            var lhs_integration = petmodel.TryGetIntegrationSkill(lhs_effect, out lhs_Id);  
 | 
            var rhs_integration = petmodel.TryGetIntegrationSkill(rhs_effect, out rhs_Id);  
 | 
            if (lhs_integration != rhs_integration)  
 | 
            {  
 | 
                return -lhs_integration.CompareTo(rhs_integration);  
 | 
            }  
 | 
            if (lhs_integration && rhs_integration)  
 | 
            {  
 | 
                return lhs_config.Effect1.CompareTo(rhs_config.Effect1);  
 | 
            }  
 | 
            var lhs_petId = 0;  
 | 
            var rhs_petId = 0;  
 | 
            petmodel.TryGetPetId(lhs, out lhs_petId);  
 | 
            petmodel.TryGetPetId(rhs, out rhs_petId);  
 | 
            var lhs_petconfig = PetInfoConfig.Get(lhs_petId);  
 | 
            var rhs_petconfig = PetInfoConfig.Get(rhs_petId);  
 | 
            return lhs_petconfig.Sort.CompareTo(rhs_petconfig.Sort);  
 | 
        }  
 | 
    }  
 | 
}  
 | 
  
 | 
  
 | 
  
 |