/// <summary> /// Update is called every frame, if the MonoBehaviour is enabled. /// </summary> void Update() { if (Input.GetKeyDown(KeyCode.D)) { HP.ApplyChange(-DamageAmount); HP.Value = Mathf.Clamp(HP.Value, 0, 100); } if (Input.GetKeyDown(KeyCode.H)) { HP.ApplyChange(HealAmount); HP.Value = Mathf.Clamp(HP.Value, 0, 100); } }
private void OnTriggerEnter(Collider other) { DamageDealer damage = other.gameObject.GetComponent <DamageDealer>(); if (damage != null) { Health.ApplyChange(-damage.DamageAmount); DamageEvent.Invoke(); } if (Health.Value <= 0.0f) { DeathEvent.Invoke(); } }