/// <summary> /// 發生於附加於物件的特殊狀態變更 /// </summary> protected virtual void OnAffixChanged(SpecialStatus oldValue, SpecialStatus newValue) { if (AffixChanged != null) { AffixChanged(this, oldValue, newValue); } }
/// <summary> /// 增加特性物件到活動集合內 /// </summary> /// <param name="item">特性物件</param> public void Add(PropertyBase item) { item.StatusChanged += ItemStatusChanged; item.AffixChanged += ItemAffixChanged; if (item.Status == PropertyStatus.Enabled) { _Affix |= item.Affix; } _Collection.Add(item); item.Binding(this, true); }
/// <summary> /// 清空特性集合 /// </summary> public void Clear() { for (int i = 0; i < _Collection.Count; i++) { _Collection[i].StatusChanged -= ItemStatusChanged; _Collection[i].AffixChanged -= ItemAffixChanged; _Collection[i].BindingUnlock(); _Collection[i].Binding(Scene); } _Affix = RunningBox.SpecialStatus.None; _AffixChanged = false; _Collection.Clear(); }
/// <summary> /// 集合內特性狀態變更動作 /// </summary> private void ItemStatusChanged(object sender, PropertyStatus oldValue, PropertyStatus newValue) { PropertyBase item = sender as PropertyBase; if (item.Affix == RunningBox.SpecialStatus.None) { return; } if (item.Status == PropertyStatus.Enabled) { _Affix |= item.Affix; } else { _AffixChanged = true; } }
/// <summary> /// 集合內特性狀態變更動作 /// </summary> private void ItemAffixChanged(object sender, SpecialStatus oldValue, SpecialStatus newValue) { _AffixChanged = true; }
/// <summary> /// 新增附加狀態特性,單純增加附加狀態無特殊效果的特性 /// </summary> /// <param name="affix">附加狀態</param> /// <param name="durationTime">持續時間(毫秒)</param> public PropertyAffix(SpecialStatus affix, int durationTime) { Affix = affix; DurationTime.Limit = durationTime; }