Beispiel #1
0
    IEnumerator StartChopping(VegetableItem item)
    {
        Debug.Log("Start Chopping, chopping time:  " + item.ChoppingTime);
        timeSpentInChopping = 0;
        item.SetChopping(true);
        while (timeSpentInChopping < item.ChoppingTime)
        {
            float deltaTime = Time.deltaTime;
            yield return(new WaitForSeconds(deltaTime));

            timeSpentInChopping += deltaTime;
        }
        ChoppingEnd(item);
    }
Beispiel #2
0
    void ChoppingEnd(VegetableItem item)
    {
        currentState = KitchenStandState.CHOPPING_DONE;
        //chopped veg convertade to salad and add in salad list
        item.SetChopping(false);
        SaladItem salad;

        if (carrier.IsCarrying() && carrier.GetLastCarryingItem().Type == PickableType.SALAD)
        {
            salad = (SaladItem)carrier.GetLastCarryingItem();
            salad.AddItem(item);
        }
        else
        {
            salad = Instantiate(saladPrefab); //TODO use object pooling instead
            salad.AddItem(item);
            carrier.OnItemPickup(salad);
        }
        TriggerChoppingDoneEvent();
        Destroy(item, 0.1f);
    }