예제 #1
0
        private void UpdateLiquidcolor(DrinkState drink)
        {
            var   drinkSize        = drink.GetTotalDrinkSize();
            Color?accumulatedColor = null;

            foreach (var keyVar in drink.GetContents())
            {
                for (var i = 0; i < keyVar.Value; i++)
                {
                    if (accumulatedColor == null)
                    {
                        accumulatedColor = Ingredients.IngredientColorMap[keyVar.Key];
                    }
                    else
                    {
                        accumulatedColor += Ingredients.IngredientColorMap[keyVar.Key];
                    }
                }
            }
            if (accumulatedColor == null)
            {
                return;
            }
            accumulatedColor = accumulatedColor / drinkSize;
            DrinkContents.GetComponent <Renderer>().material.color = accumulatedColor.Value;
        }
예제 #2
0
 private void OnDrinkChanged()
 {
     DrinkContents.SetActive(drinkState.GetTotalDrinkSize() != 0);
     UpdateLiquidHeight(drinkState.GetTotalDrinkSize());
     UpdateLiquidcolor(drinkState);
 }