using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using LitJson;
|
using TableConfig;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class RoleParticularModel : Model
|
{
|
|
public override void Init()
|
{
|
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public int viewPlayer { get; private set; }
|
|
public int viewPlayerType { get; private set; } //0-查看装备 1-查看战力
|
|
private Dictionary<int, ViewPlayerData> viewPlayerDataDic = new Dictionary<int, ViewPlayerData>();
|
private Dictionary<int, ulong> funcFightPowerDict = new Dictionary<int, ulong>();
|
public event Action PowerUpdate;
|
public ItemData GetItemData(RoleEquipType type)
|
{
|
if (viewPlayerDataDic.ContainsKey(viewPlayer))
|
{
|
if (viewPlayerDataDic[viewPlayer].roleEquipDataDic.ContainsKey(type))
|
return viewPlayerDataDic[viewPlayer].roleEquipDataDic[type];
|
}
|
return null;
|
}
|
|
public ViewPlayerData GetViewPlayerData(int player)
|
{
|
ViewPlayerData viewPlayerData = null;
|
viewPlayerDataDic.TryGetValue(player, out viewPlayerData);
|
return viewPlayerData;
|
}
|
|
public void ViewRoleEquip(int playerID)
|
{
|
viewPlayerType = 0;
|
ViewRoleParticulars(playerID);
|
}
|
|
public void ViewRoleFightPower(int playerID)
|
{
|
viewPlayerType = 1;
|
ViewRoleParticulars(playerID);
|
}
|
|
public void ViewKingFairyLeader(int _playerId)
|
{
|
viewPlayerType = 2;
|
ViewRoleParticulars(_playerId);
|
}
|
|
private void ViewRoleParticulars(int playerID)
|
{
|
if (viewPlayerType != 2)
|
{
|
if (playerID == PlayerDatas.Instance.baseData.PlayerID)
|
{
|
return;
|
}
|
}
|
if (playerID == 0)
|
{
|
return;
|
}
|
viewPlayer = playerID;
|
if (viewPlayerDataDic.ContainsKey(playerID))
|
{
|
ViewPlayerData viewPlayerData = viewPlayerDataDic[playerID];
|
if ((DateTime.Now - viewPlayerData.getTime).TotalSeconds < 30)
|
{
|
ShowRoleParticulars(viewPlayerData);
|
return;
|
}
|
}
|
CA212_tagCMViewPlayerInfo pak = new CA212_tagCMViewPlayerInfo();
|
pak.PlayerID = (uint)playerID;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
public void OnRevRoleEquip(HA705_tagSCQueryPlayerCacheResult package)
|
{
|
if (viewPlayer != package.PlayerID)
|
return;
|
ViewPlayerData viewPlayerData = null;
|
if (!viewPlayerDataDic.TryGetValue((int)package.PlayerID, out viewPlayerData))
|
{
|
viewPlayerData = new ViewPlayerData();
|
viewPlayerData.getTime = DateTime.Now;
|
viewPlayerDataDic.Add((int)package.PlayerID, viewPlayerData);
|
}
|
viewPlayerData.getTime = DateTime.Now;
|
viewPlayerData.roleEquipDataDic.Clear();
|
viewPlayerData.itemDatas = JsonMapper.ToObject<ItemData[]>(package.ItemData);
|
viewPlayerData.rolePropData = JsonMapper.ToObject<RolePropData>(package.PropData);
|
viewPlayerData.rolePlusData = new RolePlusData();
|
viewPlayerData.rolePlusData.AnalysisRolePlusData(package.PlusData);
|
if (viewPlayerData.itemDatas != null)
|
{
|
for (int i = 0; i < viewPlayerData.itemDatas.Length; i++)
|
{
|
viewPlayerData.itemDatas[i].AnalysisUserData();
|
viewPlayerData.roleEquipDataDic[(RoleEquipType)viewPlayerData.itemDatas[i].ItemIndex] = viewPlayerData.itemDatas[i];
|
}
|
}
|
viewPlayerData.AnalysisEquipSuit();
|
ShowRoleParticulars(viewPlayerData);
|
}
|
|
public void OnRevRoleFuncPower(HA3A1_tagMCModuleFightPowerInfo package)
|
{
|
if (package.MFPCnt == 0)
|
return;
|
for (int i = 0; i < package.MFPList.Length; i++)
|
{
|
funcFightPowerDict[package.MFPList[i].MfpType] = package.MFPList[i].FightPower;
|
}
|
if (PowerUpdate != null)
|
{
|
PowerUpdate();
|
}
|
}
|
|
public ulong GetFuncFightPower(int type)
|
{
|
if (funcFightPowerDict.ContainsKey(type))
|
{
|
return funcFightPowerDict[type];
|
}
|
return 0;
|
}
|
|
#region 查看玩家坐骑灵宠属性
|
List<int> skills = new List<int>();
|
Dictionary<int, float> propertyDict = new Dictionary<int, float>();
|
public int GetHorseFightPower(List<HorseInfo> horses)
|
{
|
var fightPower = 0;
|
for (int i = 0; i < horses.Count; i++)
|
{
|
fightPower += GetHorseFightPower(horses[i].id, horses[i].lv);
|
}
|
return fightPower;
|
}
|
|
public int GetHorseFightPower(int _id, int lv)
|
{
|
var fightPower = GetHorseSkillFightPower(_id, lv);
|
var horseUpConfig = HorseUpConfig.GetHorseIDAndLV(_id, lv);
|
Dictionary<int, int> dict = new Dictionary<int, int>();
|
var propertys = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrType);
|
var values = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrValue);
|
for (int i = 0; i < propertys.Length; i++)
|
{
|
if (propertys[i] == (int)AttrEnum.ATK || propertys[i] == (int)AttrEnum.HP)
|
{
|
if (!dict.ContainsKey(propertys[i]))
|
{
|
dict.Add(propertys[i], values[i]);
|
}
|
else
|
{
|
dict[propertys[i]] += values[i];
|
}
|
}
|
}
|
fightPower += UIHelper.GetFightPower(dict);
|
var config = Config.Instance.Get<HorseConfig>(_id);
|
fightPower += config.InitFightPower;
|
return fightPower;
|
}
|
|
public int GetHorseSkillFightPower(int _id, int lv)
|
{
|
var fightPower = 0;
|
HorseUpConfig.GetHorseSkills(_id, lv, true, ref skills);
|
for (int i = 0; i < skills.Count; i++)
|
{
|
Dictionary<int, int> dict1 = null;
|
Dictionary<int, int> dict2 = null;
|
var skillConfig = Config.Instance.Get<SkillConfig>(skills[i]);
|
if (skillConfig == null)
|
{
|
continue;
|
}
|
if (skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue11, skillConfig.EffectValue12, skillConfig.EffectValue13, single);
|
}
|
if (skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue21, skillConfig.EffectValue22, skillConfig.EffectValue23, single);
|
}
|
if (skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue31, skillConfig.EffectValue32, skillConfig.EffectValue33, single);
|
}
|
if (skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue41, skillConfig.EffectValue42, skillConfig.EffectValue43, single);
|
}
|
if (skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue51, skillConfig.EffectValue52, skillConfig.EffectValue53, single);
|
}
|
if (skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
Dictionary<int, int> dict = single ? dict1 : dict2;
|
dict = GetHorseSkillProperty(skillConfig.EffectValue61, skillConfig.EffectValue62, skillConfig.EffectValue63, single);
|
}
|
fightPower += dict1 == null ? 0 : UIHelper.GetFightPower(dict1);
|
fightPower += dict2 == null ? 0 : UIHelper.GetFightPower(dict2);
|
fightPower += skillConfig.FightPower;
|
}
|
return fightPower;
|
}
|
|
public void GetHorseProperty(List<HorseInfo> horses, ref Dictionary<int, int> propertyDict)
|
{
|
if (propertyDict == null)
|
{
|
return;
|
}
|
propertyDict.Clear();
|
for (int i = 0; i < horses.Count; i++)
|
{
|
HorseUpConfig horseUpConfig = HorseUpConfig.GetHorseIDAndLV(horses[i].id, horses[i].lv);
|
GetHorseProperty(horses[i].id, horses[i].lv, ref propertyDict);
|
var propertys = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrType);
|
var values = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrValue);
|
for (int k = 0; k < propertys.Length; k++)
|
{
|
if (!propertyDict.ContainsKey(propertys[k]))
|
{
|
propertyDict.Add(propertys[k], values[k]);
|
}
|
else
|
{
|
if (propertys[k] == (int)AttrEnum.MoveSpeed)
|
{
|
if (values[k] > propertyDict[propertys[k]])
|
{
|
propertyDict[propertys[k]] = values[k];
|
}
|
}
|
else
|
{
|
propertyDict[propertys[k]] += values[k];
|
}
|
}
|
}
|
}
|
}
|
|
public void GetHorseProperty(int _id, int lv, ref Dictionary<int, int> propertyDict)
|
{
|
HorseUpConfig.GetHorseSkills(_id, lv, true, ref skills);
|
for (int i = 0; i < skills.Count; i++)
|
{
|
Dictionary<int, int> dict1 = null;
|
Dictionary<int, int> dict2 = null;
|
var skillConfig = Config.Instance.Get<SkillConfig>(skills[i]);
|
if (skillConfig == null)
|
{
|
continue;
|
}
|
if (skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue11, skillConfig.EffectValue12, skillConfig.EffectValue13, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue11, skillConfig.EffectValue12, skillConfig.EffectValue13, single);
|
}
|
}
|
if (skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue21, skillConfig.EffectValue22, skillConfig.EffectValue23, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue21, skillConfig.EffectValue22, skillConfig.EffectValue23, single);
|
}
|
}
|
if (skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue31, skillConfig.EffectValue32, skillConfig.EffectValue33, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue31, skillConfig.EffectValue32, skillConfig.EffectValue33, single);
|
}
|
}
|
if (skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue41, skillConfig.EffectValue42, skillConfig.EffectValue43, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue41, skillConfig.EffectValue42, skillConfig.EffectValue43, single);
|
}
|
}
|
if (skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue51, skillConfig.EffectValue52, skillConfig.EffectValue53, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue51, skillConfig.EffectValue52, skillConfig.EffectValue53, single);
|
}
|
}
|
if (skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1
|
|| skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty2)
|
{
|
bool single = skillConfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.MountProperty1;
|
if (single)
|
{
|
dict1 = GetHorseSkillProperty(skillConfig.EffectValue61, skillConfig.EffectValue62, skillConfig.EffectValue63, single);
|
}
|
else
|
{
|
dict2 = GetHorseSkillProperty(skillConfig.EffectValue61, skillConfig.EffectValue62, skillConfig.EffectValue63, single);
|
}
|
}
|
if (dict1 != null)
|
{
|
PastePropertyDict(dict1, propertyDict);
|
}
|
if (dict2 != null)
|
{
|
PastePropertyDict(dict2, propertyDict);
|
}
|
}
|
}
|
|
private void PastePropertyDict(Dictionary<int, int> source, Dictionary<int, int> target)
|
{
|
foreach (var key in source.Keys)
|
{
|
if (!target.ContainsKey(key))
|
{
|
target.Add(key, source[key]);
|
}
|
else
|
{
|
target[key] += source[key];
|
}
|
}
|
}
|
|
int[] qualitys;
|
string[] qualityTitles;
|
public string GetQualityDisplay(int quality)
|
{
|
if (qualitys == null)
|
{
|
var config = Config.Instance.Get<FuncConfigConfig>("PetQuality");
|
qualitys = ConfigParse.GetMultipleStr<int>(config.Numerical1);
|
qualityTitles = ConfigParse.GetMultipleStr(config.Numerical2);
|
}
|
for (int i = 0; i < qualitys.Length; i++)
|
{
|
if (quality == qualitys[i])
|
{
|
return qualityTitles[i];
|
}
|
}
|
return string.Empty;
|
}
|
private Dictionary<int, int> GetHorseSkillProperty(int condition, int property, int percent, bool single)
|
{
|
Dictionary<int, int> dict = new Dictionary<int, int>();
|
dict.Add(6, 0);
|
dict.Add(7, 0);
|
|
var viewplayer = GetViewPlayerData(viewPlayer);
|
var horses = viewplayer.rolePlusData.horses;
|
|
if (single)
|
{
|
var horseInfo = horses.Find((x) =>
|
{
|
return x.id == condition;
|
});
|
HorseUpConfig horseUpConfig = HorseUpConfig.GetHorseIDAndLV(horseInfo.id, horseInfo.lv);
|
int[] propertys = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrType);
|
int[] values = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrValue);
|
for (int k = 0; k < propertys.Length; k++)
|
{
|
if (propertys[k] == property && dict.ContainsKey(property))
|
{
|
dict[property] += (int)(values[k] * ((float)percent / 10000));
|
}
|
}
|
}
|
else
|
{
|
for (int i = 0; i < horses.Count; i++)
|
{
|
HorseConfig horseConfig = Config.Instance.Get<HorseConfig>(horses[i].id);
|
if (horseConfig.Quality == condition)
|
{
|
HorseUpConfig horseUpConfig = HorseUpConfig.GetHorseIDAndLV(horses[i].id, horses[i].lv);
|
int[] propertys = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrType);
|
int[] values = ConfigParse.GetMultipleStr<int>(horseUpConfig.AttrValue);
|
for (int k = 0; k < propertys.Length; k++)
|
{
|
if (propertys[k] == property && dict.ContainsKey(property))
|
{
|
dict[property] += (int)(values[k] * ((float)percent / 10000));
|
}
|
}
|
}
|
}
|
}
|
return dict;
|
}
|
|
public int GetPetFightPower(List<PetInfo> pets)
|
{
|
var fightPower = 0;
|
for (int i = 0; i < pets.Count; i++)
|
{
|
fightPower += GetPetFightPower(pets[i].id, pets[i].lv);
|
}
|
return fightPower;
|
}
|
|
public int GetPetFightPower(int id, int lv)
|
{
|
var fightPower = 0;
|
var config = Config.Instance.Get<PetInfoConfig>(id);
|
var _init_fightpower = 0;
|
int.TryParse(config.InitFightPower, out _init_fightpower);
|
fightPower += _init_fightpower;
|
PetInfoConfig.GetPetSkills(id, lv, true, ref skills);
|
var petUpConfig = PetClassCostConfig.GetPetIdAndRank(id, lv);
|
if (petUpConfig != null)
|
{
|
fightPower += Mathf.FloorToInt(petUpConfig.AtkAdd * 2.5f);
|
}
|
for (int i = 0; i < skills.Count; i++)
|
{
|
var skillConfig = Config.Instance.Get<SkillConfig>(skills[i]);
|
if (skillConfig != null)
|
{
|
fightPower += skillConfig.FightPower;
|
}
|
}
|
return fightPower;
|
}
|
|
public int GetPetAtkProperty(List<PetInfo> pets)
|
{
|
var atk = 0;
|
for (int i = 0; i < pets.Count; i++)
|
{
|
atk += GetPetAtkProperty(pets[i].id, pets[i].lv, pets);
|
}
|
return atk;
|
}
|
|
public int GetPetAtkProperty(int id, int lv, List<PetInfo> pets)
|
{
|
var atk = 0;
|
var petUpConfig = PetClassCostConfig.GetPetIdAndRank(id, lv);
|
if (petUpConfig != null)
|
{
|
atk += petUpConfig.AtkAdd;
|
}
|
PetInfoConfig.GetPetSkills(id, lv, true, ref skills);
|
for (int i = 0; i < skills.Count; i++)
|
{
|
atk += GetPetAtkSkillProperty(skills[i], pets);
|
}
|
return atk;
|
}
|
|
public int GetPetAtkSkillProperty(int skillId, List<PetInfo> pets)
|
{
|
SkillConfig skillconfig = Config.Instance.Get<SkillConfig>(skillId);
|
if (skillconfig == null)
|
{
|
return 0;
|
}
|
if (skillconfig.Effect1 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue11, skillconfig.EffectValue12, pets);
|
}
|
else if (skillconfig.Effect2 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue21, skillconfig.EffectValue22, pets);
|
}
|
else if (skillconfig.Effect3 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue31, skillconfig.EffectValue32, pets);
|
}
|
else if (skillconfig.Effect4 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue41, skillconfig.EffectValue42, pets);
|
}
|
else if (skillconfig.Effect5 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue51, skillconfig.EffectValue52, pets);
|
}
|
else if (skillconfig.Effect6 == (int)RidingAndPetActivationModel.RidingAndPetProperty.PetAttack)
|
{
|
return GetPetAttack(skillconfig.EffectValue61, skillconfig.EffectValue62, pets);
|
}
|
return 0;
|
}
|
|
int GetPetAttack(int quality, int value, List<PetInfo> pets)
|
{
|
var atk = 0;
|
for (int i = 0; i < pets.Count; i++)
|
{
|
var config = Config.Instance.Get<PetInfoConfig>(pets[i].id);
|
if (config != null && config.Quality == quality)
|
{
|
var petUpConfig = PetClassCostConfig.GetPetIdAndRank(pets[i].id, pets[i].lv);
|
atk += petUpConfig == null ? 0 : petUpConfig.AtkAdd;
|
}
|
}
|
return (int)(atk * ((float)value / 10000));
|
}
|
|
public bool viewPetStone { get; set; }
|
#endregion
|
|
public event Action<ViewPlayerData> UpdatePlayerParticularEvent;
|
private void ShowRoleParticulars(ViewPlayerData _viewPlayerData)
|
{
|
switch (viewPlayerType)
|
{
|
case 0:
|
if (!WindowCenter.Instance.IsOpen<RoleParticularsWin>())
|
{
|
WindowCenter.Instance.Open<RoleParticularsWin>();
|
}
|
break;
|
case 1:
|
if (!WindowCenter.Instance.IsOpen<ViewFuncPowerWin>())
|
{
|
WindowCenter.Instance.Open<ViewFuncPowerWin>();
|
}
|
break;
|
case 2:
|
if (UpdatePlayerParticularEvent != null)
|
{
|
UpdatePlayerParticularEvent(_viewPlayerData);
|
}
|
break;
|
}
|
}
|
|
public class ViewPlayerData
|
{
|
public ItemData[] itemDatas;
|
public RolePropData rolePropData;
|
public RolePlusData rolePlusData;
|
|
public Dictionary<RoleEquipType, ItemData> roleEquipDataDic = new Dictionary<RoleEquipType, ItemData>();
|
|
public DateTime getTime;
|
|
Dictionary<int, Dictionary<SuitType, int>> suitCountDict = new Dictionary<int, Dictionary<SuitType, int>>();
|
public void AnalysisEquipSuit()
|
{
|
if (itemDatas == null)
|
{
|
return;
|
}
|
suitCountDict.Clear();
|
for (int i = 0; i < itemDatas.Length; i++)
|
{
|
EquipSuit _suit;
|
if (rolePlusData.TryGetEquipSuit(itemDatas[i].ItemIndex, out _suit))
|
{
|
Dictionary<SuitType, int> _dict = new Dictionary<SuitType, int>();
|
suitCountDict.Add(itemDatas[i].ItemIndex, _dict);
|
if (_suit.suitDict.ContainsKey((int)SuitType.HighSuit))
|
{
|
_dict.Add(SuitType.HighSuit, rolePlusData.GetEquipSuitCount(SuitType.HighSuit, itemDatas[i].ItemIndex,
|
_suit.suitDict[(int)SuitType.HighSuit]));
|
}
|
if (_suit.suitDict.ContainsKey((int)SuitType.LowSuit))
|
{
|
_dict.Add(SuitType.LowSuit, rolePlusData.GetEquipSuitCount(SuitType.LowSuit, itemDatas[i].ItemIndex,
|
_suit.suitDict[(int)SuitType.LowSuit]));
|
}
|
}
|
}
|
}
|
|
public Dictionary<SuitType, int> GetEquipAllSuitCount(int _index)
|
{
|
Dictionary<SuitType, int> _dict = null;
|
suitCountDict.TryGetValue(_index, out _dict);
|
return _dict;
|
}
|
|
public int GetSuitTypeCount(SuitType _type)
|
{
|
return rolePlusData.GetEquipSuitCount(_type);
|
}
|
|
public int GetEquipSuitLevel()
|
{
|
int _suitCount = 0;
|
var _rank = 0;
|
if (rolePlusData != null)
|
{
|
var _list = rolePlusData.equipSuitList;
|
ItemData _itemData = null;
|
roleEquipDataDic.TryGetValue(RoleEquipType.retClothes, out _itemData);
|
if (_itemData == null)
|
{
|
return 0;
|
}
|
var itemConfig = Config.Instance.Get<ItemConfig>(_itemData.ItemID);
|
_rank = itemConfig.LV;
|
for (int i = 0; i < _list.Count; i++)
|
{
|
var _suit = _list[i];
|
if (_suit.Index >= (int)RoleEquipType.retHat
|
&& _suit.Index <= (int)RoleEquipType.retShoes
|
&& roleEquipDataDic.TryGetValue((RoleEquipType)_suit.Index, out _itemData))
|
{
|
itemConfig = Config.Instance.Get<ItemConfig>(_itemData.ItemID);
|
if (itemConfig.SuiteiD <= 0)
|
{
|
continue;
|
}
|
|
if (_suit.suitDict != null && (_suit.suitDict.ContainsKey(1) || _suit.suitDict.ContainsKey(2)))
|
{
|
if (itemConfig.LV >= _rank)
|
{
|
_suitCount += 1;
|
}
|
}
|
}
|
}
|
}
|
if (_suitCount == 5)
|
{
|
int _type = 1;
|
return _type * 1000 + rolePropData.Job * 100 + _rank;
|
}
|
return 0;
|
}
|
}
|
|
[Serializable]
|
public class ItemData
|
{
|
public int ItemID;
|
public string UserData;
|
public int ItemIndex;
|
public int IsSuit;
|
public int IsBind;
|
public Dictionary<int, List<int>> useDataDict { get; set; }
|
public void AnalysisUserData()
|
{
|
if (UserData != null && UserData != string.Empty)
|
{
|
useDataDict = ConfigParse.Analysis(UserData);
|
}
|
}
|
}
|
[Serializable]
|
public struct RolePropData
|
{
|
public int LV;
|
public int RealmLV;
|
public string Name;
|
public string FamilyName;
|
public int Job;
|
public int JobRank;
|
public int FamilyID;
|
public ulong FightPower;
|
}
|
|
public class RolePlusData
|
{
|
Dictionary<int, ulong> fightPowerDict = new Dictionary<int, ulong>();
|
Dictionary<int, int> equipPartStarLvDict = new Dictionary<int, int>();
|
Dictionary<int, uint[]> equipPartStoneDict = new Dictionary<int, uint[]>();
|
Dictionary<int, EquipWash> equipWashDict = new Dictionary<int, EquipWash>();
|
Dictionary<int, int> godWeaponDict = new Dictionary<int, int>();
|
Dictionary<int, int> treasureDict = new Dictionary<int, int>();
|
public List<EquipSuit> equipSuitList = new List<EquipSuit>();
|
public List<HorseInfo> horses = new List<HorseInfo>();
|
public List<PetInfo> pets = new List<PetInfo>();
|
public List<PetHorseStone> petHorseStones = new List<PetHorseStone>();
|
public int Horse { get; private set; }
|
public int Pet { get; private set; }
|
|
public int AtkSpeed { get; private set; }
|
public int Rune { get; private set; }
|
|
PlayerSuitModel _suitModel;
|
PlayerSuitModel suitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
RoleParticularModel m_Model;
|
RoleParticularModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RoleParticularModel>());
|
}
|
}
|
|
public ulong GetFightPower(int type)
|
{
|
if (fightPowerDict != null && fightPowerDict.ContainsKey(type))
|
{
|
return fightPowerDict[type];
|
}
|
return 0;
|
}
|
public int GetEquipStarLv(int index)
|
{
|
if (equipPartStarLvDict != null && equipPartStarLvDict.ContainsKey(index))
|
{
|
return equipPartStarLvDict[index];
|
}
|
return 0;
|
}
|
|
public int GetAllEquipStarLV()
|
{
|
int allEquipStarLv = 0;
|
foreach (var lv in equipPartStarLvDict.Values)
|
{
|
allEquipStarLv += lv;
|
}
|
return allEquipStarLv;
|
}
|
|
public uint[] GetEquipStone(int index)
|
{
|
if (equipPartStoneDict != null && equipPartStoneDict.ContainsKey(index))
|
{
|
return equipPartStoneDict[index];
|
}
|
return null;
|
}
|
|
public Dictionary<int, uint[]> GetAllEquipStone()
|
{
|
return equipPartStoneDict;
|
}
|
|
public EquipWash? GetEquipWash(int index)
|
{
|
if (equipWashDict.ContainsKey(index))
|
{
|
return equipWashDict[index];
|
}
|
return null;
|
}
|
|
public int GetTreasureCount(int _type)
|
{
|
if (treasureDict.ContainsKey(_type))
|
{
|
return treasureDict[_type];
|
}
|
return 0;
|
}
|
|
public int GetAllEquipWashLv()
|
{
|
int allEquipWashLv = 0;
|
foreach (var wash in equipWashDict.Values)
|
{
|
allEquipWashLv += wash.LV;
|
}
|
return allEquipWashLv;
|
}
|
|
public int GetGodWeaponLevel(int type)
|
{
|
if (godWeaponDict.ContainsKey(type))
|
{
|
return godWeaponDict[type];
|
}
|
return 0;
|
}
|
|
public int GetEquipSuitCount(SuitType _type)
|
{
|
var _count = 0;
|
for (int i = 0; i < equipSuitList.Count; i++)
|
{
|
if (equipSuitList[i].suitDict != null && equipSuitList[i].suitDict.ContainsKey((int)_type))
|
{
|
_count++;
|
}
|
}
|
return _count;
|
}
|
|
public int GetEquipSuitCount(SuitType _type, int _index, int suitLv)
|
{
|
var _count = 0;
|
for (int i = 0; i < equipSuitList.Count; i++)
|
{
|
EquipSuit _suit = equipSuitList[i];
|
if (suitModel.GetGroupType(_suit.Index) == suitModel.GetGroupType(_index))
|
{
|
if (_suit.suitDict.ContainsKey((int)_type) && _suit.suitDict[(int)_type] > 0)
|
{
|
var _suitLv = _suit.suitDict[(int)_type];
|
ItemData _item = model.GetItemData((RoleEquipType)_suit.Index);
|
if (_item == null)
|
{
|
continue;
|
}
|
var _itemCfg = Config.Instance.Get<ItemConfig>(_item.ItemID);
|
if (suitModel.IsMakerSuit(_type, _itemCfg.ItemColor, _itemCfg.StarLevel))
|
{
|
if (_itemCfg.LV < _suit.suitDict[(int)_type])
|
{
|
_suitLv = _itemCfg.LV;
|
}
|
}
|
else
|
{
|
_suitLv = 0;
|
}
|
if (_suitLv == suitLv)
|
{
|
_count++;
|
}
|
}
|
}
|
}
|
return _count;
|
}
|
|
public bool TryGetEquipSuit(int _index, out EquipSuit _suit)
|
{
|
_suit = default(EquipSuit);
|
var index = equipSuitList.FindIndex((x) =>
|
{
|
return x.Index == _index;
|
});
|
if (index != -1)
|
{
|
_suit = equipSuitList[index];
|
}
|
return index != -1;
|
}
|
|
public void AnalysisRolePlusData(string jsonStr)
|
{
|
try
|
{
|
var jsonData = JsonMapper.ToObject(jsonStr);
|
if (jsonData.Keys.Contains("FightPowerDict"))
|
{
|
var jsonPlusData = jsonData["FightPowerDict"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var key in jsonPlusData.Keys)
|
{
|
int type = int.Parse(key);
|
fightPowerDict.Add(type, ulong.Parse(jsonPlusData[key].ToString()));
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("EquipPartStarLV"))
|
{
|
var jsonPlusData = jsonData["EquipPartStarLV"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var key in jsonPlusData.Keys)
|
{
|
int index = int.Parse(key);
|
equipPartStarLvDict.Add(index, int.Parse(jsonPlusData[key].ToString()));
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("EquipPartStone"))
|
{
|
var jsonPlusData = jsonData["EquipPartStone"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var key in jsonPlusData.Keys)
|
{
|
int index = int.Parse(key);
|
equipPartStoneDict.Add(index, JsonMapper.ToObject<uint[]>(jsonPlusData[key].ToJson()));
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("EquipWash"))
|
{
|
var jsonPlusData = jsonData["EquipWash"];
|
EquipWash[] equipWashs = JsonMapper.ToObject<EquipWash[]>(jsonPlusData.ToJson());
|
for (int i = 0; i < equipWashs.Length; i++)
|
{
|
equipWashDict.Add(equipWashs[i].Place, equipWashs[i]);
|
}
|
}
|
if (jsonData.Keys.Contains("GodWeapon"))
|
{
|
var jsonPlusData = jsonData["GodWeapon"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var key in jsonPlusData.Keys)
|
{
|
int id = int.Parse(key);
|
godWeaponDict.Add(id, int.Parse(jsonPlusData[key].ToString()));
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("Horse"))
|
{
|
var jsonPlusData = jsonData["Horse"];
|
if (jsonPlusData.IsArray)
|
{
|
var horseInfos = JsonMapper.ToObject<HorseInfo[]>(jsonPlusData.ToJson());
|
if (horseInfos != null && horseInfos.Length > 0)
|
{
|
horses.AddRange(horseInfos);
|
}
|
horses.Sort(Compare);
|
}
|
Horse = horses.Count;
|
}
|
else
|
{
|
Horse = 0;
|
}
|
if (jsonData.Keys.Contains("Pet"))
|
{
|
var jsonPlusData = jsonData["Pet"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var _key in jsonPlusData.Keys)
|
{
|
if (_key.Equals("AtkSpeed"))
|
{
|
AtkSpeed = int.Parse(jsonPlusData[_key].ToString());
|
}
|
else if (_key.Equals("PetLV"))
|
{
|
var petInfos = JsonMapper.ToObject<PetInfo[]>(jsonPlusData[_key].ToJson());
|
if (petInfos != null && petInfos.Length > 0)
|
{
|
for (int i = 0; i < petInfos.Length; i++)
|
{
|
var petInfo = petInfos[i];
|
pets.Add(new PetInfo()
|
{
|
id = petInfo.id,
|
lv = petInfo.lv + 1,
|
});
|
}
|
}
|
}
|
}
|
pets.Sort(Compare);
|
}
|
Pet = pets.Count;
|
}
|
else
|
{
|
Pet = 0;
|
}
|
if (jsonData.Keys.Contains("Rune"))
|
{
|
var jsonPlusData = jsonData["Rune"];
|
Rune = int.Parse(jsonPlusData.ToString());
|
}
|
else
|
{
|
Rune = 0;
|
}
|
if (jsonData.Keys.Contains("MagicWeapon"))
|
{
|
var jsonPlusData = jsonData["MagicWeapon"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var _key in jsonPlusData.Keys)
|
{
|
int _type = int.Parse(_key);
|
treasureDict.Add(_type, int.Parse(jsonPlusData[_key].ToString()));
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("EquipPartSuite"))
|
{
|
var _jsonSuitData = jsonData["EquipPartSuite"];
|
if (_jsonSuitData.IsObject)
|
{
|
foreach (var _key in _jsonSuitData.Keys)
|
{
|
var _index = int.Parse(_key);
|
EquipSuit _suit = new EquipSuit()
|
{
|
Index = _index,
|
suitDict = new Dictionary<int, int>()
|
};
|
foreach (var _subKey in _jsonSuitData[_key].Keys)
|
{
|
var _type = int.Parse(_subKey);
|
var _val = int.Parse(_jsonSuitData[_key][_subKey].ToJson());
|
_suit.Add(_type, _val);
|
}
|
equipSuitList.Add(_suit);
|
}
|
}
|
}
|
if (jsonData.Keys.Contains("Fruit"))
|
{
|
var jsonPlusData = jsonData["Fruit"];
|
if (jsonPlusData.IsObject)
|
{
|
foreach (var _key in jsonPlusData.Keys)
|
{
|
var _itemId = int.Parse(_key);
|
var _count = int.Parse(jsonPlusData[_key].ToString());
|
petHorseStones.Add(new PetHorseStone()
|
{
|
item = _itemId,
|
count = _count,
|
});
|
}
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.StackTrace);
|
}
|
}
|
|
int Compare(PetInfo x, PetInfo y)
|
{
|
var config_x = Config.Instance.Get<PetInfoConfig>(x.id);
|
var config_y = Config.Instance.Get<PetInfoConfig>(y.id);
|
if (config_x == null || config_y == null)
|
{
|
return 0;
|
}
|
return -config_x.Sort.CompareTo(config_y.Sort);
|
}
|
|
int Compare(HorseInfo x,HorseInfo y)
|
{
|
var config_x = Config.Instance.Get<HorseConfig>(x.id);
|
var config_y = Config.Instance.Get<HorseConfig>(y.id);
|
if (config_x == null || config_y == null)
|
{
|
return 0;
|
}
|
return -config_x.Sort.CompareTo(config_y.Sort);
|
}
|
}
|
|
public struct EquipWash
|
{
|
public int LV;
|
public int Place;
|
public int[] Value;
|
}
|
|
public struct EquipSuit
|
{
|
public int Index;
|
public Dictionary<int, int> suitDict;
|
|
public void Add(int _type, int _val)
|
{
|
if (suitDict != null && !suitDict.ContainsKey(_type))
|
{
|
suitDict.Add(_type, _val);
|
}
|
}
|
}
|
|
public struct HorseInfo
|
{
|
public int id;
|
public int lv;
|
}
|
|
public struct PetInfo
|
{
|
public int id;
|
public int lv;
|
}
|
|
public struct PetHorseStone
|
{
|
public int item;
|
public int count;
|
}
|
}
|
}
|
|