Example #1
0
    public override void OnInteract(MasterChef chef)
    {
        if (BELONGS_TO != chef.playerType)
        {
            return;
        }

        if (transform.childCount == 0)
        {
            Debug.Log("check if hand is empty");
            //take food
            if (!chef.IsHandEmpty())
            {
                chef.GetFoodFromHand(this);
            }
            else
            {
                Debug.Log("hand is empty");
            }
        }
        else
        {
            //give food
            Food foodOnTray = GetComponentInChildren <Food>();
            foodOnTray.transform.SetParent(chef.transform);
            foodOnTray.transform.DOLocalMove(Vector3.zero, 0.3f).OnComplete(() => { chef.AddItemToHand(foodOnTray); Destroy(foodOnTray.gameObject); });
        }
    }
Example #2
0
    public override void OnInteract(MasterChef chef)
    {
        if (chef.IsHandFull())
        {
            return;
        }
        Food newFood     = DataManager.instance.GetFoodWithKey(KEY);
        Food foodSpawned = Instantiate(newFood, transform.position, Quaternion.identity);

        foodSpawned.transform.SetParent(chef.transform);
        foodSpawned.transform.DOLocalMove(Vector3.zero, 0.3f).OnComplete(() => { chef.AddItemToHand(foodSpawned); Destroy(foodSpawned.gameObject); });
    }