using System; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; using UnityEngine; namespace vnxbqy.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,//灵宠魂石 //后续IL开发添加预设 default1, default2, default3, default4, default5, } public interface IPetHorseAwaking { event Action onFuncStateUpdate; bool IsOpen(); int GetPetHorseEffect(int id, int skinIndex); string GetPetHorseEffectNode(int id, int skinIndex); } public class PetModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { public Dictionary _TagPetItem = new Dictionary();//关于灵兽魂石 public Dictionary _DicPetBack = new Dictionary();//宠物背包列表 public Dictionary _PetSkillAcquire = new Dictionary();//灵宠已获得的技能(同类技能只存最高等级)1.技能TypeID,2.技能ID 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 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 DeblockingRedPoint = new Dictionary();//解锁按钮红点(灵宠红点子级) public Dictionary PetRedpoint = new Dictionary();//灵宠列表 public Dictionary CultivateRedPoint = new Dictionary();//灵宠培养按钮红点 private List Sortpet = new List();//用于红点排序 public int MinAtkNunber = 0;//灵宠最小攻击力 public int MaxAtkNunber = 0;//灵宠最大攻击力 public int PetStoneItemId = 0;//用来记录坐骑魂石的ID public bool isServerPrepare { get; private set; } private int PetDanExp = 0;//灵宠丹经验 public List ListEffectSkill = new List(); PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } public Dictionary petLvNameDict { get; private set; } public int curPetId { get; set; } public int petUpgradeToolId { get; set; } public int autoActivePetId { get; private set; } public bool hasSendAutoActive { get; private set; } public event Action PlayerLoginOkData; public event Action onPetInfoUpdate; private Dictionary DicDefaultPet = new Dictionary(); List allPetConfigs = new List(); Dictionary integrationSkills = new Dictionary(); Dictionary> integrationPetSkills = new Dictionary>(); Dictionary petSkillEffectValues = new Dictionary(); Dictionary petSkills = new Dictionary(); public int FosterPetID; //当前出战的Pet public int TypePetID;//用来标记当前选中的灵宠ID public override void Init() { ToAddSorting(); playerPack.refreshItemCountEvent += OnItemRefreshEvent; FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange; PetAttributeWin.IsRedPointCultivate += IsRedPointCultivate; PetNumberPreservation(); petLvNameDict = new Dictionary(); FuncConfigConfig petLvName = FuncConfigConfig.Get("PetQuality"); int[] petLvArray = ConfigParse.GetMultipleStr(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(str); ListEffectSkill.Clear(); for (int i = 0; i < listeffect.Length; i++) { ListEffectSkill.Add(listeffect[i]); } string PetRedDotstr = FuncConfigConfig.Get("MountPetRedDot").Numerical2; DicDefaultPet = ConfigParse.GetDic(PetRedDotstr); PetDanExp = int.Parse(FuncConfigConfig.Get("PetUpItem").Numerical2); var funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration"); var intArray = ConfigParse.GetMultipleStr(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]); } } funcConfig = FuncConfigConfig.Get("AutoActivePetHorse"); autoActivePetId = int.Parse(funcConfig.Numerical1); 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 skills = null; if (!integrationPetSkills.TryGetValue(effectValue, out skills)) { skills = new List(); integrationPetSkills.Add(effectValue, skills); } skills.Add(config.SkillID[i]); } petSkills.Add(config.SkillID[i], config.ID); petSkillEffectValues.Add(config.SkillID[i], effectValue); } } } public override void UnInit() { playerPack.refreshItemCountEvent -= OnItemRefreshEvent; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange; PetAttributeWin.IsRedPointCultivate -= IsRedPointCultivate; } public void OnBeforePlayerDataInitialize() { Wait = true; isServerPrepare = false; hasSendAutoActive = 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); } singPack = playerPack.GetSinglePack(PackType.Item); if (singPack == null) return; foreach (var index in singPack.GetAllItems().Keys) { OnItemRefreshEvent(singPack.type, index, singPack.GetAllItems()[index].itemId); } isServerPrepare = true; if (PlayerLoginOkData != null) { PlayerLoginOkData(); } } private DateTime dateTimeA; private void secondEvent() { CheckRedPoint(); if (!Wait) { TimeSpan timeS = DateTime.Now - dateTimeA; if (timeS.Seconds >= 2f) { Wait = true; } } else { dateTimeA = DateTime.Now; } } #region 发送服务端请求 public void SendPetSwitchQuest(int petIndex) { if (PlayerDatas.Instance.baseData.HP <= 0) { SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_740826"); return; } 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(); var config = PetInfoConfig.Get(autoActivePetId); if (config != null && id == config.UnLockNeedItemID) { TryAutoActivePet(); } ForsterPetRed(id); } } //培养石头 public void ForsterPetRed(int id)//培养石头红点 { if (!CheckPetNow()) { return; } for (int i = 0; i < GeneralDefine.PetTrainIDList.Length; i++) { if (GeneralDefine.PetTrainIDList[i] == id) { redPointStre2.state = RedPointState.None; if (FosterModel.Instance.GetPetRedPointUpdate(i, id)) { redPointStre2.state = RedPointState.Simple; } } } } private void OnFuncStateChange(int funcId) { if (funcId == (int)FuncOpenEnum.Pet) { PetStoneRed(); PetActivateRedPoint(); GetCultivateRedPoint(); TryAutoActivePet(); } } private void TryAutoActivePet() { if (isServerPrepare && FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Pet) && !_DicPetBack.ContainsKey(autoActivePetId) && !hasSendAutoActive) { var petConfig = PetInfoConfig.Get(autoActivePetId); if (petConfig != null) { var itemCount = playerPack.GetItemCountByID(PackType.Item, petConfig.UnLockNeedItemID); if (itemCount >= petConfig.UnLockNeedItemCnt) { hasSendAutoActive = true; SendBreakPetLockQuest(autoActivePetId); } } } } private const int Redpoint_key1 = 1050201; private Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_PetKey2, Redpoint_key1); private const int Redpoint_key2 = 1050208; private Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_PetKey2, Redpoint_key2); 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).basicUseLimit) { 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);//解锁按钮 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); int itemCount1 = playerPack.GetItemCountByID(PackType.Item, 4150); List ListInt = new List(); for (int i = 0; i < Sortpet.Count; i++) { int petID = Sortpet[i].ID; var config = PetInfoConfig.Get(petID); int MaxLv = config.MaxRank; int cmpCnt = itemCount; if (config.Quality == 7) { //魔化特殊处理 cmpCnt = itemCount1; } 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 (cmpCnt >= 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 IntListSkill = new List(); for (int i = 0; i < ListInt.Count; 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; } } public bool CheckPetNow() { bool bPet = false; if (_DicPetBack.Count <= 0) return false; foreach (var key in _DicPetBack.Keys) { if (_DicPetBack[key].PetStatus == 1) { FosterPetID = key; bPet = true; } } return bPet; } private int GetRedPointPetID(List 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 IntListSkill = new List(); 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) { var isChangePetNow = false; Dictionary _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) { if (petId != PetNow) { isChangePetNow = true; } 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 && isServerPrepare) { 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 && isServerPrepare) { Event_H0704Update(petId); } if (_DicPetBack[petId].PetStatus == 1) { if (petId != PetNow) { isChangePetNow = true; } PetNow = petId; if (Event_SpiritPetPlay != null && isServerPrepare) { Event_SpiritPetPlay(petState); } } } } if (isServerPrepare && isChangePetNow && PetNow != 0) { ScrollTip.ShowTip(Language.Get("Z1811"));//外观切换成功 } if (onPetInfoUpdate != null && isServerPrepare) { onPetInfoUpdate(); } GetPetMinAndMaxAttack(); } if (info.packType == PackType.Item) { m_CheckRedPoint = true; } } bool m_CheckRedPoint = false; void CheckRedPoint() { if (m_CheckRedPoint) { PetStoneRed(); PetActivateRedPoint(); GetCultivateRedPoint(); m_CheckRedPoint = false; } } public int[] GetUseDataModel(int key, Dictionary 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 Analysis(string val)//正则表达式的字符串分割 { if (!userData.IsMatch(val)) { return null; } else { Dictionary dics = new Dictionary(); 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提示,False不提示 { 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).basicUseLimit; 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 petAttrDict = new Dictionary(); public Dictionary 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(24, allAtkAdd); return petAttrDict; } #endregion #region 技能整合 public ICollection GetPetTotalSkills() { return petSkills.Keys; } public SkillEffectGroup GetSkillEffectGroup(int skillId) { if (petSkillEffectValues.ContainsKey(skillId)) { return petSkillEffectValues[skillId]; } return default(SkillEffectGroup); } public bool TryGetIntegrationSkill(SkillEffectGroup effect, out int skillId) { return integrationSkills.TryGetValue(effect, out skillId); } public bool TryGetPetSkills(SkillEffectGroup effect, out List 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; } 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 public bool IsPetMaxLevel(int petId) { if (_DicPetBack.ContainsKey(petId)) { var config = PetInfoConfig.Get(petId); return _DicPetBack[petId].PetClass >= config.MaxRank; } return false; } public bool IsPetUnlock(int petId) { return _DicPetBack.ContainsKey(petId); } public int GetPetHorseEffect(int id, int skinIndex) { return PetHorseAwakingModel.Instance.GetPetHorseEffect(id, skinIndex); } public string GetPetHorseEffectNode(int id, int skinIndex) { return PetHorseAwakingModel.Instance.GetPetHorseEffectNode(id, skinIndex); } } }