protected virtual bool AttackTargetDamagable(IDamagable damagable) { bool hitDamagable = false; SetAttackInfo(damagable); _onDamagableDestructedAction = delegate(IDamagable targetDamagable) { OnDamagableDestructed(targetDamagable); }; damagable.RegisterToDamagableDestructedEvent(_onDamagableDestructedAction, true); _onDamageReflectedAction = delegate(AttackInfo attackInfo) { OnDamageReflected(attackInfo); }; damagable.RegisterToDamageReflectedEvent(_onDamageReflectedAction, true); _registeredDamagableList.Add(damagable); if (damagable.TakeDamage(_attackInfo)) { hitDamagable = true; } return(hitDamagable); }
protected virtual void OnDamagableDestructed(IDamagable damagable) { _targetDamagableList.Remove(damagable); damagable.RegisterToDamagableDestructedEvent(_onDamagableDestructedAction, false); damagable.RegisterToDamageReflectedEvent(_onDamageReflectedAction, false); }