using UnityEngine;
using System.Collections;

public class Plant : MonoBehaviour 
{

	public float AttackRate;
    private float lastAttackTime = -1f;
    public bool canAttack = false;
	void Start ()
    {
	
	}


    void OnTriggerStay2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            canAttack = true;
        }
    }

    void OnTriggerExit2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            canAttack = false;
        }
    }

    void Update()
    {
        if (Time.time > lastAttackTime + 1 / AttackRate)
        {
            if(canAttack)
            {
               // NotificationCenter.DefaultCenter().PostNotification(this,"PlayerIsDead");
                Debug.Log("Player is dead");
            }
            lastAttackTime = Time.time;
        }

    }

}
