Пример #1
0
    public void TakeDamage(GameObject other)
    {
        if (_hasShields)
        {
            _shields.TakeDamage();
            if (_shields.HasShieldDepleted())
            {
                ActivateShields(false);
                _hasShields = false;
            }
        }
        else
        {
            Destroy(other.gameObject);
            SetAsDestroyed();

            _player.IncreaseScore(10);
        }
    }
Пример #2
0
    public void TakeDamage(float damage)
    {
        if (!_isImmune)
        {
            StartCoroutine(nameof(ShakeCameraRoutine));
            if (_isShieldsUpActive)
            {
                if (_shields != null)
                {
                    _shields.TakeDamage();
                    if (_shields.HasShieldDepleted())
                    {
                        ActivateShields(false);
                    }
                }
            }
            else
            {
                _lives--;
                if (_uiManager)
                {
                    _uiManager.UpdateLives(_lives);
                }
                if (_lives < 1)
                {
                    GameOver();
                }
                else
                {
                    print($"Remaining Lives {_lives}");
                    DamageAnEngine();
                }
            }

            StartCoroutine(StartImmunityRoutine());
        }
    }