Exemplo n.º 1
0
    public void AddToList(FoodData _food)
    {
        FoodQuantityClass tempClass = foodList.Find(food => food.data.foodName.Equals(_food.foodName));

        FoodData newData = new FoodData
        {
            foodName = _food.foodName,
            sprite   = _food.sprite,
            foodCost = _food.foodCost
        };

        if (tempClass == null)
        {
            foodList.Add(new FoodQuantityClass(newData, 1));
        }
        else
        {
            tempClass.quantity++;
        }

        orderText.text = "Ordine (" + GetOrderLength() + ")";
    }
Exemplo n.º 2
0
    public void RemoveToList(FoodData _food)
    {
        FoodQuantityClass tempClass = foodList.Find(food => food.data.foodName.Equals(_food.foodName));

        if (tempClass == null)
        {
            return;
        }

        tempClass.quantity--;

        if (tempClass.quantity == 0)
        {
            foodList.Remove(tempClass);
        }

        if (foodList.Count == 0)
        {
            foodList.Clear();
            foodList.TrimExcess();
        }

        orderText.text = "Ordine (" + GetOrderLength() + ")";
    }