27 lines
607 B
C#
27 lines
607 B
C#
using UnityEngine;
|
|
|
|
public class PlayerHealthUIController : MonoBehaviour
|
|
{
|
|
[SerializeField] private PlayerHealthView view;
|
|
|
|
private PlayerHealth playerHealth;
|
|
|
|
public void Bind(PlayerHealth _playerHealth)
|
|
{
|
|
playerHealth = _playerHealth;
|
|
playerHealth.HealthChanged += OnHealthChanged;
|
|
|
|
playerHealth.PushCurrentHealthValue();
|
|
}
|
|
|
|
public void OnHealthChanged(int _currentHealth, int _maxHealth)
|
|
{
|
|
view.UpdateHealth(_currentHealth, _maxHealth);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
playerHealth.HealthChanged -= OnHealthChanged;
|
|
}
|
|
}
|