示例#1
0
    public PouringPath getPathForDrinks(List <PouringDrink> drinks)
    {
        PouringPath result = new PouringPath(numPositions);


        for (int i = 0; i < numPositions; i++)
        {
            List <QuantifiedIngredient> validIngredients = new List <QuantifiedIngredient>();
            foreach (PouringDrink d in drinks)
            {
                int absoluteGlassPos = (i + d.glassPosition) % numPositions;

                List <QuantifiedIngredient> iList = getMixIngredientWithPositionForDrink(absoluteGlassPos, d);

                foreach (QuantifiedIngredient qi in iList)
                {
                    d.ingredientStates[qi] = true;
                    validIngredients.Add(qi);
                }
            }

            if (validIngredients.Count > 0)
            {
                PouringStep s = new PouringStep();
                s.targetPosition = i;
                s.ingredients    = validIngredients;
                result.steps.Add(s);
            }
        }

        return(result);
    }
示例#2
0
    public PouringPath generatePouringPath()
    {
        //Generate here
        List <PouringDrink> pdList = new List <PouringDrink>();

        foreach (OBSGlass g in plate.glasses)
        {
            PouringDrink pd = new PouringDrink();
            pd.glassPosition = g.pos;
            DrinkMix mix = mixes[g.plug];

            //Debug.Log("Glass at pos " + g.pos + " will get mix " + mix.mixName);
            foreach (QuantifiedIngredient qi in mix.ingredients)
            {
                //Debug.Log(" > Ingredient " + qi.ingredientName);
                pd.ingredientStates.Add(qi.Clone(), false);
            }

            pdList.Add(pd);
        }

        PouringPath p = getPathForDrinks(pdList);

        return(p);
    }
示例#3
0
    public void startPouring()
    {
        PouringPath p = generatePouringPath();

        p.Shuffle();
        //

        if (pourCoroutine != null)
        {
            StopCoroutine(pourCoroutine);
        }
        pourCoroutine = StartCoroutine(pourSequence(p));
    }
示例#4
0
    IEnumerator pourSequence(PouringPath path)
    {
        Debug.Log("Pour sequence " + path);

        float totalTime = 0;
        //plate.goHome();
        //yield return new WaitForSeconds(stepTransitionTime + .5f);

        int currentPosition = 0;

        foreach (PouringStep s in path.steps)
        {
            float posDist = path.getMinDistanceBetween(s.targetPosition, currentPosition, path.numPositions);
            float targetTransitionTime = stepTransitionTime + (posDist - 1) * additionalStepTransitionTime;

            float maxTime = 0;

            foreach (QuantifiedIngredient qi in s.ingredients)
            {
                int targetGlass = (getMixIngredientWithName(qi.ingredientName).platePosition + s.targetPosition) % numPositions;

                float t = qi.quantity * pouringQuantityFactor / 100.0f;

                LiquidJet j = jets[qi.ingredientName];

                float anticipation        = Mathf.Min(jetAnticipation * j.jetTimeToGlass, targetTransitionTime);
                float inverseAnticipation = targetTransitionTime - anticipation;

                float targetPourTime = t + j.jetTimeToGlass - anticipation;

                //Debug.Log("Serving " + qi.ingredientName + " for " + t + ", targetPourTime =" + targetPourTime);

                if (targetPourTime > maxTime)
                {
                    maxTime = targetPourTime;
                }

                j.launch(inverseAnticipation, t); //launch with anticipation delay
            }

            plate.goToPosition(s.targetPosition, targetTransitionTime);
            currentPosition = s.targetPosition;

            float waitTime = targetTransitionTime + maxTime;
            totalTime += waitTime;
            yield return(new WaitForSeconds(waitTime)); //do nothing while moving then do nothing while serving
        }

        Debug.Log("Sequence finished in " + totalTime + " seconds !");
        plate.goHome();
    }