Ejemplo n.º 1
0
    public void Mix()
    {
        if (counter == 0 || !ready)
        {
            Reset();
            return;
        }

        mix["Milk"] = (int)milk.value;
        bool correct = false;

        foreach (MilkTea mt in drinkList.GetComponentsInChildren <MilkTea>())
        {
            if (mt.CheckOrder(mix))
            {
                drink.GetComponent <SpriteRenderer>().sprite = mt.GetImage(0);
                int current = 0;
                for (int i = toppings.Count - 1; i > 0; i--)
                {
                    if (mix[toppings[i]] > current)
                    {
                        drink.GetComponent <SpriteRenderer>().sprite = mt.GetImage(i);
                        mix["Topping"] = i;
                        break;
                    }
                }

                correct = true;
                break;
            }
        }

        if (!correct)
        {
            drink.GetComponent <SpriteRenderer>().sprite = garbage;
            mix["Topping"] = 0;
        }

        money.ChangeTotal(-1);
        drink.GetComponent <Drink>().SetMix(mix);
        drink.GetComponent <Collider2D>().enabled = true;
        Reset();
    }