void TakeDamage() { --health; SetHealthText(); if (health == 0) { SetLose(); EndController(); OnPlayAgain?.Invoke(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Pickup")) { other.GetComponent <ICollectable>().Collect(); ++score; SetScoreText(); } if (other.CompareTag("Trap")) { TakeDamage(); } if (other.CompareTag("Goal")) { SetWin(); EndController(); OnPlayAgain?.Invoke(); } }