public void ReduceHealth(float reduction) { if (isPlayer == true) { if (redScreenOn == false) { if (!hasDied) { playerSounds.HurtClip(); cameraEffects.StartShake(0.04f, 0.08f); StartCoroutine(ScreenBlinkPlayer()); } } } else { if (whiteScreenOn == false) { cameraEffects.StartShake(0.1f, 0.1f); StartCoroutine(ScreenBlinkEnemy()); } } CurrentHealth -= reduction * (Mathf.Min(1, _cooldown * _cooldownRatio)); _cooldown = 0; if (isPlayer == true) { percentileHP = CurrentHealth / MaxHealth; healthBar.fillAmount = percentileHP; } }
// Update is called once per frame void Update() { _cooldown -= Time.deltaTime; if (Input.GetAxis("AttackMelee") != 0 && _cooldown <= 0) { if (!playerHealth.hasDied) { cameraShake.StartShake(0.02f, 0.025f); StartCoroutine(MeleeAttack()); } } }