using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
using LitJson;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
|
public class ItemTipsModel : Model, IBeforePlayerDataInitialize
|
{
|
public Dictionary<int, PetInfoConfig> unlockPetDict { get; private set; }
|
public Dictionary<int, HorseConfig> unlockMountDict { get; private set; }
|
|
Dictionary<int, string> petAndMountQualityDict = new Dictionary<int, string>();
|
string expValueFormula = "";
|
|
public int[] gemType1s { get; private set; }
|
public int[] gemType2s { get; private set; }
|
|
public int[] jumpAndUseTypes { get; private set; }
|
|
PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
StoreModel m_storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
|
public override void Init()
|
{
|
|
var bagUseItem = FuncConfigConfig.Get("BagUseItem");
|
jumpAndUseTypes = ConfigParse.GetMultipleStr<int>(bagUseItem.Numerical1);
|
|
var gemtype1 = FuncConfigConfig.Get("GemType1");
|
gemType1s = ConfigParse.GetMultipleStr<int>(gemtype1.Numerical1);
|
var gemtype2 = FuncConfigConfig.Get("GemType2");
|
gemType2s = ConfigParse.GetMultipleStr<int>(gemtype2.Numerical1);
|
|
var expFormula = FuncConfigConfig.Get("ExpValueDes");
|
expValueFormula = expFormula.Numerical1;
|
|
#region 灵宠坐骑解锁
|
unlockPetDict = new Dictionary<int, PetInfoConfig>();
|
var petInfolist = PetInfoConfig.GetValues();
|
for (int i = 0; i < petInfolist.Count; i++)
|
{
|
if (!unlockPetDict.ContainsKey(petInfolist[i].UnLockNeedItemID))
|
{
|
unlockPetDict.Add(petInfolist[i].UnLockNeedItemID, petInfolist[i]);
|
}
|
Dictionary<int, int> skillDict = new Dictionary<int, int>();
|
int[] skillIds = petInfolist[i].SkillID;
|
int[] skillUnlocks = petInfolist[i].SkillUnLock;
|
if (skillIds != null)
|
{
|
for (int j = 0; j < skillIds.Length; j++)
|
{
|
skillDict.Add(skillUnlocks[j], skillIds[j]);
|
}
|
}
|
}
|
|
unlockMountDict = new Dictionary<int, HorseConfig>();
|
var horselist = HorseConfig.GetValues();
|
for (int i = 0; i < horselist.Count; i++)
|
{
|
if (!unlockMountDict.ContainsKey(horselist[i].UnlockItemID))
|
{
|
unlockMountDict.Add(horselist[i].UnlockItemID, horselist[i]);
|
}
|
}
|
#endregion
|
|
FuncConfigConfig petQuality = FuncConfigConfig.Get("PetQuality");
|
int[] qualitys = ConfigParse.GetMultipleStr<int>(petQuality.Numerical1);
|
string[] qualityNames = ConfigParse.GetMultipleStr(petQuality.Numerical2);
|
if (qualitys != null && qualityNames != null
|
&& qualitys.Length == qualityNames.Length)
|
{
|
for (int i = 0; i < qualitys.Length; i++)
|
{
|
petAndMountQualityDict.Add(qualitys[i], qualityNames[i]);
|
}
|
}
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
|
Dictionary<int, int> GetItemEffectDict(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null)
|
{
|
return null;
|
}
|
|
var itemEffectDict = new Dictionary<int, int>();
|
try
|
{
|
if (config.Effect1 != 0)
|
itemEffectDict.Add(config.Effect1, config.EffectValueA1);
|
if (config.Effect2 != 0)
|
itemEffectDict.Add(config.Effect2, config.EffectValueA2);
|
if (config.Effect3 != 0)
|
itemEffectDict.Add(config.Effect3, config.EffectValueA3);
|
if (config.Effect4 != 0)
|
itemEffectDict.Add(config.Effect4, config.EffectValueA4);
|
if (config.Effect5 != 0)
|
itemEffectDict.Add(config.Effect5, config.EffectValueA5);
|
|
}
|
catch (Exception ex)
|
{
|
DebugEx.Log(ex.ToString());
|
}
|
|
return itemEffectDict;
|
}
|
|
Dictionary<int, List<int>> GetItemEffectsDict(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null)
|
{
|
return null;
|
}
|
|
var dict = new Dictionary<int, List<int>>();
|
if (config.Effect1 != 0)
|
{
|
List<int> valuelist = new List<int>();
|
valuelist.Add(config.EffectValueA1);
|
valuelist.Add(config.EffectValueB1);
|
valuelist.Add(config.EffectValueC1);
|
dict.Add(config.Effect1, valuelist);
|
}
|
|
if (config.Effect2 != 0)
|
{
|
List<int> valuelist = new List<int>();
|
valuelist.Add(config.EffectValueA2);
|
valuelist.Add(config.EffectValueB2);
|
valuelist.Add(config.EffectValueC2);
|
dict.Add(config.Effect2, valuelist);
|
}
|
|
if (config.Effect3 != 0)
|
{
|
List<int> valuelist = new List<int>();
|
valuelist.Add(config.EffectValueA3);
|
valuelist.Add(config.EffectValueB3);
|
valuelist.Add(config.EffectValueC3);
|
dict.Add(config.Effect3, valuelist);
|
}
|
|
if (config.Effect4 != 0)
|
{
|
List<int> valuelist = new List<int>();
|
valuelist.Add(config.EffectValueA4);
|
valuelist.Add(config.EffectValueB4);
|
valuelist.Add(config.EffectValueC4);
|
dict.Add(config.Effect4, valuelist);
|
}
|
|
if (config.Effect5 != 0)
|
{
|
List<int> valuelist = new List<int>();
|
valuelist.Add(config.EffectValueA5);
|
valuelist.Add(config.EffectValueB5);
|
valuelist.Add(config.EffectValueC5);
|
dict.Add(config.Effect5, valuelist);
|
}
|
|
return dict;
|
}
|
|
#region 解锁背包格子数据
|
public int OpenCount {
|
get; private set;
|
}
|
public PackType packType { get; private set; }
|
public int Index {
|
get; private set;
|
}
|
|
public void SetExtendGirdModel(int openCount = 0, int index = -1, PackType type = PackType.Deleted)
|
{
|
this.OpenCount = openCount;
|
this.packType = type;
|
this.Index = index;
|
}
|
#endregion
|
|
public ulong GetAddExpValue(int timeValue, int maxExpLv)
|
{
|
PlayerLVConfig playerLVConfig = PlayerLVConfig.Get(PlayerDatas.Instance.baseData.LV);
|
PlayerLVConfig maxLvConfig = PlayerLVConfig.Get(maxExpLv);
|
int playerReExp = 0;
|
int maxReExp = 0;
|
if (playerLVConfig != null)
|
{
|
playerReExp = playerLVConfig.ReExp;
|
}
|
if (maxLvConfig != null)
|
{
|
maxReExp = maxLvConfig.ReExp;
|
}
|
else
|
{
|
if (maxExpLv <= 0)
|
{
|
maxReExp = playerReExp;
|
}
|
}
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("PlayerReExp", playerReExp);
|
Equation.Instance.AddKeyValue("MaxReExp", maxReExp);
|
Equation.Instance.AddKeyValue("TimeValue", timeValue);
|
return Equation.Instance.Eval<ulong>(expValueFormula);
|
}
|
|
public string GetQualityName(int quality)
|
{
|
string nameStr = string.Empty;
|
petAndMountQualityDict.TryGetValue(quality, out nameStr);
|
return nameStr;
|
}
|
|
#region 物品增加战斗力
|
MountModel mountDatas { get { return ModelCenter.Instance.GetModel<MountModel>(); } }
|
public int GetFightPower(int itemId)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null) return 0;
|
|
var fightPower = 0;
|
var attrIdlist = PlayerPropertyConfig.GetKeys();
|
var fruitlist = AttrFruitConfig.GetKeys();
|
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
Dictionary<int, int> itemEffectDict = GetItemEffectDict(itemId);
|
int atk = 0;
|
int hp = 0;
|
int def = 0;
|
foreach (var attrId in itemEffectDict.Keys)
|
{
|
var attrValue = itemEffectDict[attrId];
|
switch ((PropertyType)attrId)
|
{
|
case PropertyType.ATK:
|
atk += attrValue;
|
break;
|
case PropertyType.HP:
|
hp += attrValue;
|
break;
|
case PropertyType.DEF:
|
def += attrValue;
|
break;
|
case PropertyType.HorseAtkPer:
|
float mountAtk = mountDatas.GetAllMountAttack();
|
atk += Mathf.RoundToInt(mountAtk * ((float)attrValue / 10000));
|
break;
|
case PropertyType.StoneBasePer:
|
break;
|
case PropertyType.RealmBasePer:
|
var realmDict = GetRealmAttrDict();
|
foreach (var key in realmDict.Keys)
|
{
|
var realmValue = realmDict[key];
|
switch ((PropertyType)key)
|
{
|
case PropertyType.ATK:
|
atk += Mathf.RoundToInt(realmValue * ((float)attrValue / 10000));
|
break;
|
case PropertyType.HP:
|
hp += Mathf.RoundToInt(realmValue * ((float)attrValue / 10000));
|
break;
|
case PropertyType.DEF:
|
def += Mathf.RoundToInt(realmValue * ((float)attrValue / 10000));
|
break;
|
}
|
}
|
break;
|
case PropertyType.PetSkillAtkRate:
|
break;
|
case PropertyType.PlusBaseAtkPer:
|
var strengthDict = GetStrengthAttrDict();
|
if (strengthDict.ContainsKey((int)PropertyType.ATK))
|
{
|
var strengthValue = strengthDict[(int)PropertyType.ATK];
|
atk += Mathf.RoundToInt(strengthValue * ((float)attrValue / 10000));
|
}
|
break;
|
default:
|
if (attrIdlist.Contains(attrId.ToString()))
|
{
|
attrDict.Add(attrId, attrValue);
|
}
|
break;
|
}
|
}
|
|
if (atk > 0)
|
{
|
attrDict.Add((int)PropertyType.ATK, atk);
|
}
|
|
if (def > 0)
|
{
|
attrDict.Add((int)PropertyType.DEF, def);
|
}
|
|
if (hp > 0)
|
{
|
attrDict.Add((int)PropertyType.HP, hp);
|
}
|
|
fightPower = UIHelper.GetFightPower(attrDict);
|
if (fruitlist.Contains(itemId.ToString()))
|
{
|
var fruitConfig = AttrFruitConfig.Get(itemId);
|
fightPower += fruitConfig.FightPowerEx;
|
}
|
return fightPower;
|
}
|
|
private Dictionary<int, int> GetRealmAttrDict()
|
{
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
int realmLv = PlayerDatas.Instance.baseData.realmLevel;
|
var realmConfig = RealmConfig.Get(realmLv);
|
if (realmConfig != null)
|
{
|
var attrIds = realmConfig.AddAttrType;
|
var attrValues = realmConfig.AddAttrNum;
|
if (attrIds != null && attrValues != null
|
&& attrIds.Length == attrValues.Length)
|
{
|
for (int i = 0; i < attrIds.Length; i++)
|
{
|
var attrId = attrIds[i];
|
var attrValue = attrValues[i];
|
if (attrValue > 0)
|
{
|
if (!attrDict.ContainsKey(attrId))
|
{
|
attrDict.Add(attrId, attrValue);
|
}
|
else
|
{
|
attrDict[attrId] += attrValue;
|
}
|
}
|
}
|
}
|
}
|
return attrDict;
|
}
|
private Dictionary<int, int> GetStrengthAttrDict()
|
{
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
//var strengthDict = strengthengmodel._EqInfo;
|
//foreach (var index in strengthDict.Keys)
|
//{
|
// var itemModel = playerPack.GetItemByIndex(PackType.Equip, index);
|
// if (itemModel != null)
|
// {
|
// int lv = strengthengmodel.StrengthenTheCeiling(index);
|
// int type = strengthengmodel.GameDefineIndex(index);
|
// //var itemPlus = ItemPlusConfig.GetItemPlusData(type, lv);
|
// //if (itemPlus != null)
|
// //{
|
// // int[] attrIDs = itemPlus.attrIds;
|
// // int[] attrValues = itemPlus.attrValues;
|
// // for (int i = 0; i < attrIDs.Length; i++)
|
// // {
|
// // var attrId = attrIDs[i];
|
// // var attrValue = attrValues[i];
|
// // if (attrValue > 0)
|
// // {
|
// // if (!attrDict.ContainsKey(attrId))
|
// // {
|
// // attrDict.Add(attrId, attrValue);
|
// // }
|
// // else
|
// // {
|
// // attrDict[attrId] += attrValue;
|
// // }
|
// // }
|
// // }
|
// //}
|
// }
|
//}
|
return attrDict;
|
}
|
#endregion
|
|
public string GetShareNumItemDes(int itemId)
|
{
|
string shareNumDes = string.Empty;
|
List<int> idlist = null;
|
bool isShare = playerPack.TryGetShareNumItem(itemId, out idlist);
|
if (isShare)
|
{
|
foreach (var id in idlist)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(id);
|
TextColType colType = itemConfig.ItemColor < 2 ? TextColType.White : (TextColType)itemConfig.ItemColor;
|
string des = UIHelper.AppendColor(colType, itemConfig.ItemName);
|
if (shareNumDes.Length > 0)
|
{
|
shareNumDes = StringUtility.Contact(shareNumDes, "</r>", des);
|
}
|
else
|
{
|
shareNumDes = des;
|
}
|
}
|
}
|
return shareNumDes;
|
}
|
|
public bool TryGetItemFashionData(int itemId, out int fashionType, out int fashionId)
|
{
|
fashionType = 0;
|
fashionId = 0;
|
var effectDict = GetItemEffectsDict(itemId);
|
foreach (var key in effectDict.Keys)
|
{
|
var valueList = effectDict[key];
|
if (key == 244)
|
{
|
fashionType = valueList[0];
|
fashionId = valueList[1];
|
return true;
|
}
|
}
|
return false;
|
}
|
|
}
|
|
}
|