コード例 #1
0
ファイル: GlassFill.cs プロジェクト: openalphausc/bet
    void AddIngredient(GameObject ingredient)
    {
        // if 6 ingredients already in the drink, don't do anything
        if (currentDrink.GetAmount() >= 6)
        {
            GlassIsFullAlert(); //alert that tells the user the glass is full
            return;
        }

        // add ingredient to current drink
        bool isLiquid = currentDrink.AddIngredient(ingredient.name);

        // update drink sprite
        UpdateDrinkSprite();

        // play pouring sound
        if (isLiquid)
        {
            addLiquid.Play();
        }
        else
        {
            addTopping.Play();
        }
    }
コード例 #2
0
    // Gets the drink recipes from a CSV, stores in recipes List
    void GetRecipes()
    {
        // For each line in the CSV, set the drink name and the ingredients
        List <List <string> > csvResults = ReadCSV(recipeFile);

        for (int i = 0; i < csvResults.Count; i++)
        {
            Drink currentDrink = new Drink();
            bool  hasTopping   = false;
            for (int j = 0; j < csvResults[i].Count; j++)
            {
                if (j == 0)
                {
                    // Recipe name
                    currentDrink.name = csvResults[i][j];
                }
                else
                {
                    // Ingredient
                    if (!currentDrink.AddIngredient(csvResults[i][j]) && csvResults[i][j].Contains(";"))
                    {
                        string[] toppingManip = csvResults[i][j].Split(';');
                        currentDrink.AddIngredient(toppingManip[0]);
                        currentDrink.BlendToppings();
                        currentDrink.AddIngredient(toppingManip[1]);
                        hasTopping = true;
                    }
                }
            }

            if (!hasTopping)
            {
                currentDrink.BlendToppings();
            }
            recipes.Add(currentDrink);
        }
        recipes.Sort(new Drink.DrinkComp());
    }