using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
using LitJson;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class PackModelInterface : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
private ItemConfig tagChinModel;
|
private FuncConfigConfig _equipGSFormula;
|
private FuncConfigConfig _itemPush;
|
private FuncConfigConfig _drugIDFunc;
|
private FuncConfigConfig _oneKeySellFunc;
|
public int[] preciousItemType { get; private set; }
|
private int[] drugIDs;
|
public Dictionary<int, List<int>> betterEquipExceptDungeonDict { get; private set; }
|
|
private int[] onekeySellTypes;
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack {
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel {
|
get {
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
PlayerBuffDatas buffDatas { get { return ModelCenter.Instance.GetModel<PlayerBuffDatas>(); } }
|
PlayerMountDatas mountDatas { get { return ModelCenter.Instance.GetModel<PlayerMountDatas>(); } }
|
PlayerPetDatas petDatas { get { return ModelCenter.Instance.GetModel<PlayerPetDatas>(); } }
|
PlayerStrengthengDatas strengthDatas { get { return ModelCenter.Instance.GetModel<PlayerStrengthengDatas>(); } }
|
MagicianModel magicianModel { get { return ModelCenter.Instance.GetModel<MagicianModel>(); } }
|
TrialDungeonModel trialModel { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
|
ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel<ComposeWinModel>(); } }
|
|
private int[] pushItemIds;
|
public int[] pushBuffTypeIds;
|
private List<int> equipBaseAttrlist = new List<int>();
|
public Dictionary<int, int> promptUseLimitDict { get; private set; }
|
|
public override void Init()
|
{
|
_equipGSFormula = FuncConfigConfig.Get("EquipGSFormula");
|
equipBaseAttrlist.Clear();
|
JsonData baseAttr = JsonMapper.ToObject(_equipGSFormula.Numerical2);
|
if (baseAttr.IsArray)
|
{
|
for (int i = 0; i < baseAttr.Count; i++)
|
{
|
equipBaseAttrlist.Add(int.Parse(baseAttr[i].ToString()));
|
}
|
}
|
|
_itemPush = FuncConfigConfig.Get("ItemPush");
|
preciousItemType = ConfigParse.GetMultipleStr<int>(_itemPush.Numerical1);
|
|
FuncConfigConfig noPromptUsetItem = FuncConfigConfig.Get("NoPromptUsetItem");
|
promptUseLimitDict = ConfigParse.GetDic<int, int>(noPromptUsetItem.Numerical1);
|
|
_drugIDFunc = FuncConfigConfig.Get("LifePotionlist");
|
drugIDs = ConfigParse.GetMultipleStr<int>(_drugIDFunc.Numerical1);
|
_oneKeySellFunc = FuncConfigConfig.Get("OneKeySellItemType");
|
onekeySellTypes = ConfigParse.GetMultipleStr<int>(_oneKeySellFunc.Numerical1);
|
FuncConfigConfig funcConfig = FuncConfigConfig.Get("IntroductionItem");
|
pushItemIds = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
|
pushBuffTypeIds = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical2);
|
FuncConfigConfig betterEquipExcConfig = FuncConfigConfig.Get("GoodItemDungeon");
|
betterEquipExceptDungeonDict = new Dictionary<int, List<int>>();
|
JsonData excEquipData = JsonMapper.ToObject(betterEquipExcConfig.Numerical1);
|
foreach (var dungeonId in excEquipData.Keys)
|
{
|
List<int> idlist = new List<int>();
|
betterEquipExceptDungeonDict.Add(int.Parse(dungeonId), idlist);
|
for (int i = 0; i < excEquipData[dungeonId].Count; i++)
|
{
|
int itemId = int.Parse(excEquipData[dungeonId][i].ToString());
|
idlist.Add(itemId);
|
}
|
}
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
isPackResetOk = true;
|
itemModelDict.Clear();
|
itemEffectCDDict.Clear();
|
itemEffectTimelist.Clear();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
}
|
|
|
public override void UnInit()
|
{
|
|
}
|
|
#region 计算装备评分
|
/// <summary>
|
/// 得到特殊属性的字典
|
/// </summary>
|
private Dictionary<AttrEnum, int> specAttrDic = new Dictionary<AttrEnum, int>();
|
public int SetEquipScore(PackType type, int itemId, Dictionary<int, List<int>> useDataDic = null, bool isPreview = false)
|
{
|
specAttrDic.Clear();
|
int id = itemId;
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
if (CheckIsCustomItem(itemConfig))
|
{
|
AppointItemConfig appointItemConfig = AppointItemConfig.Get(itemId);
|
SetCustomAttrData(appointItemConfig);
|
id = itemConfig.EffectValueA1;
|
}
|
else
|
{
|
if (isPreview)
|
{
|
List<int> legendIdlist = new List<int>();
|
List<int> legendValuelist = new List<int>();
|
switch (itemConfig.EquipPlace)
|
{
|
case 11:
|
CalculateWingsLegendAttr(itemConfig, out legendIdlist, out legendValuelist);
|
break;
|
case 1:
|
case 2:
|
case 3:
|
case 4:
|
case 5:
|
case 6:
|
case 7:
|
case 8:
|
case 9:
|
case 10:
|
case 12:
|
CalculateEquipLegendAttr(itemConfig, out legendIdlist, out legendValuelist);
|
break;
|
}
|
|
var packType = GeneralDefine.GetPackTypeByItemType(itemConfig.Type);
|
switch (packType)
|
{
|
case PackType.JadeDynastyItem:
|
CalculateJadeDynastyLegendAttr(itemConfig,out legendIdlist, out legendValuelist);
|
break;
|
}
|
|
if (legendIdlist.Count == legendValuelist.Count)
|
{
|
SetLegendData(legendIdlist, legendValuelist);
|
}
|
}
|
else
|
{
|
if (useDataDic != null)
|
{
|
if (useDataDic.ContainsKey((int)ItemUseDataKey.legendAttrID))
|
{
|
SetLegendData(useDataDic[(int)ItemUseDataKey.legendAttrID], useDataDic[(int)ItemUseDataKey.legendAttrValue]);
|
}
|
|
if (useDataDic.ContainsKey((int)ItemUseDataKey.outOfPrintAttrID))
|
{
|
SetExhaustedData(useDataDic[(int)ItemUseDataKey.outOfPrintAttrID], useDataDic[(int)ItemUseDataKey.outOfPrintAttrValue]);
|
}
|
|
}
|
}
|
}
|
return GetEquipScore(type, id, specAttrDic);
|
|
}
|
|
private void CalculateEquipLegendAttr(ItemConfig itemConfig, out List<int> legendIdlist, out List<int> legendValuelist)
|
{
|
legendIdlist = new List<int>();
|
legendValuelist = new List<int>();
|
string attrCntKey = StringUtility.Contact(itemConfig.ItemColor, itemConfig.StarLevel);
|
var attrIDDict = itemTipsModel.legendAttrIDPreviewDict;
|
var attrCntDict = itemTipsModel.legendAttrCntPreviewDict;
|
if (attrIDDict.ContainsKey(itemConfig.EquipPlace))
|
{
|
var attrTypeDict = itemTipsModel.legendAttrIDPreviewDict[itemConfig.EquipPlace];
|
|
foreach (var attrType in attrTypeDict.Keys)
|
{
|
var attrIds = attrTypeDict[attrType];
|
int attrCnt = 0;
|
if (attrCntDict.ContainsKey(attrCntKey))
|
{
|
attrCnt = attrCntDict[attrCntKey][attrType];
|
}
|
for (int i = 0; i < attrIds.Count; i++)
|
{
|
if (attrCnt > i)
|
{
|
legendIdlist.Add(attrIds[i]);
|
}
|
}
|
}
|
}
|
for (int i = 0; i < legendIdlist.Count; i++)
|
{
|
if (itemTipsModel.legendAttrColorValuePreviewDict.ContainsKey(legendIdlist[i]))
|
{
|
if (itemTipsModel.legendAttrColorValuePreviewDict[legendIdlist[i]].ContainsKey(itemConfig.ItemColor))
|
{
|
legendValuelist.Add(itemTipsModel.legendAttrColorValuePreviewDict[legendIdlist[i]][itemConfig.ItemColor]);
|
}
|
}
|
else if (itemTipsModel.legendAttrLvValuePreviewDict.ContainsKey(legendIdlist[i]))
|
{
|
if (itemTipsModel.legendAttrLvValuePreviewDict[legendIdlist[i]].ContainsKey(itemConfig.LV))
|
{
|
legendValuelist.Add(itemTipsModel.legendAttrLvValuePreviewDict[legendIdlist[i]][itemConfig.LV]);
|
}
|
}
|
}
|
}
|
|
private void CalculateWingsLegendAttr(ItemConfig itemConfig, out List<int> legendIdlist, out List<int> legendValuelist)
|
{
|
legendIdlist = new List<int>();
|
legendValuelist = new List<int>();
|
var attrCntDict = itemTipsModel.wingsLegendAttrCntPreviewDict;
|
var attrValueDict = itemTipsModel.wingsLegendAttrValuePreviewDict;
|
int attrCnt = 0;
|
if (attrCntDict.ContainsKey(itemConfig.LV))
|
{
|
attrCnt = attrCntDict[itemConfig.LV];
|
}
|
if (attrValueDict.ContainsKey(itemConfig.LV))
|
{
|
var attrIdDict = attrValueDict[itemConfig.LV];
|
foreach (var attrId in attrIdDict.Keys)
|
{
|
if (legendIdlist.Count < attrCnt)
|
{
|
legendIdlist.Add(attrId);
|
legendValuelist.Add(attrIdDict[attrId][0]);
|
}
|
}
|
|
}
|
}
|
|
private void CalculateJadeDynastyLegendAttr(ItemConfig itemConfig, out List<int> legendIdlist, out List<int> legendValuelist)
|
{
|
Dictionary<int, int> attrDict = null;
|
itemTipsModel.TryGetJadeDynastyLegendAttr(itemConfig.ID,out attrDict);
|
legendIdlist = attrDict.Keys.ToList();
|
legendValuelist = attrDict.Values.ToList();
|
}
|
|
#region 预览定制属性逻辑处理
|
public bool CheckIsCustomItem(ItemConfig itemConfig)
|
{
|
if (itemConfig == null) return false;
|
|
if (itemConfig.Effect1 == 220)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 设置定制属性的数据
|
/// </summary>
|
private void SetCustomAttrData(AppointItemConfig appointItemConfig)
|
{
|
if (appointItemConfig == null)
|
return;
|
|
List<int> legendIdlist = null;
|
List<int> legendValuelist = null;
|
List<int> exhaustedIdlist = null;
|
List<int> exhaustedValuelist = null;
|
int i = 0;
|
if (appointItemConfig.LegendAttrID.Length > 0)
|
{
|
legendIdlist = new List<int>();
|
legendValuelist = new List<int>();
|
for (i = 0; i < appointItemConfig.LegendAttrID.Length; i++)
|
{
|
legendIdlist.Add(appointItemConfig.LegendAttrID[i]);
|
legendValuelist.Add(appointItemConfig.LegendAttrValue[i]);
|
}
|
}
|
|
if (appointItemConfig.OutOfPrintAttr.Length > 0)
|
{
|
exhaustedIdlist = new List<int>();
|
exhaustedValuelist = new List<int>();
|
for (i = 0; i < appointItemConfig.OutOfPrintAttr.Length; i++)
|
{
|
exhaustedIdlist.Add(appointItemConfig.OutOfPrintAttr[i]);
|
exhaustedValuelist.Add(appointItemConfig.OutOfPrintAttrValue[i]);
|
}
|
}
|
SetLegendData(legendIdlist, legendValuelist);
|
SetExhaustedData(exhaustedIdlist, exhaustedValuelist);
|
}
|
#endregion
|
/// <summary>
|
/// 设置传奇属性数据
|
/// </summary>
|
/// <param name="ids"></param>
|
/// <param name="values"></param>
|
private void SetLegendData(List<int> ids, List<int> values)
|
{
|
if (ids == null || ids.Count < 1) return;
|
int i = 0;
|
for (i = 0; i < ids.Count; i++)
|
{
|
SetSpecAttrlist(ids[i], values[i]);
|
}
|
}
|
|
/// <summary>
|
/// 设置绝版属性数据
|
/// </summary>
|
/// <param name="ids"></param>
|
/// <param name="values"></param>
|
private void SetExhaustedData(List<int> ids, List<int> values)
|
{
|
if (ids == null || ids.Count < 1) return;
|
int i = 0;
|
for (i = 0; i < ids.Count; i++)
|
{
|
SetSpecAttrlist(ids[i], values[i]);
|
}
|
|
}
|
|
private void SetSpecAttrlist(int attrId, int attrValue)
|
{
|
AttrEnum attrEnum = (AttrEnum)attrId;
|
if (!specAttrDic.ContainsKey(attrEnum))
|
{
|
specAttrDic.Add(attrEnum, attrValue);
|
}
|
else
|
{
|
specAttrDic[attrEnum] = attrValue;
|
}
|
}
|
|
/// <summary>
|
/// 得到装备的评分
|
/// </summary>
|
/// <param name="itemId"></param>
|
/// <returns></returns>
|
private Dictionary<int, int> itemEffectDict = new Dictionary<int, int>();
|
private Dictionary<AttrEnum, float> curEquipAttrDict = new Dictionary<AttrEnum, float>(); //存储当前装备属性对应的数值 key 属性 value 属性值
|
private Dictionary<AttrEnum, int> _tagGsProValueDict;
|
private Dictionary<string, string> _equipGSFormulaDict = new Dictionary<string, string>(); //key 公式参数 value 参数数值
|
private float curProValue = 0;
|
private int GetEquipScore(PackType type, int itemId, Dictionary<AttrEnum, int> specAttrDict)
|
{
|
tagChinModel = ItemConfig.Get(itemId);
|
if (tagChinModel == null || !GeneralDefine.CompareEquipPlaces.Contains(tagChinModel.EquipPlace)) return 0;
|
|
Equation.Instance.Clear();
|
_tagGsProValueDict = EquipGSParamConfig.GetTagGsProValueDict(tagChinModel.LV, tagChinModel.ItemColor, tagChinModel.StarLevel);
|
curEquipAttrDict.Clear();
|
itemEffectDict.Clear();
|
_equipGSFormulaDict.Clear();
|
try
|
{
|
if (tagChinModel.Effect1 != 0)
|
{
|
ConvertAttrId(tagChinModel.Effect1, tagChinModel.EffectValueA1, itemEffectDict);
|
}
|
if (tagChinModel.Effect2 != 0)
|
{
|
ConvertAttrId(tagChinModel.Effect2, tagChinModel.EffectValueA2, itemEffectDict);
|
}
|
|
if (tagChinModel.Effect3 != 0)
|
{
|
ConvertAttrId(tagChinModel.Effect3, tagChinModel.EffectValueA3, itemEffectDict);
|
}
|
|
if (tagChinModel.Effect4 != 0)
|
{
|
ConvertAttrId(tagChinModel.Effect4, tagChinModel.EffectValueA4, itemEffectDict);
|
}
|
|
if (tagChinModel.Effect5 != 0)
|
{
|
ConvertAttrId(tagChinModel.Effect5, tagChinModel.EffectValueA5, itemEffectDict);
|
}
|
|
}
|
catch (Exception ex)
|
{
|
DebugEx.Log(ex.ToString());
|
}
|
|
|
foreach (var key in itemEffectDict.Keys)
|
{
|
if (equipBaseAttrlist.Contains(key))
|
{
|
switch ((AttrEnum)key)
|
{
|
case AttrEnum.ATKSPEED:
|
case AttrEnum.OnlyFinalHurt:
|
case AttrEnum.PVPAtkBackHP:
|
curEquipAttrDict.Add((AttrEnum)key, itemEffectDict[key]);
|
break;
|
default:
|
if (_tagGsProValueDict != null && _tagGsProValueDict.ContainsKey((AttrEnum)key))
|
{
|
curProValue = itemEffectDict[key] * _tagGsProValueDict[(AttrEnum)key];
|
curEquipAttrDict.Add((AttrEnum)key, curProValue);
|
}
|
else
|
{
|
curEquipAttrDict.Add((AttrEnum)key, itemEffectDict[key]);
|
}
|
break;
|
}
|
}
|
}
|
|
foreach (AttrEnum attrType in specAttrDict.Keys)
|
{
|
switch (attrType)
|
{
|
case AttrEnum.ATKSPEED:
|
case AttrEnum.OnlyFinalHurt:
|
case AttrEnum.PVPAtkBackHP:
|
curEquipAttrDict.Add(attrType, specAttrDict[attrType]);
|
break;
|
default:
|
if (_tagGsProValueDict != null && _tagGsProValueDict.ContainsKey(attrType))
|
{
|
curProValue = specAttrDict[attrType] * _tagGsProValueDict[attrType];
|
curEquipAttrDict.Add(attrType, curProValue);
|
}
|
else
|
{
|
curEquipAttrDict.Add(attrType, specAttrDict[attrType]);
|
}
|
break;
|
}
|
}
|
|
if (_equipGSFormula != null)
|
{
|
foreach (var key in curEquipAttrDict.Keys)
|
{
|
PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get((int)key);
|
if (propertyConfig != null)
|
{
|
Equation.Instance.AddKeyValue(propertyConfig.Parameter, curEquipAttrDict[key]);
|
}
|
}
|
|
EquipGSParamConfig gSParamModel = EquipGSParamConfig.GetTagGSModel(tagChinModel.LV, tagChinModel.ItemColor, tagChinModel.StarLevel);
|
if (gSParamModel != null)
|
{
|
Equation.Instance.AddKeyValue("AtkSpeedC", gSParamModel.AtkSpeedC);
|
}
|
else
|
{
|
Equation.Instance.AddKeyValue("AtkSpeedC", 0);
|
}
|
DebugEx.Log("评分:" + Equation.Instance.Eval<double>(_equipGSFormula.Numerical1));
|
|
if(type == PackType.Deleted)
|
{
|
type = GeneralDefine.GetPackTypeByItemType(tagChinModel.Type);
|
}
|
switch(type)
|
{
|
case PackType.DogzEquip:
|
case PackType.DogzItem:
|
return Equation.Instance.Eval<int>(_equipGSFormula.Numerical3);
|
case PackType.JadeDynastyItem:
|
case PackType.JadeDynastyEquip:
|
return Equation.Instance.Eval<int>(_equipGSFormula.Numerical4);
|
default:
|
return Equation.Instance.Eval<int>(_equipGSFormula.Numerical1);
|
}
|
}
|
return 0;
|
}
|
|
private void ConvertAttrId(int attrId, int attrValue, Dictionary<int, int> keyValues)
|
{
|
switch ((AttrEnum)attrId)
|
{
|
case AttrEnum.ATK:
|
if (!keyValues.ContainsKey((int)AttrEnum.MinAtk))
|
{
|
keyValues.Add(((int)AttrEnum.MinAtk), attrValue);
|
}
|
else
|
{
|
keyValues[(int)AttrEnum.MinAtk] += attrValue;
|
}
|
|
if (!keyValues.ContainsKey((int)AttrEnum.MaxAtk))
|
{
|
keyValues.Add(((int)AttrEnum.MaxAtk), attrValue);
|
}
|
else
|
{
|
keyValues[(int)AttrEnum.MaxAtk] += attrValue;
|
}
|
break;
|
default:
|
if (!keyValues.ContainsKey(attrId))
|
{
|
keyValues.Add(attrId, attrValue);
|
}
|
else
|
{
|
keyValues[attrId] += attrValue;
|
}
|
break;
|
}
|
}
|
#endregion
|
|
#region 主界面物品弹框展示
|
public event Action<PackType, string> GetPreciousItemEvent; //得到珍品 value 物品的实例ID
|
|
public void GetPreciousItem(ItemModel itemModel)
|
{
|
if (itemModel.packType != PackType.Item) return;
|
|
if (itemModel.config.UseLV > PlayerDatas.Instance.baseData.LV) return;
|
|
bool isOverdue = IsOverdue(itemModel.itemInfo.ItemGUID, itemModel.itemInfo.ItemID, itemModel.useDataDict);
|
if (isOverdue)
|
{
|
return;
|
}
|
|
if (preciousItemType != null)
|
{
|
int i = 0;
|
for (i = 0; i < preciousItemType.Length; i++)
|
{
|
if (itemModel.config.Type == preciousItemType[i] && CheckPreciousCondition(itemModel))
|
{
|
if (GetPreciousItemEvent != null)
|
{
|
GetPreciousItemEvent(itemModel.packType, itemModel.itemInfo.ItemGUID);
|
}
|
}
|
}
|
}
|
}
|
|
public bool CheckPreciousCondition(ItemModel itemModel)
|
{
|
bool isReach = true;
|
WindowSearchConfig windowSearch = WindowSearchConfig.Get((int)itemModel.config.Jump);
|
if (windowSearch != null)
|
{
|
if (!FuncOpen.Instance.IsFuncOpen(windowSearch.Lv) && windowSearch.Lv != 0)
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
if (pushItemIds.Contains(itemModel.itemId))
|
{
|
int itemCnt = playerPack.GetItemCountByID(PackType.Item, itemModel.itemId) - itemModel.itemInfo.ItemCount;
|
if (itemCnt > 0)
|
{
|
isReach = false;
|
return isReach;
|
}
|
else
|
{
|
if (itemModel.preItemCount > 0)
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
|
}
|
|
if (promptUseLimitDict.ContainsKey(itemModel.itemId))
|
{
|
int playerLv = PlayerDatas.Instance.baseData.LV;
|
if (playerLv < promptUseLimitDict[itemModel.itemId])
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
|
ulong canUseCnt = 0;
|
if (playerPack.IsReachUseLimit(itemModel.itemInfo.ItemGUID, out canUseCnt))
|
{
|
isReach = false;
|
return isReach;
|
}
|
|
bool isBox = false;
|
bool isCanOpen = ModelCenter.Instance.GetModel<BoxGetItemModel>().CheckOpenBoxCondition(itemModel.itemId, out isBox);
|
if (isBox)
|
{
|
if (!isCanOpen)
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
|
if (trialModel.trialTokens.Contains(itemModel.itemId))
|
{
|
if (!trialModel.IsAnySatisfyExchangeBetter(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
|
if (playerPack.CheckIsDrugById(itemModel.itemId))
|
{
|
if (itemModel.config.RealmLimit > PlayerDatas.Instance.baseData.realmLevel)
|
{
|
isReach = false;
|
return isReach;
|
}
|
}
|
|
switch (itemModel.config.Type)
|
{
|
case 8:
|
if (buffDatas.BastBuff(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 20:
|
if (magicianModel.IsGodWeaponMaxLevelByItem(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 21:
|
if (!mountDatas.IsHint(HorseEnum.HorseDan, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 22:
|
if (!mountDatas.IsHint(HorseEnum.HorseStone, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 41:
|
if (!mountDatas.IsHint(HorseEnum.HorseDebris, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 26:
|
if (!petDatas.IsHint(PetEnum.PetDebris, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 27:
|
if (!petDatas.IsHint(PetEnum.PetDan, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 28:
|
if (!petDatas.IsHint(PetEnum.PetStone, itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 25:
|
if (!ModelCenter.Instance.GetModel<GemModel>().SatisfyBetter(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 39:
|
if (!CheckIsBetterWings(itemModel))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 52:
|
if (!strengthDatas.IsHint(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 127:
|
bool isHaveMakeNum = ItemLogicUtility.Instance.IsHaveMakeNumber(itemModel.itemInfo.ItemPlace);
|
int remainNum = CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum();
|
if (!CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch
|
|| remainNum > 0
|
|| !isHaveMakeNum)
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
default:
|
break;
|
}
|
|
switch (itemModel.itemId)
|
{
|
case 951:
|
if (!CheckIsExtendGrid(itemModel.itemId))
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
case 952:
|
int willTime = HangUpSetModel.Instance.offlinePluginTime + itemModel.config.EffectValueA1;
|
if (HangUpSetModel.Instance.offlinePluginTime >= HangUpSetModel.Instance.maxOfflinePluginTime)
|
{
|
isReach = false;
|
return isReach;
|
}
|
break;
|
|
}
|
|
return isReach;
|
}
|
|
private bool CheckIsBetterWings(ItemModel itemModel)
|
{
|
if (itemModel == null) return false;
|
|
ItemModel putModel = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Wing);
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
List<ItemModel> itemModels = null;
|
if (singlePack != null)
|
{
|
singlePack.GetItemCountByType((int)ItemType.Wings, out itemModels);
|
}
|
int[] composeTypes = itemModel.config.JumpComposeCondi;
|
bool isOpenCompose = false;
|
if (composeTypes != null && composeTypes.Length >= 3)
|
{
|
int first = composeTypes[0];
|
int second = composeTypes[1];
|
int third = composeTypes[2];
|
ComposeWinModel.ComposeThirdTypeData thirdTypeData = null;
|
composeModel.TryGetThirdTypeData(first, second, third, out thirdTypeData);
|
if (thirdTypeData != null)
|
{
|
var itemCompound = thirdTypeData.itemCompound;
|
if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
|
{
|
isOpenCompose = true;
|
}
|
}
|
}
|
|
if (!isOpenCompose)
|
{
|
return false;
|
}
|
|
if (putModel != null && putModel.config.LV >= itemModel.config.LV)
|
{
|
return false;
|
}
|
|
if (itemModels != null)
|
{
|
for (int i = 0; i < itemModels.Count; i++)
|
{
|
if (itemModels[i].config.JobLimit / 100 == PlayerDatas.Instance.baseData.Job)
|
{
|
if (itemModels[i].config.LV >= itemModel.config.LV)
|
{
|
return false;
|
}
|
}
|
}
|
}
|
|
return true;
|
}
|
|
private bool CheckIsExtendGrid(int itemId)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
if (singlePack == null) return false;
|
|
int startLockIndex = singlePack.openGridCount - playerPack.InitBagGridCnt;
|
FuncConfigConfig _tagFuncModel = FuncConfigConfig.Get("OpenBagItem");
|
int haveCount = playerPack.GetItemCountByID(PackType.Item, itemId);
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("index", startLockIndex + 1);
|
int needTool = Equation.Instance.Eval<int>(_tagFuncModel.Numerical2);
|
if (haveCount >= needTool)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public event Action<string> RefreshGetBetterEquipEvent; //得到更好的装备 value 物品的实例ID
|
|
public bool IsSameJob(int jobLimit)
|
{
|
return jobLimit == 0 || jobLimit / 100 == PlayerDatas.Instance.baseData.Job;
|
}
|
|
public void OnGetEquip(ItemModel model)
|
{
|
if (model == null) return;
|
if (model.packType != PackType.Item && model.packType != PackType.JadeDynastyItem) return;
|
if (!IsSameJob(model.config.JobLimit)) return;
|
|
int equipPlace = model.config.EquipPlace;
|
switch ((RoleEquipType)equipPlace)
|
{
|
case RoleEquipType.Weapon:
|
case RoleEquipType.Weapon2:
|
case RoleEquipType.Hat:
|
case RoleEquipType.Clothes:
|
case RoleEquipType.Belt:
|
case RoleEquipType.Trousers:
|
case RoleEquipType.Shoes:
|
case RoleEquipType.Neck:
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.FairyCan2:
|
case RoleEquipType.Wing:
|
case RoleEquipType.SpiritAnimal:
|
case RoleEquipType.JadeDynasty_Cloak:
|
case RoleEquipType.JadeDynasty_FaceMask:
|
case RoleEquipType.JadeDynasty_Glove1:
|
case RoleEquipType.JadeDynasty_Glove2:
|
case RoleEquipType.JadeDynasty_Ruyi:
|
case RoleEquipType.JadeDynasty_Pendant:
|
case RoleEquipType.JadeDynasty_Ring1:
|
case RoleEquipType.JadeDynasty_Ring2:
|
case RoleEquipType.JadeDynasty_Sword1:
|
case RoleEquipType.JadeDynasty_Sword2:
|
case RoleEquipType.JadeDynasty_Sword3:
|
case RoleEquipType.JadeDynasty_Sword4:
|
if (betterEquipExceptDungeonDict.ContainsKey(PlayerDatas.Instance.baseData.MapID))
|
{
|
if (betterEquipExceptDungeonDict[PlayerDatas.Instance.baseData.MapID].Contains(model.itemInfo.ItemID))
|
{
|
return;
|
}
|
}
|
SetGetBetterEquipEvent(model);
|
break;
|
}
|
}
|
|
private void SetGetBetterEquipEvent(ItemModel model)
|
{
|
List<int> itemEffectTime = model.GetUseDataModel((int)ItemUseDataKey.createTime);
|
if (itemEffectTime != null)
|
{
|
if (itemEffectTime[0] != 0)
|
{
|
ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(model.itemInfo.ItemGUID);
|
double remainTime = 0;
|
if (cool != null)
|
{
|
remainTime = cool.GetRemainTime();
|
}
|
|
if (remainTime >= 0 && remainTime < 120 && model.config.ExpireTime > 0)
|
{
|
return;
|
}
|
}
|
}
|
|
int isFightUp = IsFightUp(model.itemId,model.equipScore);
|
int equipPlace = model.config.EquipPlace;
|
if (isFightUp == 1)
|
{
|
switch(equipPlace)
|
{
|
case 9:
|
break;
|
default:
|
if(model.packType == PackType.Item)
|
{
|
var equipItemModel = playerPack.GetItemModelByIndex(PackType.Equip, model.config.EquipPlace);
|
if (PlayerDatas.Instance.baseData.LV >= 200)
|
{
|
if (model.EquipPlace > (int)RoleEquipType.Weapon2 && model.EquipPlace < (int)RoleEquipType.Neck)
|
{
|
if (equipItemModel != null && equipItemModel.config.ItemColor > model.config.ItemColor)
|
{
|
return;
|
}
|
}
|
}
|
}
|
break;
|
}
|
if (RefreshGetBetterEquipEvent != null)
|
{
|
RefreshGetBetterEquipEvent(model.itemInfo.ItemGUID);
|
}
|
}
|
}
|
|
private bool CheckIsBetterEquip(int curScore, int putOnScore = 0)
|
{
|
|
if (putOnScore <= 0)
|
{
|
return true;
|
}
|
|
if (curScore > putOnScore)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public event Action<PackType, string> RefreshPickItemEvent; //捡起的物品
|
|
public void RefreshPickItem(PackType type, string guid)
|
{
|
if (type != PackType.Item) return;
|
|
if (RefreshPickItemEvent != null)
|
{
|
RefreshPickItemEvent(type, guid);
|
}
|
}
|
|
Dictionary<int, ItemModel> RealmBetterDict = new Dictionary<int, ItemModel>();
|
public Dictionary<int, ItemModel> CheckBetterEquipByRealm()
|
{
|
RealmBetterDict.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
if (singlePack == null) return RealmBetterDict;
|
|
int realmLv = PlayerDatas.Instance.baseData.realmLevel;
|
Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
|
foreach (var model in pairs.Values)
|
{
|
if (model.config.EquipPlace > 0
|
&& model.config.EquipPlace != (int)RoleEquipType.SpiritAnimal
|
&& model.config.RealmLimit <= realmLv
|
&& !IsOverdue(model.itemInfo.ItemGUID, model.itemId, model.useDataDict)
|
&& IsFightUp(model.itemId, model.equipScore) == 1)
|
{
|
if (!RealmBetterDict.ContainsKey(model.EquipPlace))
|
{
|
RealmBetterDict.Add(model.EquipPlace, model);
|
}
|
else
|
{
|
if (model.equipScore > RealmBetterDict[model.EquipPlace].equipScore)
|
{
|
RealmBetterDict[model.EquipPlace] = model;
|
}
|
}
|
}
|
}
|
return RealmBetterDict;
|
}
|
|
List<ItemModel> RealmDruglist = new List<ItemModel>();
|
public List<ItemModel> GetDruglistByRealm()
|
{
|
RealmDruglist.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
if (singlePack == null) return RealmDruglist;
|
|
int realmLv = PlayerDatas.Instance.baseData.realmLevel;
|
Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
|
foreach (var model in pairs.Values)
|
{
|
if (playerPack.CheckIsDrugById(model.itemId))
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(model.itemId);
|
if (!playerPack.IsReachMaxUseDrug(fruitConfig)
|
&& model.config.RealmLimit <= realmLv)
|
{
|
RealmDruglist.Add(model);
|
}
|
}
|
}
|
return RealmDruglist;
|
}
|
#endregion
|
|
#region 解锁格子
|
|
public void OpenGrid(int chooseGridCount, PackType type)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(type);
|
int openCount = chooseGridCount - singlePack.openGridCount;
|
int index = 0;
|
switch (type)
|
{
|
case PackType.Item:
|
index = chooseGridCount - playerPack.InitBagGridCnt;
|
break;
|
case PackType.Warehouse:
|
index = chooseGridCount - playerPack.InitDepotGridCnt;
|
break;
|
}
|
itemTipsModel.SetExtendGirdModel(openCount, index, type);
|
WindowCenter.Instance.Open<ExtendWin>();
|
}
|
|
#endregion
|
|
#region 物品处于CD中的逻辑处理
|
|
private Dictionary<string, double> itemEffectCDDict = new Dictionary<string, double>(); //key 物品实例ID
|
private List<string> itemEffectTimelist = new List<string>(); //key 物品实例ID
|
/// <summary>
|
/// 物品使用时间限制
|
/// </summary>
|
public void SetItemEffectCDTime(string guid, int itemID, int getTime, int serverSurplusTime)
|
{
|
double time = GetTimeOffest(TimeUtility.GetTime((uint)getTime));
|
if (time < 0)
|
{
|
time = 0;
|
}
|
itemEffectTimelist.Add(guid);
|
ItemConfig itemConfig = ItemConfig.Get(itemID);
|
if (time >= itemConfig.ExpireTime)
|
{
|
KnapsackTimeCDMgr.Instance.UnRegister(guid);
|
return;
|
}
|
double remainTime = (serverSurplusTime > 0 ? serverSurplusTime : itemConfig.ExpireTime) - time;
|
KnapsackTimeCDMgr.Instance.Register(guid, itemID, remainTime);
|
}
|
|
public double GetTimeOffest(DateTime getTime)
|
{
|
DebugEx.Log("现在时间:" + TimeUtility.ServerNow + "获得时间:" + getTime);
|
//TimeUtility.SyncServerTime();
|
TimeSpan t = TimeUtility.ServerNow - getTime;
|
DebugEx.Log("时间差:" + t.TotalSeconds);
|
return t.TotalSeconds;
|
}
|
|
public List<string> GetItemEffectTimelist()
|
{
|
return itemEffectTimelist;
|
}
|
|
#endregion
|
|
#region 设置可以一键出售的物品数据
|
|
private int playerLv;
|
private Dictionary<int, List<ItemModel>> _lifePotionDict = new Dictionary<int, List<ItemModel>>(); //key 药水等级
|
private List<int> _sellItemScorelist = new List<int>();
|
private Dictionary<int, Dictionary<int, List<ItemModel>>> _sameIndexEquipDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>(); //存储相同装备位的装备
|
// private _sameEquipScoreDict = new Dictionary<int, List<ItemModel>>(); //存储相同ID中相同装备评分的装备
|
private Dictionary<int, ItemModel> _packModelDict;
|
private List<ItemModel> _sellItemlist = new List<ItemModel>();
|
|
public List<ItemModel> GetSellItemList()
|
{
|
GetOneKeySellModel();
|
_sellItemlist.Sort(SetSellItemOrder);
|
return _sellItemlist;
|
}
|
|
public int SetSellItemOrder(ItemModel startModel, ItemModel endModel)
|
{
|
bool startIsEquip = IsEquip(startModel);
|
bool endIsEquip = IsEquip(endModel);
|
if (startIsEquip.CompareTo(endIsEquip) != 0) return -startIsEquip.CompareTo(endIsEquip);
|
int order1 = startModel.config.Type;
|
int order2 = endModel.config.Type;
|
if (order1.CompareTo(order2) != 0) return order1.CompareTo(order2);
|
int color1 = startModel.config.ItemColor;
|
int color2 = endModel.config.ItemColor;
|
if (color1.CompareTo(color2) != 0) return -color1.CompareTo(color2);
|
int code1 = startModel.itemInfo.ItemID;
|
int code2 = endModel.itemInfo.ItemID;
|
if (code1.CompareTo(code2) != 0) return -code1.CompareTo(code2);
|
return 0;
|
}
|
|
public bool IsEquip(ItemModel model)
|
{
|
if (model.config.EquipPlace != 0)
|
return true;
|
else
|
return false;
|
}
|
|
public void GetOneKeySellModel()
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
if (singlePack == null)
|
return;
|
|
_sellItemlist.Clear();
|
_lifePotionDict.Clear();
|
_sameIndexEquipDict.Clear();
|
_sellItemScorelist.Clear();
|
playerLv = PlayerDatas.Instance.baseData.LV;
|
_packModelDict = singlePack.GetPackModelIndexDict();
|
foreach (var key in _packModelDict.Keys)
|
{
|
GetCanSellEquipList(_packModelDict[key]);
|
ItemModel itemModel = _packModelDict[key];
|
if (drugIDs.Contains(itemModel.itemInfo.ItemID))
|
{
|
if (!_lifePotionDict.ContainsKey(itemModel.config.LV))
|
{
|
List<ItemModel> modellist = new List<ItemModel>();
|
modellist.Add(itemModel);
|
_lifePotionDict.Add(itemModel.config.LV, modellist);
|
}
|
else
|
{
|
_lifePotionDict[itemModel.config.LV].Add(itemModel);
|
}
|
}
|
}
|
|
#region 得到可以出售的装备
|
foreach (var key in _sameIndexEquipDict.Keys)
|
{
|
_sellItemScorelist = _sameIndexEquipDict[key].Keys.ToList();
|
_sellItemScorelist.Sort();
|
if (_sellItemScorelist.Count > 0)
|
{
|
int score = 0;
|
int curJob = PlayerDatas.Instance.baseData.Job;
|
for (score = _sellItemScorelist.Count - 1; score > -1; score--)
|
{
|
SinglePackModel equipPack = playerPack.GetSinglePackModel(PackType.Equip);
|
ItemModel model = null;
|
if (equipPack != null)
|
{
|
model = equipPack.GetItemModelByIndex(key);
|
}
|
|
List<ItemModel> modellist = _sameIndexEquipDict[key][_sellItemScorelist[score]];
|
int i = 0;
|
bool remainBetter = true;
|
for (i = 0; i < modellist.Count; i++)
|
{
|
double joblimit = Math.Floor((double)modellist[i].config.JobLimit / 100);
|
if (model != null)
|
{
|
if (remainBetter)
|
{
|
if (model.equipScore < _sellItemScorelist[score] && curJob == joblimit)
|
{
|
_sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
|
remainBetter = false;
|
break;
|
}
|
}
|
|
}
|
else
|
{
|
if (curJob == joblimit)
|
{
|
if (remainBetter)
|
{
|
_sameIndexEquipDict[key].Remove(_sellItemScorelist[score]);
|
remainBetter = false;
|
break;
|
}
|
}
|
}
|
}
|
|
if (!remainBetter)
|
{
|
break;
|
}
|
|
}
|
int j = 0;
|
for (j = 0; j < _sellItemScorelist.Count; j++)
|
{
|
|
if (_sameIndexEquipDict[key].ContainsKey(_sellItemScorelist[j]))
|
{
|
int k = 0;
|
List<ItemModel> sellModlelist = _sameIndexEquipDict[key][_sellItemScorelist[j]];
|
for (k = 0; k < sellModlelist.Count; k++)
|
{
|
_sellItemlist.Add(sellModlelist[k]);
|
}
|
}
|
}
|
|
}
|
|
}
|
#endregion
|
|
List<int> drugLvlist = new List<int>();
|
drugLvlist.AddRange(_lifePotionDict.Keys.ToList());
|
drugLvlist.Sort();
|
for (int i = drugLvlist.Count - 1; i > -1; i--)
|
{
|
if (drugLvlist[i] > playerLv)
|
{
|
_lifePotionDict.Remove(drugLvlist[i]);
|
}
|
else
|
{
|
_lifePotionDict.Remove(drugLvlist[i]);
|
break;
|
}
|
}
|
|
foreach (var list in _lifePotionDict.Values)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
_sellItemlist.Add(list[i]);
|
}
|
|
}
|
}
|
|
|
//得到满足出售条件的装备列表
|
public void GetCanSellEquipList(ItemModel model)
|
{
|
|
if (model.config.EquipPlace == 0 || !onekeySellTypes.Contains(model.config.Type))
|
return;
|
|
Dictionary<int, List<ItemModel>> sameScoreDict;
|
List<ItemModel> sameScorelist;
|
|
if (model.config.ItemColor < 3)
|
{
|
if (!_sameIndexEquipDict.ContainsKey(model.config.EquipPlace))
|
{
|
sameScoreDict = new Dictionary<int, List<ItemModel>>();
|
sameScorelist = new List<ItemModel>();
|
sameScorelist.Add(model);
|
sameScoreDict.Add(model.equipScore, sameScorelist);
|
_sameIndexEquipDict.Add(model.config.EquipPlace, sameScoreDict);
|
|
}
|
else
|
{
|
if (_sameIndexEquipDict[model.config.EquipPlace].ContainsKey(model.equipScore))
|
{
|
_sameIndexEquipDict[model.config.EquipPlace][model.equipScore].Add(model);
|
}
|
else
|
{
|
sameScorelist = new List<ItemModel>();
|
sameScorelist.Add(model);
|
_sameIndexEquipDict[model.config.EquipPlace].Add(model.equipScore, sameScorelist);
|
}
|
|
}
|
}
|
|
|
}
|
|
#endregion
|
|
#region 发送请求
|
/// <summary>
|
/// 一键出售物品的请求
|
/// </summary>
|
/// <param name="_oneKeySelllist"></param>
|
public void SendOneKeySellQuest(List<ItemModel> _oneKeySelllist)
|
{
|
if (!isPackResetOk || SettingEffectMgr.Instance.isStartOneKeySell) return;
|
|
SettingEffectMgr.Instance.isStartOneKeySell = true;
|
byte[] itemIndexs = new byte[_oneKeySelllist.Count];
|
int i = 0;
|
for (i = 0; i < _oneKeySelllist.Count; i++)
|
{
|
itemIndexs[i] = (byte)_oneKeySelllist[i].itemInfo.ItemPlace;
|
}
|
CA311_tagCMSellItem sellItem = new CA311_tagCMSellItem();
|
sellItem.PackType = (int)PackType.Item;
|
sellItem.Count = (byte)_oneKeySelllist.Count;
|
sellItem.ItemIndex = itemIndexs;
|
GameNetSystem.Instance.SendInfo(sellItem);
|
}
|
|
/// <summary>
|
/// 整理包裹物品
|
/// </summary>
|
/// <param name="type"></param>
|
public bool isPackResetOk { get; set; }
|
public void SendPackResetQuest(PackType type)
|
{
|
if (lookLineIndex > -1)
|
{
|
SetLookIndex(null);
|
}
|
|
if (KnapSackWin.titleType == KnapsackFuncTitle.bag)
|
{
|
playerPack.isPlayBetterEquipEffect = true;
|
}
|
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(type);
|
if (singlePack != null)
|
{
|
C070F_tagCItemPackReset packReset = new C070F_tagCItemPackReset();
|
packReset.Type = (byte)type;
|
packReset.ItemBeginIndex = 0;
|
packReset.ItemEndIndex = (ushort)(singlePack.openGridCount - 1);
|
GameNetSystem.Instance.SendInfo(packReset); //整理物品
|
if (type == PackType.Item)
|
{
|
isPackResetOk = false;
|
}
|
}
|
}
|
#endregion
|
|
#region 查看某个位置的物品
|
public event Action lookEquipEvent;
|
private int _lookLineIndex = -1;
|
public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
|
|
public string lookItemGUID { get; private set; }
|
|
public void SetLookIndex(string guid, int singleRowCount = 5)
|
{
|
|
if (string.IsNullOrEmpty(guid) || guid == "")
|
{
|
lookLineIndex = -1;
|
}
|
else
|
{
|
int index = playerPack.GetItemModelByGUID(guid).itemInfo.ItemPlace;
|
lookLineIndex = index / singleRowCount;
|
lookItemGUID = guid;
|
}
|
|
if (lookEquipEvent != null)
|
{
|
lookEquipEvent();
|
}
|
|
}
|
#endregion
|
|
#region 判断是否有更好的装备替换
|
/// <summary>
|
/// 过滤装备位判断
|
/// </summary>
|
/// <param name="ignoreType"></param>
|
/// <returns></returns>
|
public bool CheckBetterEquip(RoleEquipType ignoreType)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Equip);
|
if (singlePack != null)
|
{
|
Dictionary<int, ItemModel> putOnDic = singlePack.GetPackModelIndexDict();
|
foreach (var key in putOnDic.Keys)
|
{
|
if ((RoleEquipType)key == ignoreType)
|
{
|
continue;
|
}
|
if (key < 13)
|
{
|
List<ItemModel> itemlist = GetSameEquipPlacelist(key);
|
int i = 0;
|
for (i = 0; i < itemlist.Count; i++)
|
{
|
bool isOverdue = IsOverdue(itemlist[i].itemInfo.ItemGUID, itemlist[i].itemInfo.ItemID, itemlist[i].useDataDict);
|
bool isRealm = PlayerDatas.Instance.baseData.realmLevel >= itemlist[i].config.RealmLimit ? true : false;
|
if (itemlist[i].equipScore > putOnDic[key].equipScore && !isOverdue && isRealm)
|
{
|
return true;
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
int i = 1;
|
for (i = 1; i < 13; i++)
|
{
|
List<ItemModel> itemlist = GetSameEquipPlacelist(i);
|
if (itemlist.Count > 0)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
private List<ItemModel> GetSameEquipPlacelist(int equipPlace)
|
{
|
List<ItemModel> modellist = new List<ItemModel>();
|
Dictionary<int, ItemModel> dic = null;
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.Item);
|
if (singlePack != null)
|
{
|
dic = singlePack.GetPackModelIndexDict();
|
foreach (var model in dic.Values)
|
{
|
if (model.config.EquipPlace == equipPlace)
|
{
|
double equipJob = Math.Floor((double)model.config.JobLimit / 100);
|
if (equipJob == 0 || equipJob == PlayerDatas.Instance.baseData.Job)
|
{
|
modellist.Add(model);
|
}
|
}
|
}
|
}
|
return modellist;
|
}
|
|
/// <summary>
|
/// 获取装备评分最高可提升战力的装备
|
/// </summary>
|
/// <param name="_places"></param>
|
/// <returns></returns>
|
public string GetHighestScoreEquipByPlace(int equipPlace)
|
{
|
var itemPackage = playerPack.GetSinglePackModel(PackType.Item);
|
var allItems = itemPackage.GetPackModelIndexDict();
|
ItemModel putModel = playerPack.GetItemModelByIndex(PackType.Equip, equipPlace);
|
equipPlace = (equipPlace == 9 || equipPlace == 10) ? 9 : equipPlace;
|
var guid = string.Empty;
|
var equips = new List<string>();
|
var score = putModel == null ? 0 : putModel.equipScore;
|
var job = PlayerDatas.Instance.baseData.Job;
|
foreach (var item in allItems.Values)
|
{
|
if (item.config.EquipPlace == equipPlace)
|
{
|
if (!IsOverdue(item.itemInfo.ItemGUID, item.itemId, item.useDataDict)
|
&& (item.config.JobLimit == 0 || (item.config.JobLimit / 100) == job) && item.equipScore > score)
|
{
|
guid = item.itemInfo.ItemGUID;
|
score = item.equipScore;
|
}
|
}
|
}
|
|
return guid;
|
}
|
#endregion
|
|
#region 背包整理后好的同类型最好的装备
|
public Dictionary<int, Dictionary<int, ItemModel>> itemModelDict = new Dictionary<int, Dictionary<int, ItemModel>>(); // key1 装备位置索引 key2 背包位置索引
|
public void SetBagSortBetterEquipList(ItemModel itemModel)
|
{
|
if (itemModel == null || itemModel.packType != PackType.Item) return;
|
|
if (!IsCanPutOn(itemModel)) return;
|
|
int equipPlace = itemModel.config.EquipPlace;
|
if (!itemModelDict.ContainsKey(equipPlace))
|
{
|
Dictionary<int, ItemModel> dict = new Dictionary<int, ItemModel>();
|
if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
|
{
|
dict.Add(itemModel.itemInfo.ItemPlace, itemModel);
|
itemModelDict.Add(equipPlace, dict);
|
}
|
}
|
else
|
{
|
if (IsFightUp(itemModel.itemId, itemModel.equipScore) == 1)
|
{
|
itemModelDict[equipPlace].Add(itemModel.itemInfo.ItemPlace, itemModel);
|
}
|
}
|
|
}
|
|
public ItemModel GetBagSortBetterEquip(int equipPlace, int index)
|
{
|
ItemModel itemModel = null;
|
if (itemModelDict.ContainsKey(equipPlace))
|
{
|
itemModelDict[equipPlace].TryGetValue(index, out itemModel);
|
}
|
return itemModel;
|
}
|
|
public bool IsCanPutOn(ItemModel itemModel)
|
{
|
double equipJob = Math.Floor((double)itemModel.config.JobLimit / 100);
|
int playerJob = PlayerDatas.Instance.baseData.Job;
|
int equipPlace = itemModel.config.EquipPlace;
|
if (equipPlace == 0 || equipPlace > 12) return false;
|
if (equipJob != 0 && equipJob != playerJob) return false;
|
|
List<int> putOnlimitList = itemModel.GetUseDataModel((int)ItemUseDataKey.cancelUseLimit);
|
if (putOnlimitList != null)
|
{
|
if (putOnlimitList[0] == 1)
|
{
|
return true;
|
}
|
}
|
|
return CheckPutOnRealm(itemModel.config);
|
}
|
|
private bool CheckPutOnRealm(ItemConfig config)
|
{
|
var _realmLv = config.RealmLimit;
|
if (PlayerDatas.Instance.baseData.realmLevel < _realmLv)
|
{
|
return false;
|
}
|
return true;
|
}
|
#endregion
|
|
#region 得到物品的品质颜色
|
private Dictionary<int, int> wingRefineQualityDict;
|
private int[] wingsQualitys;
|
private int[] wingsRefineExps;
|
public int GetItemQuality(int itemId, Dictionary<int, List<int>> useDataDic = null)
|
{
|
wingsQualitys = null;
|
wingsRefineExps = null;
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
wingRefineQualityDict = WingRefineAttrConfig.GetWingsQualityModel(itemConfig.LV);
|
if (useDataDic != null)
|
{
|
if (useDataDic.ContainsKey(42) && wingRefineQualityDict != null)
|
{
|
wingsQualitys = wingRefineQualityDict.Keys.ToArray();
|
wingsRefineExps = wingRefineQualityDict.Values.ToArray();
|
int i = 0;
|
for (i = wingsRefineExps.Length - 1; i > -1; i--)
|
{
|
if (useDataDic[42][0] >= wingsRefineExps[i])
|
{
|
return wingsQualitys[i];
|
}
|
}
|
}
|
}
|
return itemConfig.ItemColor;
|
}
|
#endregion
|
|
|
//设置玩家货币显示
|
public string OnChangeCoinsUnit(ulong value)
|
{
|
|
string strCoins = value.ToString();
|
if (strCoins.Length > 4 && strCoins.Length < 9)
|
{
|
double coins = Math.Floor((double)value / 10000);
|
strCoins = coins + Language.Get("KnapS114");
|
}
|
else if (strCoins.Length >= 9 && strCoins.Length < 13)
|
{
|
double coins = Math.Floor((double)value / 100000000);
|
strCoins = coins + Language.Get("KnapS115");
|
}
|
else if (strCoins.Length >= 13 && strCoins.Length < 19)
|
{
|
double coins = Math.Floor((double)value / 1000000000000);
|
strCoins = coins + Language.Get("KnapS126");
|
}
|
else if (strCoins.Length >= 19)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("KnapS127"));
|
}
|
return strCoins;
|
}
|
|
/// <summary>
|
/// 装备是否可以提升战力
|
/// </summary>
|
/// <param name="_itemID"></param>
|
/// <param name="_score"></param>
|
/// <returns></returns>
|
public int IsFightUp(int _itemID, int _score)//-1低级,0不是本职业,1更好
|
{
|
ItemConfig chinItemModel = ItemConfig.Get(_itemID);
|
if (chinItemModel != null)
|
{
|
ItemModel putOnModel = null;
|
switch((RoleEquipType)chinItemModel.EquipPlace)
|
{
|
case RoleEquipType.Clothes:
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.Belt:
|
case RoleEquipType.Hat:
|
case RoleEquipType.Neck:
|
case RoleEquipType.Shoes:
|
case RoleEquipType.SpiritAnimal:
|
case RoleEquipType.Trousers:
|
case RoleEquipType.Weapon:
|
case RoleEquipType.Weapon2:
|
case RoleEquipType.Wing:
|
putOnModel = playerPack.GetItemModelByIndex(PackType.Equip, chinItemModel.EquipPlace);
|
break;
|
case RoleEquipType.JadeDynasty_Cloak:
|
case RoleEquipType.JadeDynasty_FaceMask:
|
case RoleEquipType.JadeDynasty_Glove1:
|
case RoleEquipType.JadeDynasty_Pendant:
|
case RoleEquipType.JadeDynasty_Ring1:
|
case RoleEquipType.JadeDynasty_Ruyi:
|
case RoleEquipType.JadeDynasty_Sword1:
|
case RoleEquipType.JadeDynasty_Sword2:
|
case RoleEquipType.JadeDynasty_Sword3:
|
case RoleEquipType.JadeDynasty_Sword4:
|
putOnModel = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, chinItemModel.EquipPlace);
|
break;
|
default:
|
return 0;
|
}
|
|
ItemModel putOnModel2 = null;
|
switch((RoleEquipType)chinItemModel.EquipPlace)
|
{
|
case RoleEquipType.FairyCan:
|
putOnModel2 = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FairyCan2);
|
break;
|
case RoleEquipType.JadeDynasty_Glove1:
|
putOnModel2 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Glove2);
|
break;
|
case RoleEquipType.JadeDynasty_Ring1:
|
putOnModel2 = playerPack.GetItemModelByIndex(PackType.JadeDynastyEquip, (int)RoleEquipType.JadeDynasty_Ring2);
|
break;
|
}
|
|
switch ((RoleEquipType)chinItemModel.EquipPlace)
|
{
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.JadeDynasty_Glove1:
|
case RoleEquipType.JadeDynasty_Ring1:
|
if (putOnModel2 != null)
|
{
|
if (putOnModel != null)
|
{
|
if (putOnModel2.equipScore < putOnModel.equipScore)
|
{
|
putOnModel = putOnModel2;
|
}
|
}
|
}
|
else
|
{
|
putOnModel = putOnModel2;
|
}
|
break;
|
}
|
|
int equipScore1 = 0;
|
if (putOnModel != null)
|
{
|
equipScore1 = (int)putOnModel.equipScore;
|
}
|
|
int playerJob = PlayerDatas.Instance.baseData.Job;
|
|
if (playerJob == Math.Floor((double)chinItemModel.JobLimit / 100) || chinItemModel.JobLimit == 0)
|
{
|
if (equipScore1 > _score)
|
return -1;
|
else if (equipScore1 < _score)
|
return 1;
|
else
|
return 0;
|
}
|
else
|
{
|
return 0;
|
}
|
}
|
return 0;
|
}
|
|
#region 物品是否过期
|
public bool IsOverdue(string guid, int itemId, Dictionary<int, List<int>> useDataDict = null)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
if (itemConfig == null) return false;
|
|
if (itemConfig.ExpireTime > 0)
|
{
|
ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(guid);
|
switch ((EquipReduceType)itemConfig.EndureReduceType)
|
{
|
case EquipReduceType.Def_EquipReduceType_Time:
|
if (guid != "")
|
{
|
List<int> itemEffectTime = null;
|
if (useDataDict != null)
|
{
|
if (useDataDict.ContainsKey((int)ItemUseDataKey.createTime))
|
{
|
itemEffectTime = useDataDict[(int)ItemUseDataKey.createTime];
|
}
|
}
|
|
if (itemEffectTime != null && itemEffectTime[0] != 0)
|
{
|
if (cool == null || cool.GetRemainTime() <= 0)
|
{
|
return true;
|
}
|
}
|
}
|
break;
|
|
case EquipReduceType.Def_EquipReduceType_RTimeItem:
|
if (guid != "")
|
{
|
if (cool == null || cool.GetRemainTime() <= 0)
|
{
|
return true;
|
}
|
}
|
break;
|
|
}
|
}
|
|
return false;
|
}
|
#endregion
|
}
|
}
|