using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Health : MonoBehaviour {
	public HealthBar healthBar;
	[SerializeField]float _maxHealth = 100;
	[SerializeField]float _currentHealth = 100;

	public float maxHealth 
	{
		get {return _maxHealth;}		
	}

	public float currentHealth
	{
		get {return this._currentHealth;}
	}

	public float healthPercent
	{
		get {return this._currentHealth/this._maxHealth;}
	}

	void Start()
	{
		this._currentHealth = this._maxHealth;
	}

	public void Damage(int damage)
	{
		this._currentHealth -=damage;
		if (this._currentHealth < 0)
		{
			this._currentHealth = 0;
		}

		if (healthBar) 
		{
			healthBar.SetBar(healthPercent);
		}
	}
}
