public void InflictDamage(float damage, bool isExplosionDamage, GameObject damageSource) { if (health) { var totalDamage = damage; // skip the crit multiplier if it's from an explosion if (!isExplosionDamage) { if (health.gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(3); } totalDamage *= damageMultiplier; } // potentially reduce damages if inflicted by self if (health.gameObject == damageSource) { if (health.gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(1); } totalDamage *= sensibilityToSelfdamage; } // apply the damages health.TakeDamage(totalDamage, damageSource); } }
private void HandleDeath() { if (m_IsDead) { return; } // call OnDie action if (currentHealth <= 0f) { if (onDie != null) { if (gameObject.CompareTag("Enemy")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.AddPoints(30); //print("Enemy killed " + player.currentPoints); } if (gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(30); // print("Player died" + player.currentPoints); player.UpdateHighScore(); } m_IsDead = true; onDie.Invoke(); } } }