using System; using System.Collections.Generic; using XUtliPoolLib; namespace XMainClient { internal class XCharacterAttrView : XAttrCommonHandler where T : XAttrCommonFile, new() { private XAttributes m_Attributes; private Dictionary.AttrType> m_showPerAttr = new Dictionary.AttrType> { { XAttributeDefine.XAttr_PhysicalDef_Total, XCharacterAttrView.AttrType.PhysicalDef }, { XAttributeDefine.XAttr_MagicDef_Total, XCharacterAttrView.AttrType.MagicDef }, { XAttributeDefine.XAttr_FireAtk_Total, XCharacterAttrView.AttrType.ElementAtk }, { XAttributeDefine.XAttr_WaterAtk_Total, XCharacterAttrView.AttrType.ElementAtk }, { XAttributeDefine.XAttr_LightAtk_Total, XCharacterAttrView.AttrType.ElementAtk }, { XAttributeDefine.XAttr_DarkAtk_Total, XCharacterAttrView.AttrType.ElementAtk }, { XAttributeDefine.XAttr_FireDef_Total, XCharacterAttrView.AttrType.ElementDef }, { XAttributeDefine.XAttr_WaterDef_Total, XCharacterAttrView.AttrType.ElementDef }, { XAttributeDefine.XAttr_LightDef_Total, XCharacterAttrView.AttrType.ElementDef }, { XAttributeDefine.XAttr_DarkDef_Total, XCharacterAttrView.AttrType.ElementDef }, { XAttributeDefine.XAttr_Critical_Total, XCharacterAttrView.AttrType.Critical }, { XAttributeDefine.XAttr_CritDamage_Total, XCharacterAttrView.AttrType.CritDamage } }; private enum AttrType { ElementAtk, ElementDef, Critical, CritDamage, PhysicalDef, MagicDef, None } public void SetAttributes(XAttributes attributes) { bool flag = this.m_Attributes != attributes; if (flag) { this.m_Attributes = attributes; bool flag2 = base.IsVisible(); if (flag2) { this.RefreshData(); } } } public override void SetData() { base.SetData(); bool flag = this.m_Attributes == null; if (!flag) { CharacterAttributesList.RowData[] table = XCharacterEquipDocument.AttributeTable.Table; XAttrData xattrData = null; foreach (CharacterAttributesList.RowData rowData in table) { bool flag2 = xattrData == null || xattrData.Title != rowData.Section; if (flag2) { xattrData = base._FetchAttrData(); xattrData.Title = rowData.Section; xattrData.Type = AttriDataType.Attri; } XAttributeDefine attributeID = (XAttributeDefine)rowData.AttributeID; xattrData.Left.Add(XStringDefineProxy.GetString(attributeID)); bool flag3 = XSingleton.singleton.GetInt("AttriStat") != 0 && this.m_showPerAttr.ContainsKey(attributeID); if (flag3) { double attr = this.m_Attributes.GetAttr(attributeID); xattrData.Right.Add(string.Format("{0}({1}%)", XAttributeCommon.GetAttrValueStr(rowData.AttributeID, (uint)attr, false), (int)(this.GetAttrPercent(attributeID, attr) * 100.0))); } else { xattrData.Right.Add(XAttributeCommon.GetAttrValueStr(rowData.AttributeID, (uint)this.m_Attributes.GetAttr(attributeID), false)); } } } } private double GetAttrPercent(XAttributeDefine type, double value) { XCharacterAttrView.AttrType type2; bool flag = !this.m_showPerAttr.TryGetValue(type, out type2); if (flag) { type2 = XCharacterAttrView.AttrType.None; } double max = this.GetMax(type2); double min = this.GetMin(type2); CombatParamTable.RowData combatParam = XSingleton.singleton.GetCombatParam(this.m_Attributes.Level); int baseValue = this.GetBaseValue(type, combatParam); double num = this.GetCombatValue(baseValue, value); num = ((num > min) ? num : min); return (num < max) ? num : max; } private double GetMax(XCharacterAttrView.AttrType type) { double result; switch (type) { case XCharacterAttrView.AttrType.ElementAtk: result = XSingleton.singleton.ElemAtkLimit; break; case XCharacterAttrView.AttrType.ElementDef: result = XSingleton.singleton.ElemDefLimit; break; case XCharacterAttrView.AttrType.Critical: result = XSingleton.singleton.CriticalLimit; break; case XCharacterAttrView.AttrType.CritDamage: result = XSingleton.singleton.CritDamageUpperBound; break; case XCharacterAttrView.AttrType.PhysicalDef: result = double.Parse(XSingleton.singleton.GetValue("PhycialAvoidenceLimit")); break; case XCharacterAttrView.AttrType.MagicDef: result = double.Parse(XSingleton.singleton.GetValue("MagicAvoidenceLimit")); break; default: result = 10.0; break; } return result; } private double GetMin(XCharacterAttrView.AttrType type) { double result; if (type != XCharacterAttrView.AttrType.CritDamage) { result = 0.0; } else { result = XSingleton.singleton.CritDamageLowerBound; } return result; } private int GetBaseValue(XAttributeDefine type, CombatParamTable.RowData atkData) { bool flag = atkData == null; int result; if (flag) { result = 0; } else { if (type <= XAttributeDefine.XAttr_MagicDef_Total) { if (type == XAttributeDefine.XAttr_PhysicalDef_Total) { return atkData.PhysicalDef; } if (type == XAttributeDefine.XAttr_MagicDef_Total) { return atkData.MagicDef; } } else { if (type == XAttributeDefine.XAttr_Critical_Total) { return atkData.CriticalBase; } if (type == XAttributeDefine.XAttr_CritDamage_Total) { return atkData.CritDamageBase; } switch (type) { case XAttributeDefine.XAttr_FireAtk_Total: case XAttributeDefine.XAttr_WaterAtk_Total: case XAttributeDefine.XAttr_LightAtk_Total: case XAttributeDefine.XAttr_DarkAtk_Total: return atkData.ElementAtk; case XAttributeDefine.XAttr_FireDef_Total: case XAttributeDefine.XAttr_WaterDef_Total: case XAttributeDefine.XAttr_LightDef_Total: case XAttributeDefine.XAttr_DarkDef_Total: return atkData.ElementDef; } } result = 0; } return result; } private double GetCombatValue(int combatParam, double value) { return value / (value + (double)combatParam); } } }