public _AttrValue Add(_AttrValue other) { if (other != null) { this.MinDefense += other.MinDefense; this.MaxDefense += other.MaxDefense; this.MinMDefense += other.MinMDefense; this.MaxMDefense += other.MaxMDefense; this.MinAttack += other.MinAttack; this.MaxAttack += other.MaxAttack; this.MinMAttack += other.MinMAttack; this.MaxMAttack += other.MaxMAttack; this.HitV += other.HitV; this.Dodge += other.Dodge; this.MaxLifeV += other.MaxLifeV; } return(this); }
// 计算图鉴系统属性加成 public void UpdateTuJianProps(GameClient client) { if (client == null) { return; } if (client.ClientData.PictureJudgeReferInfo == null || client.ClientData.PictureJudgeReferInfo.Count == 0) { return; } // 统计每个图鉴Type激活了多少个Item Dictionary <int, int> activeItemByType = new Dictionary <int, int>(); // 计算图鉴总属性 _AttrValue totalAttrValue = new _AttrValue(); // 计算激活的图鉴Item加成 foreach (var kvp in client.ClientData.PictureJudgeReferInfo) { int itemID = kvp.Key; int itemReferCnt = kvp.Value; TuJianItem item = null; if (!TuJianItems.TryGetValue(itemID, out item)) { continue; } // 本item已激活 if (itemReferCnt >= item.CostGoodsCnt) { if (!activeItemByType.ContainsKey(item.TypeID)) { activeItemByType.Add(item.TypeID, 0); } activeItemByType[item.TypeID]++; totalAttrValue.Add(item.AttrValue); if (client.ClientData.ActivedTuJianItem != null && !client.ClientData.ActivedTuJianItem.Contains(itemID)) { client.ClientData.ActivedTuJianItem.Add(itemID); } } } // 计算图鉴Type加成(只有所有子item全部激活的图鉴type) foreach (var kvp in activeItemByType) { TuJianType type = null; if (!TuJianTypes.TryGetValue(kvp.Key, out type)) { continue; } // 本图鉴type全部激活 if (kvp.Value >= type.ItemCnt) { totalAttrValue.Add(type.AttrValue); if (client.ClientData.ActivedTuJianType != null && !client.ClientData.ActivedTuJianType.Contains(kvp.Key)) { client.ClientData.ActivedTuJianType.Add(kvp.Key); } } } client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinAttack, totalAttrValue.MinAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxAttack, totalAttrValue.MaxAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinMAttack, totalAttrValue.MinMAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxMAttack, totalAttrValue.MaxMAttack); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinDefense, totalAttrValue.MinDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxDefense, totalAttrValue.MaxDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MinMDefense, totalAttrValue.MinMDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxMDefense, totalAttrValue.MaxMDefense); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.HitV, totalAttrValue.HitV); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.MaxLifeV, totalAttrValue.MaxLifeV); client.ClientData.PropsCacheManager.SetExtPropsSingle((int)PropsSystemTypes.TuJian, (int)ExtPropIndexes.Dodge, totalAttrValue.Dodge); }
// 把配置的字符串属性值转化为 'attr,value' private _AttrValue analyseToAttrValues(string strAttrs) { if (string.IsNullOrEmpty(strAttrs)) { return(null); } string[] sArry = strAttrs.Split('|'); if (sArry == null || sArry.Length == 0) { return(null); } _AttrValue result = new _AttrValue(); foreach (var str in sArry) { string[] attr = str.Split(','); if (attr == null || attr.Length != 2) { continue; } string attrName = attr[0].ToLower(); string attrValue = attr[1]; string[] attrTwoValue = attrValue.Split('-'); if (attrName == "defense") { if (attrTwoValue != null && attrTwoValue.Length == 2) { result.MinDefense = Global.SafeConvertToInt32(attrTwoValue[0]); result.MaxDefense = Global.SafeConvertToInt32(attrTwoValue[1]); } } else if (attrName == "mdefense") { if (attrTwoValue != null && attrTwoValue.Length == 2) { result.MinMDefense = Global.SafeConvertToInt32(attrTwoValue[0]); result.MaxMDefense = Global.SafeConvertToInt32(attrTwoValue[1]); } } else if (attrName == "attack") { if (attrTwoValue != null && attrTwoValue.Length == 2) { result.MinAttack = Global.SafeConvertToInt32(attrTwoValue[0]); result.MaxAttack = Global.SafeConvertToInt32(attrTwoValue[1]); } } else if (attrName == "mattack") { if (attrTwoValue != null && attrTwoValue.Length == 2) { result.MinMAttack = Global.SafeConvertToInt32(attrTwoValue[0]); result.MaxMAttack = Global.SafeConvertToInt32(attrTwoValue[1]); } } else if (attrName == "hitv") { result.HitV = Global.SafeConvertToInt32(attrTwoValue[0]); } else if (attrName == "dodge") { result.Dodge = Global.SafeConvertToInt32(attrTwoValue[0]); } else if (attrName == "maxlifev") { result.MaxLifeV = Global.SafeConvertToInt32(attrTwoValue[0]); } } return(result); }
public void UpdateTuJianProps(GameClient client) { if (client != null) { if (client.ClientData.PictureJudgeReferInfo != null && client.ClientData.PictureJudgeReferInfo.Count != 0) { Dictionary <int, int> activeItemByType = new Dictionary <int, int>(); _AttrValue totalAttrValue = new _AttrValue(); foreach (KeyValuePair <int, int> kvp in client.ClientData.PictureJudgeReferInfo) { int itemID = kvp.Key; int itemReferCnt = kvp.Value; TuJianItem item = null; if (this.TuJianItems.TryGetValue(itemID, out item)) { if (itemReferCnt >= item.CostGoodsCnt) { if (!activeItemByType.ContainsKey(item.TypeID)) { activeItemByType.Add(item.TypeID, 0); } Dictionary <int, int> dictionary; int typeID; (dictionary = activeItemByType)[typeID = item.TypeID] = dictionary[typeID] + 1; totalAttrValue.Add(item.AttrValue); if (client.ClientData.ActivedTuJianItem != null && !client.ClientData.ActivedTuJianItem.Contains(itemID)) { client.ClientData.ActivedTuJianItem.Add(itemID); } } } } foreach (KeyValuePair <int, int> kvp in activeItemByType) { TuJianType type = null; if (this.TuJianTypes.TryGetValue(kvp.Key, out type)) { if (kvp.Value >= type.ItemCnt) { totalAttrValue.Add(type.AttrValue); if (client.ClientData.ActivedTuJianType != null && !client.ClientData.ActivedTuJianType.Contains(kvp.Key)) { client.ClientData.ActivedTuJianType.Add(kvp.Key); } } } } client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 7, totalAttrValue.MinAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 8, totalAttrValue.MaxAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 9, totalAttrValue.MinMAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 10, totalAttrValue.MaxMAttack }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 3, totalAttrValue.MinDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 4, totalAttrValue.MaxDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 5, totalAttrValue.MinMDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 6, totalAttrValue.MaxMDefense }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 18, totalAttrValue.HitV }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 13, totalAttrValue.MaxLifeV }); client.ClientData.PropsCacheManager.SetExtPropsSingle(new object[] { 12, 19, totalAttrValue.Dodge }); } } }