| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Tuesday, November 14, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using TableConfig; |
| | | |
| | | using System; |
| | | using Snxxz.UI; |
| | | using System.Collections.Generic; |
| | | using EnhancedUI.EnhancedScroller; |
| | | |
| | | namespace Snxxz.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; |
| | | |
| | | private int typePetID = 0; |
| | | private float timePlay = 0;//灵宠动作播放时间 |
| | | PlayerPetDatas m_petModel; |
| | | PlayerPetDatas petmodel { get { return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>()); } } |
| | | GetItemPathModel pathModel { get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); } } |
| | | PlayerPackModel _playerPack; |
| | | PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } } |
| | | RidingAndPetActivationModel ridingModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } } |
| | | PetInfoConfig petInfoConfig; |
| | | bool isAutoTrain = false; |
| | | List<GameObject> Skillimage = new List<GameObject>(); |
| | | private void OnEnable() |
| | | { |
| | | timePlay = 0; |
| | | Skillimage.Clear(); |
| | | Skillimage.Add(Skillimage1); |
| | | Skillimage.Add(Skillimage2); |
| | | Skillimage.Add(Skillimage3); |
| | | isAutoTrain = false; |
| | | breakLockBtn.AddListener(ClickBreakBtn); |
| | | petAutoTrainBtn.AddListener(ClickPetAutoTrainBtn); |
| | | PlayerPetDatas.Event_H0704Update += RefreshPetInfo; |
| | | PlayerPetDatas.Event_H0704Add += RefreshPetInfo; |
| | | petStoneBtn.AddListener(() => { WindowCenter.Instance.Open<PetStoneTipsWin>(); }); |
| | | curPetSkillCtrl.OnRefreshCell += RefreshCurPetSkillCell; |
| | | allPetSkillCtrl.OnRefreshCell += RefreshAllPetSkillCell; |
| | | FlySkillIconWin.FlySkillID += FlySkillID; |
| | | CreateAllPetSkill(); |
| | | StartCoroutine(LoadingFrame()); |
| | | petTrainBtn.AddListener(ClickPetTrainBtn); |
| | | } |
| | | |
| | | IEnumerator LoadingFrame() |
| | | { |
| | | yield return null; |
| | | allPetSkillCtrl.JumpIndex(0); |
| | | } |
| | | private void OnDisable() |
| | | { |
| | | typePetID = 0; |
| | | StopCoroutine("FrameDelay"); |
| | | PlayerPetDatas.Event_H0704Update -= RefreshPetInfo; |
| | | PlayerPetDatas.Event_H0704Add -= RefreshPetInfo; |
| | | curPetSkillCtrl.OnRefreshCell -= RefreshCurPetSkillCell; |
| | | allPetSkillCtrl.OnRefreshCell -= RefreshAllPetSkillCell; |
| | | FlySkillIconWin.FlySkillID -= FlySkillID; |
| | | petStoneBtn.RemoveAllListeners(); |
| | | breakLockBtn.RemoveAllListeners(); |
| | | petTrainBtn.RemoveAllListeners(); |
| | | petAutoTrainBtn.RemoveAllListeners(); |
| | | } |
| | | |
| | | private void FlySkillID(int skillID) |
| | | { |
| | | int Index = 0; |
| | | if (petSkillIdlist.Contains(skillID)) |
| | | { |
| | | Index = petSkillIdlist.IndexOf(skillID); |
| | | } |
| | | int line = Index / 3; |
| | | allPetSkillCtrl.JumpIndex(line); |
| | | allPetSkillCtrl.JumpIndex(-50, 0, EnhancedScroller.TweenType.immediate); |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | timePlay += Time.deltaTime; |
| | | if (timePlay >= GeneralConfig.Instance.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 = ConfigParse.GetMultipleStr<int>(petInfoConfig.SkillID); |
| | | curPetUnlocks = ConfigParse.GetMultipleStr<int>(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>(); |
| | | 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); |
| | | |
| | | } |
| | | } |
| | | |
| | | List<int> petSkillIdlist = new List<int>(); |
| | | List<int> petSkillUnlockLvlist = new List<int>(); |
| | | List<bool> petSkillIsUnlocklist = new List<bool>(); |
| | | private void SetAllPetSkillModel() |
| | | { |
| | | petSkillUnlockLvlist.Clear(); |
| | | petSkillIdlist.Clear(); |
| | | petSkillIsUnlocklist.Clear(); |
| | | List<PetInfoConfig> list = ConfigManager.Instance.GetAllValues<PetInfoConfig>(); |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | if (petmodel._DicPetBack.ContainsKey(list[i].ID)) |
| | | { |
| | | PetBackpack _PetBackpack = petmodel._DicPetBack[list[i].ID]; |
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[i].SkillID); |
| | | int[] unlocks = ConfigParse.GetMultipleStr<int>(list[i].SkillUnLock); |
| | | for (int j = 0; j < ids.Length; j++) |
| | | { |
| | | if (_PetBackpack.PetClass >= unlocks[j]) |
| | | { |
| | | petSkillIdlist.Add(ids[j]); |
| | | petSkillUnlockLvlist.Add(unlocks[j]); |
| | | petSkillIsUnlocklist.Add(true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[i].SkillID); |
| | | int[] unlocks = ConfigParse.GetMultipleStr<int>(list[i].SkillUnLock); |
| | | if (petmodel._DicPetBack.ContainsKey(list[i].ID)) |
| | | { |
| | | PetBackpack _PetBackpack = petmodel._DicPetBack[list[i].ID]; |
| | | for (int j = 0; j < ids.Length; j++) |
| | | { |
| | | if (_PetBackpack.PetClass < unlocks[j]) |
| | | { |
| | | petSkillIdlist.Add(ids[j]); |
| | | petSkillUnlockLvlist.Add(unlocks[j]); |
| | | petSkillIsUnlocklist.Add(false); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int j = 0; j < ids.Length; j++) |
| | | { |
| | | petSkillIdlist.Add(ids[j]); |
| | | petSkillUnlockLvlist.Add(unlocks[j]); |
| | | petSkillIsUnlocklist.Add(false); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | private void CreateAllPetSkill() |
| | | { |
| | | SetAllPetSkillModel(); |
| | | if (allPetSkillCtrl.GetNumberOfCells(allPetSkillCtrl.m_Scorller) > 0) |
| | | { |
| | | allPetSkillCtrl.m_Scorller.RefreshActiveCellViews(); |
| | | } |
| | | else |
| | | { |
| | | allPetSkillCtrl.Refresh(); |
| | | int line = petSkillIdlist.Count / 3; |
| | | int remain = petSkillIdlist.Count % 3; |
| | | if (remain > 0) |
| | | { |
| | | line += 1; |
| | | } |
| | | 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 cellCnt = cell.index * 3 + (i + 1); |
| | | SkillButtonPet skillButton = cell.transform.GetChild(i).GetComponent<SkillButtonPet>(); |
| | | FunctionUnlockFlyObjectTarget functionUnlockFlyObjectTarget = cell.transform.GetChild(i).GetComponent<FunctionUnlockFlyObjectTarget>(); |
| | | int petId = 0; |
| | | List<PetInfoConfig> list = ConfigManager.Instance.GetAllValues<PetInfoConfig>(); |
| | | for (int j = 0; j < list.Count; j++) |
| | | { |
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[j].SkillID); |
| | | for (int k = 0; k < ids.Length; k++) |
| | | { |
| | | if (cellCnt <= petSkillIdlist.Count) |
| | | { |
| | | if (ids[k] == petSkillIdlist[cellCnt - 1]) |
| | | { |
| | | petId = list[j].ID; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | if (cellCnt <= petSkillIdlist.Count) |
| | | { |
| | | skillButton.gameObject.SetActive(true); |
| | | skillButton.SetModel(petSkillIdlist[cellCnt - 1], petSkillUnlockLvlist[cellCnt - 1], petSkillIsUnlocklist[cellCnt - 1], petId, SkillType.PetSkill, true); |
| | | functionUnlockFlyObjectTarget.IdList = new int[] { petSkillIdlist[cellCnt - 1] }; |
| | | functionUnlockFlyObjectTarget.Z_UnLockType = FunctionUnlockType.Skill; |
| | | FunctionUnlockFlyObjectTargetCenter.Register(FunctionUnlockType.Skill, new int[] { petSkillIdlist[cellCnt - 1] }, functionUnlockFlyObjectTarget); |
| | | } |
| | | else |
| | | { |
| | | skillButton.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | private void RefreshPetInfo() |
| | | { |
| | | if (petInfoConfig == null) return; |
| | | |
| | | 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 _MinNunber = 0; |
| | | int _MaxNumber = 0; |
| | | foreach (var key in petmodel._DicPetBack.Keys) |
| | | { |
| | | PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(key, petmodel._DicPetBack[key].PetClass); |
| | | _MinNunber += _tagPetClass.AtkAdd; |
| | | _MaxNumber += _tagPetClass.AtkAdd; |
| | | } |
| | | allAttackText.text = /*_MinNunber.ToString() + "-" +*/ ((int)(_MaxNumber + ridingModel.GetAllPetAddLife())).ToString(); |
| | | int sumFight = 0; |
| | | int InitFightPower = 0; |
| | | foreach (var petId in petmodel._DicPetBack.Keys) |
| | | { |
| | | int _scoreNum = 0; |
| | | int _scoreNumAll = 0; |
| | | PetInfoConfig config = ConfigManager.Instance.GetTemplate<PetInfoConfig>(petId); |
| | | InitFightPower += int.Parse(config.InitFightPower); |
| | | string[] strNumberSkill = config.SkillID.Split('|'); |
| | | string[] strSkillUnLock = config.SkillUnLock.Split('|'); |
| | | PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(petId, petmodel._DicPetBack[petId].PetClass); |
| | | for (int i = 0; i < strSkillUnLock.Length; i++) |
| | | { |
| | | if (petmodel._DicPetBack[petId].PetClass >= int.Parse(strSkillUnLock[i])) |
| | | { |
| | | SkillConfig skillconfig = ConfigManager.Instance.GetTemplate<SkillConfig>(int.Parse(strNumberSkill[i])); |
| | | if (skillconfig != null) |
| | | { |
| | | _scoreNum += skillconfig.FightPower; |
| | | } |
| | | } |
| | | } |
| | | _scoreNumAll = Mathf.FloorToInt(_tagPetClass.AtkAdd * 2.5f) + _scoreNum; |
| | | sumFight += _scoreNumAll; |
| | | } |
| | | allFightText.text = (sumFight + InitFightPower).ToString(); |
| | | attackSpeed.text = ((float)UIHelper.GetPropertyMapPlayerData(AttrEnum.ATKSPEED) / 100).ToString(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void RefreshPetUpgradeCostUI(bool isRefresh = false) |
| | | { |
| | | if (petInfoConfig == null) return; |
| | | |
| | | upgradeCostTip.SetActive(true); |
| | | ItemConfig itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(petmodel.petUpgradeToolId); |
| | | if (itemConfig != null) |
| | | { |
| | | m_PetDanIcon1.SetSprite(itemConfig.IconKey); |
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, 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.gameObject.SetActive(false); |
| | | if (isMaxRank) |
| | | { |
| | | petTrainBtn.gameObject.SetActive(false); |
| | | petAutoTrainBtn.gameObject.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | petTrainBtn.gameObject.SetActive(true); |
| | | petAutoTrainBtn.gameObject.SetActive(true); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | breakLockBtn.gameObject.SetActive(true); |
| | | petTrainBtn.gameObject.SetActive(false); |
| | | petAutoTrainBtn.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | private void ClickBreakBtn() |
| | | { |
| | | if (petInfoConfig == null) return; |
| | | |
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, 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.rptItem, petmodel.petUpgradeToolId); |
| | | if (haveCnt >= costNum) |
| | | { |
| | | if (petmodel._DicPetBack.ContainsKey(petInfoConfig.ID)) |
| | | { |
| | | petmodel.SendPetTrainQuest(petmodel._DicPetBack[petInfoConfig.ID].ItemPlace, 1); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(petmodel.petUpgradeToolId); |
| | | } |
| | | |
| | | |
| | | // petTrainBtn.RemoveAllListeners(); |
| | | } |
| | | |
| | | private void ClickPetAutoTrainBtn() |
| | | { |
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, petmodel.petUpgradeToolId); |
| | | if (haveCnt < costNum) |
| | | { |
| | | ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(petmodel.petUpgradeToolId); |
| | | return; |
| | | } |
| | | isAutoTrain = !isAutoTrain; |
| | | if (isAutoTrain) |
| | | { |
| | | CheckPetTrainCondi(); |
| | | } |
| | | else |
| | | { |
| | | petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6"); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void CheckPetTrainCondi() |
| | | { |
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, petmodel.petUpgradeToolId); |
| | | if (haveCnt >= costNum) |
| | | { |
| | | if (WindowCenter.Instance.CheckOpen<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); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | public void ModelShow(int PetID) |
| | | { |
| | | petmodel.curPetId = PetID; |
| | | isAutoTrain = false; |
| | | petInfoConfig = ConfigManager.Instance.GetTemplate<PetInfoConfig>(PetID); |
| | | 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.gameObject.SetActive(true); |
| | | |
| | | if (typePetID != PetID) |
| | | { |
| | | if (_uiEffect.IsPlaying) |
| | | { |
| | | _uiEffect.StopImediatly(); |
| | | } |
| | | typePetID = PetID; |
| | | timePlay = 0; |
| | | var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(PetID); |
| | | UI3DModelExhibition.Instance.BeginShowNPC(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 = ConfigManager.Instance.GetTemplate<PetInfoConfig>(PetID); |
| | | petAttrBtn.RemoveAllListeners(); |
| | | if (petmodel._DicPetBack.ContainsKey(PetID)) |
| | | { |
| | | petAttrBtn.gameObject.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.gameObject.SetActive(false); |
| | | m_RedPointreakLock.redpointId = petmodel.DeblockingRedPoint[PetID].id; |
| | | } |
| | | } |
| | | |
| | | void NotUnlock(int PetID) |
| | | { |
| | | FragmentUnlockTip.SetActive(true); |
| | | FullAttTip.SetActive(false); |
| | | PetInfoConfig PetModel = ConfigManager.Instance.GetTemplate<PetInfoConfig>(PetID); |
| | | ItemConfig _item = ConfigManager.Instance.GetTemplate<ItemConfig>(PetModel.UnLockNeedItemID); |
| | | ImageIcon.SetSprite(_item.IconKey); |
| | | m_BGM_Image.SetItemBackGround(_item.ItemColor); |
| | | if (playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) < PetModel.UnLockNeedItemCnt) |
| | | AttAddTxt.text = "<color=#ff4500>" + playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) + "</color>/" + PetModel.UnLockNeedItemCnt; |
| | | else |
| | | AttAddTxt.text = playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) + "/" + PetModel.UnLockNeedItemCnt; |
| | | FragmentBtn.RemoveAllListeners(); |
| | | FragmentBtn.AddListener(() => |
| | | { |
| | | pathModel.SetPetMatUnlockModel(_item.ID); |
| | | }); |
| | | } |
| | | |
| | | void FullOrderPanel(int PetID) |
| | | { |
| | | PetInfoConfig PetModel = ConfigManager.Instance.GetTemplate<PetInfoConfig>(PetID); |
| | | PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(PetID, PetModel.MaxRank); |
| | | FragmentUnlockTip.SetActive(false); |
| | | FullAttTip.SetActive(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, November 14, 2017
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | |
|
| | | using System;
|
| | | using Snxxz.UI;
|
| | | using System.Collections.Generic;
|
| | | using EnhancedUI.EnhancedScroller;
|
| | |
|
| | | namespace Snxxz.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] UIEffect m_UIeffect2;//经验条特效
|
| | | private int typePetID = 0;
|
| | | private float timePlay = 0;//灵宠动作播放时间
|
| | | PlayerPetDatas m_petModel;
|
| | | PlayerPetDatas petmodel { get { return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>()); } }
|
| | | GetItemPathModel pathModel { get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); } }
|
| | | PlayerPackModel _playerPack;
|
| | | PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } }
|
| | | RidingAndPetActivationModel ridingModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } }
|
| | | PetInfoConfig petInfoConfig;
|
| | | bool isAutoTrain = false;
|
| | | List<GameObject> Skillimage = new List<GameObject>();
|
| | | private void OnEnable()
|
| | | {
|
| | | timePlay = 0;
|
| | | Skillimage.Clear();
|
| | | Skillimage.Add(Skillimage1);
|
| | | Skillimage.Add(Skillimage2);
|
| | | Skillimage.Add(Skillimage3);
|
| | | isAutoTrain = false;
|
| | | breakLockBtn.AddListener(ClickBreakBtn);
|
| | | petAutoTrainBtn.AddListener(ClickPetAutoTrainBtn);
|
| | | PlayerPetDatas.Event_H0704Update += RefreshPetInfo;
|
| | | PlayerPetDatas.Event_H0704Add += RefreshPetInfo;
|
| | | petStoneBtn.AddListener(() => { WindowCenter.Instance.Open<PetStoneTipsWin>(); });
|
| | | curPetSkillCtrl.OnRefreshCell += RefreshCurPetSkillCell;
|
| | | allPetSkillCtrl.OnRefreshCell += RefreshAllPetSkillCell;
|
| | | FlySkillIconWin.FlySkillID += FlySkillID;
|
| | | CreateAllPetSkill();
|
| | | StartCoroutine(LoadingFrame());
|
| | | petTrainBtn.AddListener(ClickPetTrainBtn);
|
| | | }
|
| | |
|
| | | IEnumerator LoadingFrame()
|
| | | {
|
| | | yield return null;
|
| | | allPetSkillCtrl.JumpIndex(0);
|
| | | }
|
| | | private void OnDisable()
|
| | | {
|
| | | typePetID = 0;
|
| | | StopCoroutine("FrameDelay");
|
| | | PlayerPetDatas.Event_H0704Update -= RefreshPetInfo;
|
| | | PlayerPetDatas.Event_H0704Add -= RefreshPetInfo;
|
| | | curPetSkillCtrl.OnRefreshCell -= RefreshCurPetSkillCell;
|
| | | allPetSkillCtrl.OnRefreshCell -= RefreshAllPetSkillCell;
|
| | | FlySkillIconWin.FlySkillID -= FlySkillID;
|
| | | petStoneBtn.RemoveAllListeners();
|
| | | breakLockBtn.RemoveAllListeners();
|
| | | petTrainBtn.RemoveAllListeners();
|
| | | petAutoTrainBtn.RemoveAllListeners();
|
| | | }
|
| | |
|
| | | private void FlySkillID(int skillID)
|
| | | {
|
| | | int Index = 0;
|
| | | if (petSkillIdlist.Contains(skillID))
|
| | | {
|
| | | Index = petSkillIdlist.IndexOf(skillID);
|
| | | }
|
| | | int line = Index / 3;
|
| | | allPetSkillCtrl.JumpIndex(line);
|
| | | allPetSkillCtrl.JumpIndex(-50, 0, EnhancedScroller.TweenType.immediate);
|
| | | }
|
| | |
|
| | | private void LateUpdate()
|
| | | {
|
| | | timePlay += Time.deltaTime;
|
| | | if (timePlay >= GeneralConfig.Instance.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 = ConfigParse.GetMultipleStr<int>(petInfoConfig.SkillID);
|
| | | curPetUnlocks = ConfigParse.GetMultipleStr<int>(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>();
|
| | | 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);
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | List<int> petSkillIdlist = new List<int>();
|
| | | List<int> petSkillUnlockLvlist = new List<int>();
|
| | | List<bool> petSkillIsUnlocklist = new List<bool>();
|
| | | private void SetAllPetSkillModel()
|
| | | {
|
| | | petSkillUnlockLvlist.Clear();
|
| | | petSkillIdlist.Clear();
|
| | | petSkillIsUnlocklist.Clear();
|
| | | List<PetInfoConfig> list = Config.Instance.GetAllValues<PetInfoConfig>();
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | if (petmodel._DicPetBack.ContainsKey(list[i].ID))
|
| | | {
|
| | | PetBackpack _PetBackpack = petmodel._DicPetBack[list[i].ID];
|
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[i].SkillID);
|
| | | int[] unlocks = ConfigParse.GetMultipleStr<int>(list[i].SkillUnLock);
|
| | | for (int j = 0; j < ids.Length; j++)
|
| | | {
|
| | | if (_PetBackpack.PetClass >= unlocks[j])
|
| | | {
|
| | | petSkillIdlist.Add(ids[j]);
|
| | | petSkillUnlockLvlist.Add(unlocks[j]);
|
| | | petSkillIsUnlocklist.Add(true);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[i].SkillID);
|
| | | int[] unlocks = ConfigParse.GetMultipleStr<int>(list[i].SkillUnLock);
|
| | | if (petmodel._DicPetBack.ContainsKey(list[i].ID))
|
| | | {
|
| | | PetBackpack _PetBackpack = petmodel._DicPetBack[list[i].ID];
|
| | | for (int j = 0; j < ids.Length; j++)
|
| | | {
|
| | | if (_PetBackpack.PetClass < unlocks[j])
|
| | | {
|
| | | petSkillIdlist.Add(ids[j]);
|
| | | petSkillUnlockLvlist.Add(unlocks[j]);
|
| | | petSkillIsUnlocklist.Add(false);
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int j = 0; j < ids.Length; j++)
|
| | | {
|
| | | petSkillIdlist.Add(ids[j]);
|
| | | petSkillUnlockLvlist.Add(unlocks[j]);
|
| | | petSkillIsUnlocklist.Add(false);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | private void CreateAllPetSkill()
|
| | | {
|
| | | SetAllPetSkillModel();
|
| | | if (allPetSkillCtrl.GetNumberOfCells(allPetSkillCtrl.m_Scorller) > 0)
|
| | | {
|
| | | allPetSkillCtrl.m_Scorller.RefreshActiveCellViews();
|
| | | }
|
| | | else
|
| | | {
|
| | | allPetSkillCtrl.Refresh();
|
| | | int line = petSkillIdlist.Count / 3;
|
| | | int remain = petSkillIdlist.Count % 3;
|
| | | if (remain > 0)
|
| | | {
|
| | | line += 1;
|
| | | }
|
| | | 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 cellCnt = cell.index * 3 + (i + 1);
|
| | | SkillButtonPet skillButton = cell.transform.GetChild(i).GetComponent<SkillButtonPet>();
|
| | | FunctionUnlockFlyObjectTarget functionUnlockFlyObjectTarget = cell.transform.GetChild(i).GetComponent<FunctionUnlockFlyObjectTarget>();
|
| | | int petId = 0;
|
| | | List<PetInfoConfig> list = Config.Instance.GetAllValues<PetInfoConfig>();
|
| | | for (int j = 0; j < list.Count; j++)
|
| | | {
|
| | | int[] ids = ConfigParse.GetMultipleStr<int>(list[j].SkillID);
|
| | | for (int k = 0; k < ids.Length; k++)
|
| | | {
|
| | | if (cellCnt <= petSkillIdlist.Count)
|
| | | {
|
| | | if (ids[k] == petSkillIdlist[cellCnt - 1])
|
| | | {
|
| | | petId = list[j].ID;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | if (cellCnt <= petSkillIdlist.Count)
|
| | | {
|
| | | skillButton.gameObject.SetActive(true);
|
| | | skillButton.SetModel(petSkillIdlist[cellCnt - 1], petSkillUnlockLvlist[cellCnt - 1], petSkillIsUnlocklist[cellCnt - 1], petId, SkillType.PetSkill, true);
|
| | | functionUnlockFlyObjectTarget.IdList = new int[] { petSkillIdlist[cellCnt - 1] };
|
| | | functionUnlockFlyObjectTarget.Z_UnLockType = FunctionUnlockType.Skill;
|
| | | FunctionUnlockFlyObjectTargetCenter.Register(FunctionUnlockType.Skill, new int[] { petSkillIdlist[cellCnt - 1] }, functionUnlockFlyObjectTarget);
|
| | | }
|
| | | else
|
| | | {
|
| | | skillButton.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | | 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 = Config.Instance.Get<PetInfoConfig>(petId);
|
| | | InitFightPower += int.Parse(config.InitFightPower);
|
| | | string[] strNumberSkill = config.SkillID.Split('|');
|
| | | string[] strSkillUnLock = config.SkillUnLock.Split('|');
|
| | | PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(petId, petmodel._DicPetBack[petId].PetClass);
|
| | | for (int i = 0; i < strSkillUnLock.Length; i++)
|
| | | {
|
| | | if (petmodel._DicPetBack[petId].PetClass >= int.Parse(strSkillUnLock[i]))
|
| | | {
|
| | | SkillConfig skillconfig = Config.Instance.Get<SkillConfig>(int.Parse(strNumberSkill[i]));
|
| | | if (skillconfig != null)
|
| | | {
|
| | | _scoreNum += skillconfig.FightPower;
|
| | | }
|
| | | }
|
| | | }
|
| | | _scoreNumAll = Mathf.FloorToInt(_tagPetClass.AtkAdd * 2.5f) + _scoreNum;
|
| | | sumFight += _scoreNumAll;
|
| | | }
|
| | | allFightText.text = (sumFight + InitFightPower).ToString();
|
| | | attackSpeed.text = ((float)UIHelper.GetPropertyMapPlayerData(AttrEnum.ATKSPEED) / 100).ToString();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void RefreshPetUpgradeCostUI(bool isRefresh = false)
|
| | | {
|
| | | if (petInfoConfig == null) return;
|
| | |
|
| | | upgradeCostTip.SetActive(true);
|
| | | ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(petmodel.petUpgradeToolId);
|
| | | if (itemConfig != null)
|
| | | {
|
| | | m_PetDanIcon1.SetSprite(itemConfig.IconKey);
|
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, 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.gameObject.SetActive(false);
|
| | | if (isMaxRank)
|
| | | {
|
| | | petTrainBtn.gameObject.SetActive(false);
|
| | | petAutoTrainBtn.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | petTrainBtn.gameObject.SetActive(true);
|
| | | petAutoTrainBtn.gameObject.SetActive(true);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | breakLockBtn.gameObject.SetActive(true);
|
| | | petTrainBtn.gameObject.SetActive(false);
|
| | | petAutoTrainBtn.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | private void ClickBreakBtn()
|
| | | {
|
| | | if (petInfoConfig == null) return;
|
| | |
|
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, 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.rptItem, petmodel.petUpgradeToolId);
|
| | | if (haveCnt >= costNum)
|
| | | {
|
| | | if (petmodel._DicPetBack.ContainsKey(petInfoConfig.ID))
|
| | | {
|
| | | petmodel.SendPetTrainQuest(petmodel._DicPetBack[petInfoConfig.ID].ItemPlace, 1);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(petmodel.petUpgradeToolId);
|
| | | }
|
| | |
|
| | |
|
| | | // petTrainBtn.RemoveAllListeners();
|
| | | }
|
| | |
|
| | | private void ClickPetAutoTrainBtn()
|
| | | {
|
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, petmodel.petUpgradeToolId);
|
| | | if (haveCnt < costNum)
|
| | | {
|
| | | ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(petmodel.petUpgradeToolId);
|
| | | return;
|
| | | }
|
| | | isAutoTrain = !isAutoTrain;
|
| | | if (isAutoTrain)
|
| | | {
|
| | | CheckPetTrainCondi();
|
| | | }
|
| | | else
|
| | | {
|
| | | petAutoTrainText.text = Language.Get("PetWin_EvolveTrainBtn_6");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void CheckPetTrainCondi()
|
| | | {
|
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, petmodel.petUpgradeToolId);
|
| | | if (haveCnt >= costNum)
|
| | | {
|
| | | if (WindowCenter.Instance.CheckOpen<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);
|
| | | 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);
|
| | | }
|
| | | }
|
| | |
|
| | | public void ModelShow(int PetID)
|
| | | {
|
| | | petmodel.curPetId = PetID;
|
| | | isAutoTrain = false;
|
| | | petInfoConfig = Config.Instance.Get<PetInfoConfig>(PetID);
|
| | | 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.gameObject.SetActive(true);
|
| | |
|
| | | if (typePetID != PetID)
|
| | | {
|
| | | if (_uiEffect.IsPlaying)
|
| | | {
|
| | | _uiEffect.StopImediatly();
|
| | | }
|
| | | typePetID = PetID;
|
| | | timePlay = 0;
|
| | | var npcConfig = Config.Instance.Get<NPCConfig>(PetID);
|
| | | UI3DModelExhibition.Instance.BeginShowNPC(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 = Config.Instance.Get<PetInfoConfig>(PetID);
|
| | | petAttrBtn.RemoveAllListeners();
|
| | | if (petmodel._DicPetBack.ContainsKey(PetID))
|
| | | {
|
| | | petAttrBtn.gameObject.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.gameObject.SetActive(false);
|
| | | m_RedPointreakLock.redpointId = petmodel.DeblockingRedPoint[PetID].id;
|
| | | }
|
| | | }
|
| | |
|
| | | void NotUnlock(int PetID)
|
| | | {
|
| | | FragmentUnlockTip.SetActive(true);
|
| | | FullAttTip.SetActive(false);
|
| | | PetInfoConfig PetModel = Config.Instance.Get<PetInfoConfig>(PetID);
|
| | | ItemConfig _item = Config.Instance.Get<ItemConfig>(PetModel.UnLockNeedItemID);
|
| | | ImageIcon.SetSprite(_item.IconKey);
|
| | | m_BGM_Image.SetItemBackGround(_item.ItemColor);
|
| | | if (playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) < PetModel.UnLockNeedItemCnt)
|
| | | AttAddTxt.text = "<color=#ff4500>" + playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) + "</color>/" + PetModel.UnLockNeedItemCnt;
|
| | | else
|
| | | AttAddTxt.text = playerPack.GetItemCountByID(PackType.rptItem, PetModel.UnLockNeedItemID) + "/" + PetModel.UnLockNeedItemCnt;
|
| | | FragmentBtn.RemoveAllListeners();
|
| | | FragmentBtn.AddListener(() =>
|
| | | {
|
| | | pathModel.SetPetMatUnlockModel(_item.ID);
|
| | | });
|
| | | }
|
| | |
|
| | | void FullOrderPanel(int PetID)
|
| | | {
|
| | | PetInfoConfig PetModel = Config.Instance.Get<PetInfoConfig>(PetID);
|
| | | PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(PetID, PetModel.MaxRank);
|
| | | FragmentUnlockTip.SetActive(false);
|
| | | FullAttTip.SetActive(true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|