//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, September 07, 2018
|
//--------------------------------------------------------
|
using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
|
using UnityEngine;
|
|
// 关于神兽强化
|
|
public class GodBeastModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
public Dictionary<int, int> Absorption_Dic = new Dictionary<int, int>();//获取选择的物品
|
public event Action AbsorbEvent;
|
public int ItemInde = 0;//物品下标
|
public ItemModel Crystal_ItemModel;//当前所选中的水晶物品
|
public int ItemPos = 1;//设置弹框的位置索引
|
public int ItemPlace = -1;//神兽装备位置信息
|
public Dictionary<int, int> QualityLimit = new Dictionary<int, int>();//对应品质所能选择的最大强化等级
|
DogzModel Dogz_model;
|
DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel<DogzModel>()); } }
|
PackModel _playerPack;
|
PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } }
|
public Dictionary<int, Redpoint> GodBeastRedPointDic = new Dictionary<int, Redpoint>();//key装备位置下标(红点)
|
private List<int> RedPointLIst = new List<int>();
|
private const int Redpoint_key1 = 11202;//神兽强化红点
|
public Redpoint redPointStre1 = new Redpoint(112, Redpoint_key1);
|
public override void Init()
|
{
|
if (QualityLimit.Count <= 0)
|
{
|
string DogzAssist = FuncConfigConfig.Get("DogzAssist").Numerical4;//获取不同品质的神兽强化上限
|
QualityLimit = ConfigParse.GetDic<int, int>(DogzAssist);
|
}
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
playerPack.itemCntAddEvent -= ItemCntAddAct;
|
playerPack.itemCntReduceEvent -= ItemCntReduceAct;
|
dogz_model.UpdateAssistDogzEvent -= UpdateAssistDogzEvent;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= MakeItemAnswerEvent;
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += MakeItemAnswerEvent;
|
playerPack.itemCntAddEvent += ItemCntAddAct;//物品数量增加
|
playerPack.itemCntReduceEvent += ItemCntReduceAct;//物品数量减少
|
dogz_model.UpdateAssistDogzEvent += UpdateAssistDogzEvent;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
SetRedPointID();
|
GodBeastRedPoint();
|
}
|
|
private void MakeItemAnswerEvent(H0721_tagMakeItemAnswer obj)
|
{
|
if ((int)obj.MakeType == (int)MakeType.DogzEquipPlus)
|
{
|
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.DogzItem || packType == PackType.DogzEquip)
|
{
|
GodBeastRedPoint();
|
}
|
}
|
|
private void ItemCntAddAct(PackType packType, int arg2, int arg3)
|
{
|
if (packType == PackType.DogzItem || packType == PackType.DogzEquip)
|
{
|
GodBeastRedPoint();
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void AbsorbEventUpdate()
|
{
|
if (AbsorbEvent != null)
|
{
|
AbsorbEvent();
|
}
|
}
|
|
private Dictionary<int, int> AllEnhancedPropertiesDic = new Dictionary<int, int>();//key:为属性编号,value是属性值
|
public Dictionary<int, int> AllEnhancedProperties(int GodBeastNumber)//获取整只神兽强化属性
|
{
|
AllEnhancedPropertiesDic.Clear();
|
List<ItemModel> 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.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
if (IudetDogzEquipPlus != null)
|
{
|
int lv = IudetDogzEquipPlus[0];
|
if (lv > 0)
|
{
|
var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.config.EquipPlace, lv);
|
int[] AttType = DogzEquipConfig.attType;
|
int[] AttValue = 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<int, int> SiteEnhancementAttributeDic = new Dictionary<int, int>();//key:为属性编号,value是属性值
|
public Dictionary<int, int> SiteEnhancementAttribute(PackType PackTypeGodBeast, int GodBeastIndex)//获取某只神兽身上某个装备属性值
|
{
|
SiteEnhancementAttributeDic.Clear();
|
ItemModel item = playerPack.GetItemByIndex(PackTypeGodBeast, GodBeastIndex);
|
if (item == null)
|
{
|
return SiteEnhancementAttributeDic;
|
}
|
var IudetDogzEquipPlus = item.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
if (IudetDogzEquipPlus != null && IudetDogzEquipPlus[0] > 0)
|
{
|
var DogzEquipConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(item.config.EquipPlace, IudetDogzEquipPlus[0]);
|
int[] AttType = DogzEquipConfig.attType;
|
int[] AttValue = 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.GetItemByIndex(PackType.DogzEquip, DogZBagIndex);
|
if (itemModel == null)
|
{
|
return false;
|
}
|
int lv = QualityLimit[itemModel.config.ItemColor];//获取最大强化等级
|
var DogzEquipMaxConfig = DogzEquipPlusConfig.GetEquipplaceAndLevel(itemModel.config.EquipPlace, lv);
|
var IudetDogzEquipPlus = itemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
|
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.GetItemByIndex(PackType.DogzItem, key);
|
if (item_Model != null)
|
{
|
if (item_Model.config.Effect1 == 235)
|
{
|
var _IudetDogzEquipPlus = item_Model.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
SingleProficiency += item_Model.config.EffectValueA1 * Absorption_Dic[key];
|
if (_IudetDogzEquipPlus != null)
|
{
|
SingleProficiency += _IudetDogzEquipPlus[1];
|
DoubleProficiency += item_Model.config.EffectValueA1 + _IudetDogzEquipPlus[1];
|
}
|
else
|
{
|
DoubleProficiency += item_Model.config.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> itemModel = dogz_model.GetDogzEquips(key);
|
if (itemModel == null)
|
{
|
continue;
|
}
|
for (int i = 0; i < itemModel.Count; i++)
|
{
|
int IndexId = itemModel[i].gridIndex;
|
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.GetItemByIndex(PackType.DogzEquip, x);
|
ItemModel IindexitemModely = playerPack.GetItemByIndex(PackType.DogzEquip, y);
|
if (IindexitemModelx.config.ItemColor.CompareTo(IindexitemModely.config.ItemColor) != 0)//品质
|
{
|
return -IindexitemModelx.config.ItemColor.CompareTo(IindexitemModely.config.ItemColor);
|
}
|
if (IindexitemModelx.config.StarLevel.CompareTo(IindexitemModely.config.StarLevel) != 0)//星级
|
{
|
return -IindexitemModelx.config.StarLevel.CompareTo(IindexitemModely.config.StarLevel);
|
}
|
if (IindexitemModelx.config.EquipPlace.CompareTo(IindexitemModely.config.EquipPlace) != 0)//装备位
|
{
|
return IindexitemModelx.config.EquipPlace.CompareTo(IindexitemModely.config.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.score.CompareTo(IindexitemModely.score) != 0)//装备评分
|
{
|
return -IindexitemModelx.score.CompareTo(IindexitemModely.score);
|
}
|
return 1;
|
}
|
|
private int GetLV(ItemModel _ItemModel)
|
{
|
var IudetDogzEquipPlus = _ItemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
if (IudetDogzEquipPlus != null)
|
{
|
return IudetDogzEquipPlus[0];
|
}
|
return 0;
|
}
|
private int GetProficiency(ItemModel _ItemModel)
|
{
|
var IudetDogzEquipPlus = _ItemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
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> itemModel = dogz_model.GetDogzEquips(key);
|
if (itemModel == null)
|
{
|
return;
|
}
|
for (int i = 0; i < itemModel.Count; i++)
|
{
|
if (itemModel[i].config.ItemColor < ItemColor)//获取最低品质的颜色
|
{
|
ItemColor = itemModel[i].config.ItemColor;
|
}
|
var IudetDogzEquipPlus = itemModel[i].GetUseData((int)ItemUseDataKey.dogzEquipPlus);// 神兽装备强化信息列表 [强化等级, 强化熟练度]
|
if (IudetDogzEquipPlus == null)//判断是否都满级 满级不可亮红点
|
{
|
Istrue = true;
|
}
|
else
|
{
|
if (QualityLimit.ContainsKey(itemModel[i].config.ItemColor) && IudetDogzEquipPlus[0] < (QualityLimit[itemModel[i].config.ItemColor]))
|
{
|
Istrue = true;
|
}
|
}
|
}
|
if (Istrue)
|
{
|
if (playerPack.GetSinglePack(PackType.DogzItem) == null)
|
{
|
return;
|
}
|
Dictionary<int, ItemModel> BackpackDic = playerPack.GetSinglePack(PackType.DogzItem).GetAllItems();
|
int _ItemColor = 10;
|
foreach (var keyBack in BackpackDic.Keys)
|
{
|
var itemModelBack = BackpackDic[keyBack];
|
if (itemModelBack.config.Type == 70)//有神兽水晶时的红点
|
{
|
IsRedPoint = true;
|
}
|
if (itemModelBack.config.ItemColor < _ItemColor)
|
{
|
_ItemColor = itemModelBack.config.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.GetItemByIndex(PackType.DogzEquip, RedPointLIst[i]);
|
|
if (_itemModel == null)
|
{
|
continue;
|
}
|
int MaxLv = QualityLimit[_itemModel.config.ItemColor];//获取最大强化等级
|
var _IudetDogzEquipPlus = _itemModel.GetUseData((int)ItemUseDataKey.dogzEquipPlus);
|
|
if (_IudetDogzEquipPlus != null)
|
{
|
if (_IudetDogzEquipPlus[0]<MaxLv && _IudetDogzEquipPlus[0] < Lv)
|
{
|
Lv = _IudetDogzEquipPlus[0];
|
IndexId = RedPointLIst[i];
|
}
|
}
|
else
|
{
|
if (0 < Lv)
|
{
|
Lv = 0;
|
IndexId = RedPointLIst[i];
|
}
|
}
|
}
|
if (GodBeastRedPointDic.ContainsKey(IndexId))
|
{
|
GodBeastRedPointDic[IndexId].state = RedPointState.Simple;
|
}
|
}
|
|
}
|
|
public bool IsNeedEquipment()//是否有极品装备需要弹框
|
{
|
bool IsBool = false;
|
foreach (var key in Absorption_Dic.Keys)
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.DogzItem, key);
|
if (itemModel != null)
|
{
|
if (itemModel.config.EquipPlace > 0 && itemModel.config.ItemColor >= 5)
|
{
|
IsBool = true;
|
}
|
}
|
|
}
|
return IsBool;
|
}
|
}
|
|
|
|
|