Exemplo n.º 1
0
    private void AttemptFoodTransfer(Pot pot)
    {
        //Debug.Log($"Attempt food transfer from {pot.name}");

        // check empty plate and pot food ready
        if (hasFood || !pot.IsFoodReady())
        {
            return;
        }

        // check pot is tilted over plate (dot product with 'up' vectors)
        bool potTilted = Vector3.Dot(pot.transform.up, Vector3.up) < 0f;

        if (!potTilted)
        {
            return;
        }

        // create content in plate
        this.content = pot.GetPotContent();
        foodObject.SetActive(true);
        foodObject.transform.localScale = Vector3.zero;
        foodObject.transform.DOScale(Vector3.one, 0.3f);

        // reset pot
        pot.Reset();

        // trigger plate content changed event for UI
        ContentChanged?.Invoke(content);
    }