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

public class OnBorder : MonoBehaviour {

    public GameObject Player;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
    private void OnTriggerEnter2D(Collider2D other)
    {
        if(Player!=null)
        {
            GameObject food = other.gameObject;
            if(food.CompareTag("food") && Player.GetComponent<PointOfEffectController>().HasGrippedThatFood(food))
            {
                Player.GetComponent<PointOfEffectController>().ReleaseFood(food);

                if(food.transform.parent.GetComponent<Food>().wave!=null)
                {
                    food.transform.parent.GetComponent<Food>().wave.GetComponent<Wave>().subCounter(food.transform.parent.gameObject);
                    Player.GetComponentInParent<Player>().addScore();
                    Player.GetComponentInParent<Player>().UpdateStatus(food.GetComponentInParent<Food>().FoodHealthProperty);
                }
                    
            }
        }
    }
}
