Пример #1
0
    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);
    }
Пример #2
0
    protected virtual void OnDamagableDestructed(IDamagable damagable)
    {
        _targetDamagableList.Remove(damagable);

        damagable.RegisterToDamagableDestructedEvent(_onDamagableDestructedAction, false);
        damagable.RegisterToDamageReflectedEvent(_onDamageReflectedAction, false);
    }