Beispiel #1
0
    override public void TakeDamage(DamageSignal signal)
    {
        if (signal.sender == this)
        {
            return;
        }

        if (signal.reciever == this)
        {
            _signalBus.Fire(new AttackBlockedSignal {
                sender = this, isBlocked = _canBlock
            });

            var damageTaken = _canBlock ?
                              signal.sender.CurrentStats.damage - _currentStats.defense :
                              signal.sender.CurrentStats.damage;

            damageTaken = Mathf.Max(0, damageTaken);

            _currentStats.currentHealth -= damageTaken;

            _canBlock = false;
        }

        OnStatsChanged();
        OnCriticalHealth();
        OnDeath();
    }
Beispiel #2
0
 public virtual void DoDamage(DamageSignal signal)
 {
     StartCoroutine(ChangeSpriteCoroutine(_attackSprite));
     _signalBus.Fire(signal);
     _signalBus.Fire(new SFXSignal {
         clip = _attackSound
     });
 }
Beispiel #3
0
    private IEnumerator BeforeAttackCoroutine(DamageSignal signal)
    {
        _spriteNotifier.SetActive(true);
        yield return(new WaitForSeconds(_timeToNotify));

        _spriteNotifier.SetActive(false);
        base.DoDamage(signal);
    }
Beispiel #4
0
    private void Attack(PlayerAttackSignal signal)
    {
        DamageSignal damageSignal = new DamageSignal {
            reciever = _enemyToAttack, sender = this
        };

        DoDamage(damageSignal);
    }
Beispiel #5
0
    public override void TakeDamage(DamageSignal signal)
    {
        base.TakeDamage(signal);

        _signalBus.Fire(new UpdateEnemyHealthSignal {
            enemy = this
        });
        OnEnemyDeath();
    }
Beispiel #6
0
    public virtual void TakeDamage(DamageSignal signal)
    {
        if (signal.sender == this)
        {
            return;
        }

        if (signal.reciever == this)
        {
            _currentStats.currentHealth -= signal.sender.CurrentStats.damage;
            _attackDelay = 0;
        }
    }
Beispiel #7
0
    protected IEnumerator DoDamageCoroutine(Character character)
    {
        while (character.CurrentStats.currentHealth > 0)
        {
            while (_attackDelay < 2f)
            {
                _attackDelay += Time.deltaTime;
                yield return(null);
            }

            DamageSignal signal = new DamageSignal {
                reciever = character, sender = this
            };
            DoDamage(signal);
            yield return(new WaitForSeconds(_currentStats.attackSpeed));
        }
    }
Beispiel #8
0
 public override void DoDamage(DamageSignal signal)
 {
     StartCoroutine(BeforeAttackCoroutine(signal));
 }