Пример #1
0
    public void Damage()
    {
        if (_isShieldActived)
        {
            if (_shieldAlpha.a < 0.4f)
            {
                _isShieldActived = false;
                _shieldEffect.SetActive(false);
            }
            else
            {
                _shieldAlpha.a -= 0.4f; //set alpha decrease when damage
                _shieldEffect.GetComponent <SpriteRenderer>().color = _shieldAlpha;
            }
            return;
        }

        if (_isPoisoned)
        {
            _lives -= 2;
        }
        else
        {
            _lives--;
        }

        DamageSprites();

        _cameraShaker.EngageShake(1);
        _uiManager.UpdateSprite(_lives);

        if (_lives < 1)
        {
            _isDestroyed = true;
            _spawnManager.PlayerDeath();
            Instantiate(_explosion, transform.position, Quaternion.identity);
            Destroy(gameObject, 0.5f);
        }
    }