/// <summary> /// 获取所有的标记 /// </summary> /// <returns></returns> PropertyMark GetAllMark() { PropertyMark mark = PropertyMark.None; foreach (PropertyMark temp in m_MarkDict.Values) { mark |= temp; } return(mark); }
/// <summary> /// 通过标记排除后,获取真正的属性值 /// </summary> /// <param name="value"></param> /// <returns></returns> public PropertyValue GetProperty(PropertyValue value) { PropertyMark allMark = GetAllMark(); if (allMark == PropertyMark.None) { return(value); } PropertyValue resultValue = value; if (CheckMark(allMark, PropertyMark.ForbidReduceHpMax)) { resultValue.hpMax = value.hpMax < 0 ? 0 : value.hpMax; } return(resultValue); }
public bool RemovePropertyMark(IPropertyController effect) { PropertyMark oldMark = GetAllMark(); if (m_MarkDict.Remove(effect)) { if (oldMark != GetAllMark()) { onPropertyMarkChanged.Invoke(); } return(true); } else { return(false); } }
public bool AddPropertyMark(IPropertyController effect, PropertyMark mark) { if (!m_MarkDict.ContainsKey(effect)) { PropertyMark oldMark = GetAllMark(); m_MarkDict.Add(effect, mark); if (oldMark != GetAllMark()) { onPropertyMarkChanged.Invoke(); } return(true); } else { return(false); } }
static bool CheckMark(PropertyMark sourceMark, PropertyMark targetMark) { return((sourceMark & targetMark) == targetMark); }