public override void ReverseEffect(EventSetData data) { EventSetEffectData attributeData = data as EventSetEffectData; EffectLog.Assert(attributeData != null, "属性变更 参数类型不对[{0}]", data); if (attributeData == null) { return; } // 属性和数值 EntityAttributeProperty attPro = attributeData._entity.AttributeProp; // 1.更新的属性类型 E_EntityAttributeType attributeType = _attParam.entity_attribute_type; AttributeIntParam attributeParam = attPro.FindAttribute(attributeType); float oldValue = attributeParam.Value; attributeParam.SetPlus(_cumulativeData); float changeValue = attributeParam.Value - oldValue; EffectLog.Log("属性变更回退--->属性:[{0}],before:[{1}],after:[{2}],change:[{3}]", attributeType, oldValue, attributeParam.Value, changeValue); }
public AttributeIntParam FindAttribute(E_EntityAttributeType type) { AttributeIntParam param; if (_param.TryGetValue(type, out param)) { return(param); } LogManager.Error("找不到对应的属性:[{0}]", type); return(null); }
public string value_text = string.Empty; // 描述文本 public void ParseParam(TextNode text_node) { string attribute_string = text_node.GetAttribute(EffectTemplateInfo.ATTRIBUTETYPE); entity_attribute_type = (E_EntityAttributeType)Enum.Parse(typeof(E_EntityAttributeType), attribute_string); List <TextNode> nodes = text_node.GetNodes(EffectTemplateInfo.GROUP); values = new List <EffValueData>(nodes.Count); int length = nodes.Count; for (int i = 0; i < length; i++) { EffValueData param = new EffValueData(); param.ParseParam(nodes[i]); values.Add(param); } }
public override void ExcuteEffect(EventSetData data) { // 参数 EventSetEffectData attributeData = data as EventSetEffectData; EffectLog.Assert(attributeData != null, "属性变更 参数类型不对[{0}]", data); if (attributeData == null) { return; } // 属性和数值 EntityAttributeProperty attPro = attributeData._entity.AttributeProp; // 1.更新的属性类型 E_EntityAttributeType attributeType = _attParam.entity_attribute_type; AttributeIntParam attributeParam = attPro.FindAttribute(attributeType); float oldValue = attributeParam.Value; float newValue = 0; int length = _attParam.values.Count; for (int i = 0; i < length; i++) { float tmpValue = attributeParam.Value; // 2.更新的数据的类型(百分比、固定数值) E_DataUpdateType dataUpdateType = _attParam.values[i].data_type; // 3.数值 float dataValue = _attParam.values[i].value; // 4.计算 ValueHelper.Calc(attributeParam, dataUpdateType, (int)dataValue); newValue += (attributeParam.Value - tmpValue); } _cumulativeData += newValue; EffectLog.Log("执行计算--->属性:[{0}],before:[{1}],after:[{2}],change:[{3}]", attributeType, oldValue, attributeParam.Value, newValue); }
public AttributeIntParam FindAttribute(E_EntityAttributeType type) { return(_attribute.FindAttribute(type)); }