using UnityEngine;

using System;
using System.Collections;

public class Lifebar : MonoBehaviour 
{

    private float _fLife;

    public float Life
    {
        get
        {
            return _fLife;
        }
    }

    public bool IsDead
    {
        get
        {
            return (_fLife <= 0f);
        }
    }

	void Start () 
    {
        _fLife = 1f;
	}
	
    public void AddDamage(float i_fDamage)
    {
        _fLife = Mathf.Max(0f, _fLife - i_fDamage);

        if (_fLife <= 0f)
        {
            // Game over.

            GameManager.Instance.EndMatch();

            Debug.Log("[" + gameObject.name + "] GAME OVER");
        }
    }

}
