public override void Destroy(IEntity entity, IBuffDataComponent buff) { IDamageBuff damageBuff = (IDamageBuff)buff; BuffManager.GetBuffs(damageBuff.Maker, _fixedLifesteals); BuffManager.GetBuffs(damageBuff.Maker, _mechanicBuffs); if (_mechanicBuffs.Count < 1) { return; } var health = _mechanicBuffs[0]; var maxHealth = _mechanicBuffs[1]; foreach (var fixedLifesteal in _fixedLifesteals) { if (fixedLifesteal is IBuffType buffType) { if (damageBuff.Type != buffType.Type) { continue; } } health.Value += fixedLifesteal.Value; if (health.Value > maxHealth.Value) { health.Value = maxHealth.Value; } } }
public override void Create(IEntity entity, IBuffDataComponent buff) { BuffManager.GetBuffs(entity, _damageReducePercentageBuffs); //todo 只使用最后一个减伤buff IDamageReducePercentageBuff damageReduceFixedBuff = _damageReducePercentageBuffs[_damageReducePercentageBuffs.Count - 1]; IDamageBuff damageBuff = (IDamageBuff)buff; if (damageBuff.Type == damageReduceFixedBuff.Type) { damageBuff.Value -= damageBuff.Value * damageReduceFixedBuff.Value; if (damageBuff.Value <= 0) { damageBuff.Value = 0; } } }
public override void Destroy(IEntity entity, IBuffDataComponent buff) { IDamageBuff damageBuff = (IDamageBuff)buff; BuffManager.GetBuffs <IMechanicBuff>(damageBuff.Maker, _hps); if (_hps.Count < 1) { return; } var health = _hps[0]; var maxHealth = _hps[1]; BuffManager.GetBuffs(damageBuff.Maker, _damageReducePercentageBuffs); float per = 0; foreach (var percentageLifesteal in _damageReducePercentageBuffs) { if (percentageLifesteal is IBuffType buffType) { if (damageBuff.Type != buffType.Type) { continue; } } per += percentageLifesteal.Value; } health.Value += damageBuff.Value * per; if (health.Value > maxHealth.Value) { health.Value = maxHealth.Value; } }