//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Friday, September 07, 2018 //-------------------------------------------------------- using Snxxz.UI; using System; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; using TableConfig; using UnityEngine; // 关于神兽强化 public class GodBeastModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { public Dictionary Absorption_Dic = new Dictionary();//获取选择的物品 public event Action AbsorbEvent; public int ItemInde = 0;//物品下标 public ItemModel Crystal_ItemModel;//当前所选中的水晶物品 public int ItemPlace = -1;//神兽装备位置信息 public Dictionary QualityLimit = new Dictionary();//对应品质所能选择的最大强化等级 DogzModel Dogz_model; DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel()); } } PlayerPackModel _playerPack; PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } public Dictionary GodBeastRedPointDic = new Dictionary();//key装备位置下标(红点) private List RedPointLIst = new List(); private const int Redpoint_key1 = 11202;//神兽强化红点 public Redpoint redPointStre1 = new Redpoint(112, Redpoint_key1); public override void Init() { if (QualityLimit.Count <= 0) { string DogzAssist = Config.Instance.Get("DogzAssist").Numerical4;//获取不同品质的神兽强化上限 QualityLimit = ConfigParse.GetDic(DogzAssist); } } public void OnBeforePlayerDataInitialize() { } public void OnPlayerLoginOk() { playerPack.ItemCntAddAct -= ItemCntAddAct; playerPack.ItemCntReduceAct -= ItemCntReduceAct; dogz_model.UpdateAssistDogzEvent -= UpdateAssistDogzEvent; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= MakeItemAnswerEvent; DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += MakeItemAnswerEvent; playerPack.ItemCntAddAct += ItemCntAddAct;//物品数量增加 playerPack.ItemCntReduceAct += ItemCntReduceAct;//物品数量减少 dogz_model.UpdateAssistDogzEvent += UpdateAssistDogzEvent; FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; SetRedPointID(); GodBeastRedPoint(); } private void MakeItemAnswerEvent(H0721_tagMakeItemAnswer obj) { if ((int)obj.MakeType == (int)MakeType.Def_mitDogzEquipPlus) { GodBeastRedPoint(); } } private void OnFuncStateChangeEvent(int obj) { if (obj == 138) { GodBeastRedPoint(); } } private void UpdateAssistDogzEvent() { foreach (var key in GodBeastRedPointDic.Keys) { GodBeastRedPointDic[key].state = RedPointState.None; } SetRedPointID(); GodBeastRedPoint(); } private void ItemCntReduceAct(PackType packType, int arg2, int arg3) { if (packType == PackType.rptDogzItem || packType == PackType.rptDogzEquip) { GodBeastRedPoint(); } } private void ItemCntAddAct(PackType packType, int arg2, int arg3) { if (packType == PackType.rptDogzItem || packType == PackType.rptDogzEquip) { GodBeastRedPoint(); } } public override void UnInit() { } public void AbsorbEventUpdate() { if (AbsorbEvent != null) { AbsorbEvent(); } } private Dictionary AllEnhancedPropertiesDic = new Dictionary();//key:为属性编号,value是属性值 public Dictionary AllEnhancedProperties(int GodBeastNumber)//获取整只神兽强化属性 { AllEnhancedPropertiesDic.Clear(); List itemModel = dogz_model.GetDogzEquips(GodBeastNumber); if (itemModel == null) { return AllEnhancedPropertiesDic; } for (int i = 0; i < itemModel.Count; i++) { ItemModel item = itemModel[i]; var IudetDogzEquipPlus = item.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (IudetDogzEquipPlus != null) { int lv = IudetDogzEquipPlus[0]; if (lv > 0) { var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.EquipPlace, lv); int[] AttType = ConfigParse.GetMultipleStr(DogzEquipConfig.attType); int[] AttValue = ConfigParse.GetMultipleStr(DogzEquipConfig.attValue); for (int j = 0; j < AttType.Length; j++) { if (AllEnhancedPropertiesDic.ContainsKey(AttType[j])) { var value = AllEnhancedPropertiesDic[(AttType[j])]; AllEnhancedPropertiesDic[(AttType[j])] = value + AttValue[j]; } else { AllEnhancedPropertiesDic.Add(AttType[j], AttValue[j]); } } } } } return AllEnhancedPropertiesDic; } private Dictionary SiteEnhancementAttributeDic = new Dictionary();//key:为属性编号,value是属性值 public Dictionary SiteEnhancementAttribute(PackType PackTypeGodBeast, int GodBeastIndex)//获取某只神兽身上某个装备属性值 { SiteEnhancementAttributeDic.Clear(); ItemModel item = playerPack.GetItemModelByIndex(PackTypeGodBeast, GodBeastIndex); if (item == null) { return SiteEnhancementAttributeDic; } var IudetDogzEquipPlus = item.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (IudetDogzEquipPlus != null && IudetDogzEquipPlus[0] > 0) { var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.EquipPlace, IudetDogzEquipPlus[0]); int[] AttType = ConfigParse.GetMultipleStr(DogzEquipConfig.attType); int[] AttValue = ConfigParse.GetMultipleStr(DogzEquipConfig.attValue); for (int j = 0; j < AttType.Length; j++) { if (SiteEnhancementAttributeDic.ContainsKey(AttType[j])) { SiteEnhancementAttributeDic[(AttType[j])] = AttValue[j]; } else { SiteEnhancementAttributeDic.Add(AttType[j], AttValue[j]); } } } return SiteEnhancementAttributeDic; } public int DogZBagIndex = 0;//当前强化的装备下标 public bool IsToggleBool = false; public bool IsFullLevel()//是都满级能够继续吸收 { int DogZLV = 0;//获取当前神兽等级 int DogProficiency = 0;//当前神兽的熟练度 int SingleProficiency = 0;//单倍熟练度 int DoubleProficiency = 0;//双倍熟练度 ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptDogzEquip, DogZBagIndex); if (itemModel == null) { return false; } int lv = QualityLimit[itemModel.chinItemModel.ItemColor];//获取最大强化等级 var DogzEquipMaxConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(itemModel.chinItemModel.EquipPlace, lv); var IudetDogzEquipPlus = itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (IudetDogzEquipPlus != null) { DogZLV = IudetDogzEquipPlus[0]; DogProficiency = IudetDogzEquipPlus[1]; } if (DogZLV >= lv) { return true; } foreach (var key in Absorption_Dic.Keys) { ItemModel item_Model = playerPack.GetItemModelByIndex(PackType.rptDogzItem, key); if (item_Model != null) { if (item_Model.chinItemModel.Effect1 == 235) { var _IudetDogzEquipPlus = item_Model.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); SingleProficiency += item_Model.chinItemModel.EffectValueA1 * Absorption_Dic[key]; if (_IudetDogzEquipPlus != null) { SingleProficiency += _IudetDogzEquipPlus[1]; DoubleProficiency += item_Model.chinItemModel.EffectValueA1 + _IudetDogzEquipPlus[1]; } else { DoubleProficiency += item_Model.chinItemModel.EffectValueA1 * 2 * Absorption_Dic[key]; } } } } if (IsToggleBool)//双倍熟练度 { if (DogProficiency + DoubleProficiency >= DogzEquipMaxConfig.upExpTotal) { return true;//已满 } else { return false;//未满 } } else//单倍熟练度 { if (DogProficiency + SingleProficiency >= DogzEquipMaxConfig.upExpTotal) { return true;//已满 } else { return false;//未满 } } } private void SetRedPointID()//设置红点ID { GodBeastRedPointDic.Clear(); RedPointLIst.Clear(); var DogzEquipDict = dogz_model.dogzAssistStateDict; foreach (var key in DogzEquipDict.Keys) { if (DogzEquipDict[key] == 1) { List itemModel = dogz_model.GetDogzEquips(key); for (int i = 0; i < itemModel.Count; i++) { int IndexId = itemModel[i].itemInfo.ItemPlace; int RedPoint = Redpoint_key1 * 1000 + IndexId; Redpoint redPointStare = new Redpoint(Redpoint_key1, RedPoint); if (!GodBeastRedPointDic.ContainsKey(IndexId)) { GodBeastRedPointDic.Add(IndexId, redPointStare); RedPointLIst.Add(IndexId); } } } } RedPointLIst.Sort(Compare); } int Compare(int x, int y) { ItemModel IindexitemModelx = playerPack.GetItemModelByIndex(PackType.rptDogzEquip, x); ItemModel IindexitemModely = playerPack.GetItemModelByIndex(PackType.rptDogzEquip, y); if (IindexitemModelx.chinItemModel.ItemColor.CompareTo(IindexitemModely.chinItemModel.ItemColor) != 0)//品质 { return -IindexitemModelx.chinItemModel.ItemColor.CompareTo(IindexitemModely.chinItemModel.ItemColor); } if (IindexitemModelx.chinItemModel.StarLevel.CompareTo(IindexitemModely.chinItemModel.StarLevel) != 0)//星级 { return -IindexitemModelx.chinItemModel.StarLevel.CompareTo(IindexitemModely.chinItemModel.StarLevel); } if (IindexitemModelx.chinItemModel.EquipPlace.CompareTo(IindexitemModely.chinItemModel.EquipPlace) != 0)//装备位 { return IindexitemModelx.chinItemModel.EquipPlace.CompareTo(IindexitemModely.chinItemModel.EquipPlace); } if (GetLV(IindexitemModelx).CompareTo(GetLV(IindexitemModely)) != 0)//强化等级 { return -GetLV(IindexitemModelx).CompareTo(GetLV(IindexitemModely)); } if (GetProficiency(IindexitemModelx).CompareTo(GetProficiency(IindexitemModely)) != 0)//熟练度 { return -GetProficiency(IindexitemModelx).CompareTo(GetProficiency(IindexitemModely)); } if (IindexitemModelx.equipScore.CompareTo(IindexitemModely.equipScore) != 0)//装备评分 { return -IindexitemModelx.equipScore.CompareTo(IindexitemModely.equipScore); } return 1; } private int GetLV(ItemModel _ItemModel) { var IudetDogzEquipPlus = _ItemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (IudetDogzEquipPlus != null) { return IudetDogzEquipPlus[0]; } return 0; } private int GetProficiency(ItemModel _ItemModel) { var IudetDogzEquipPlus = _ItemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (IudetDogzEquipPlus != null) { return IudetDogzEquipPlus[1]; } return 0; } public int IndexId = 0; private void GodBeastRedPoint()//神兽强化红点 { bool Istrue = false; bool IsRedPoint = false; int ItemColor = 10; var DogzEquipDict = dogz_model.dogzAssistStateDict; IndexId = 0; foreach (var key in GodBeastRedPointDic.Keys) { GodBeastRedPointDic[key].state = RedPointState.None; } int Type = 0; foreach (var key in DogzEquipDict.Keys) { if (DogzEquipDict[key] == 1) { Type += 1; List itemModel = dogz_model.GetDogzEquips(key); for (int i = 0; i < itemModel.Count; i++) { if (itemModel[i].chinItemModel.ItemColor < ItemColor)//获取最低品质的颜色 { ItemColor = itemModel[i].chinItemModel.ItemColor; } var IudetDogzEquipPlus = itemModel[i].GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus);// 神兽装备强化信息列表 [强化等级, 强化熟练度] if (IudetDogzEquipPlus == null)//判断是否都满级 满级不可亮红点 { Istrue = true; } else { if (QualityLimit.ContainsKey(itemModel[i].chinItemModel.ItemColor) && IudetDogzEquipPlus[0] < (QualityLimit[itemModel[i].chinItemModel.ItemColor])) { Istrue = true; } } } if (Istrue) { if (playerPack.GetSinglePackModel(PackType.rptDogzItem) == null) { return; } Dictionary BackpackDic = playerPack.GetSinglePackModel(PackType.rptDogzItem).GetPackModelIndexDict(); int _ItemColor = 10; foreach (var keyBack in BackpackDic.Keys) { var itemModelBack = BackpackDic[keyBack]; if (itemModelBack.chinItemModel.Type == 70)//有神兽水晶时的红点 { IsRedPoint = true; } if (itemModelBack.chinItemModel.ItemColor < _ItemColor) { _ItemColor = itemModelBack.chinItemModel.ItemColor; } } if (Type >= dogz_model.curSumAssistNum && ItemColor > _ItemColor)//出战神兽已满,且神兽背包有品质低于已助战神兽品质颜色时 { IsRedPoint = true; } } } } if (IsRedPoint) { int Lv = 100; for (int i = 0; i < RedPointLIst.Count; i++) { ItemModel _itemModel = playerPack.GetItemModelByIndex(PackType.rptDogzEquip, RedPointLIst[i]); int MaxLv= QualityLimit[_itemModel.chinItemModel.ItemColor];//获取最大强化等级 var _IudetDogzEquipPlus = _itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus); if (_IudetDogzEquipPlus != null) { if (_IudetDogzEquipPlus[0] 0 && itemModel.chinItemModel.ItemColor >= 5) { IsBool = true; } } } return IsBool; } }