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

public class PlateColScript : MonoBehaviour
{
    private Animator anim;
    private WaiterHandler wHandler;
    private bool touched = false;

	// Use this for initialization
	void Start ()
    {
        anim = transform.parent.parent.GetComponent<Animator>();
        wHandler = FindObjectOfType<WaiterHandler>();
	}

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "food")
        {
            anim.SetBool("FoodOnPlate", true);

            if(touched == false)
            {
                touched = true;
                wHandler.SpawnWaiter(false);
            }
        }
    }

    void OnTriggerExit2D(Collider2D other)
    {
        if (other.tag == "food")
        {
            anim.SetBool("FoodOnPlate", false);
        }
    }
}
