예제 #1
0
        private void UpdateView()
        {
            var ingredients = _burger.CurrentIngredients.Value;

            if (ingredients.Contains(Ingredient.Bread))
            {
                _ingredientViews[0].Renderer.sprite = _spriteSelector.GetBread()[0];

                var ingredienstWithoutBread = ingredients.Where(ingr => ingr != Ingredient.Bread).ToList();

                for (var i = 0; i < _maxIngredients - 1; i++)
                {
                    if (i < ingredienstWithoutBread.Count)
                    {
                        _ingredientViews[i + 1].Renderer.sprite = _spriteSelector.GetIngredientSprite(ingredienstWithoutBread[i]);
                    }
                    else
                    {
                        _ingredientViews[i + 1].Renderer.sprite = _spriteSelector.GetIngredientSprite(Ingredient.None);
                    }
                }

                _ingredientViews[ingredienstWithoutBread.Count + 1].Renderer.sprite = _spriteSelector.GetBread()[1];
            }
            else
            {
                for (var i = 0; i < _maxIngredients; i++)
                {
                    if (i < ingredients.Count)
                    {
                        _ingredientViews[i].Renderer.sprite = _spriteSelector.GetIngredientSprite(ingredients[i]);
                    }
                    else
                    {
                        _ingredientViews[i].Renderer.sprite = _spriteSelector.GetIngredientSprite(Ingredient.None);
                    }
                }
            }
        }