Esempio n. 1
0
        public void TakeDamage()
        {
            _hurtAudio.Play();
            _isHurt          = true;
            _agent.isStopped = true;
            _animator.ResetTrigger(_atkDistanceHash);

            if (_isAlive)
            {
                _enemy.CurrentHealth -= CalculateDamageToReceive();

                if (IsCriticalHit())
                {
                    _animator.SetTrigger(_defendHash);
                    _isDefending = true;

                    _playerStatsController.AddCritical();
                }
                else
                {
                    _animator.SetTrigger(_hurtHash);
                }
            }

            if (!_isAlive)
            {
                _enemy.CurrentHealth = 0;
                Die();
            }
        }