public void DisplayIngredient(PlantEffect.Ingredient newIngredient)
    {
        if (newIngredient == null)
        {
            Debug.LogError("new ingredient is null");
            return;
        }

        switch (newIngredient.ingredientType)
        {
        case PlantEffect.Ingredient.IngredientType.Rat:
            rats[newIngredient.ingredientColor].SetActive(true);
            break;

        case PlantEffect.Ingredient.IngredientType.Frog:
            frogs[newIngredient.ingredientColor].SetActive(true);
            break;

        case PlantEffect.Ingredient.IngredientType.Leg:
            legs[newIngredient.ingredientColor].SetActive(true);
            break;

        case PlantEffect.Ingredient.IngredientType.Doll:
            dolls[newIngredient.ingredientColor].SetActive(true);
            break;

        default:
            break;
        }
    }
Exemple #2
0
    public PlantEffect.Ingredient[] GenerateRandomRecipe()
    {
        ingredientSpawner = FindObjectOfType <IngredientSpawner>();
        ingredientSpawner.InitIngredientLists(currentRecipeSize);
        PlantEffect.Ingredient[] recipe = new PlantEffect.Ingredient[currentRecipeSize];
        for (int i = 0; i < currentRecipeSize; i++)
        {
            ingredientSpawner.currentBatch = i;
            recipe[i] = GenerateRandomIngredient();
            AddRecipeToDropList(recipe[i], 0);
            for (int j = 1; j < ingredientSpawner.ingredientsByBatch; j++)
            {
                AddRecipeToDropList(GenerateRandomIngredient(), j);
            }
        }
        ingredientSpawner.currentBatch = 0;

        var timePerRecipe     = PlayerPrefs.HasKey(recipeTime) ? PlayerPrefs.GetFloat(recipeTime) : defaultRecipeTime;
        var timePerIngredient = PlayerPrefs.HasKey(ingredientTime) ? PlayerPrefs.GetFloat(ingredientTime) : defaultIngredientTime;
        var newTime           = timePerRecipe + timePerIngredient * recipe.Length; // divide by number of player

        TimerManager.instance.SetNewTime(newTime);

        return(recipe);
    }
Exemple #3
0
    public PlantEffect.Ingredient GenerateRandomIngredient()
    {
        PlantEffect.Ingredient ingredient = new PlantEffect.Ingredient();

        int randomColor = Random.Range(0, colorAmount);

        ingredient.ingredientColor = randomColor;

        var ingredientTypes = System.Enum.GetNames(typeof(PlantEffect.Ingredient.IngredientType)).Length;
        int randomType      = Random.Range(0, ingredientTypes);

        ingredient.ingredientType = (PlantEffect.Ingredient.IngredientType)randomType;

        var curseTypes = System.Enum.GetNames(typeof(CurseManager.CurseType)).Length;

        CurseManager.CurseType randomCurse = (CurseManager.CurseType)Random.Range(0, curseTypes);
        ingredient.curseType = randomCurse;

        return(ingredient);
    }
Exemple #4
0
    //Check if plant is similar to the one we put inside the cauldron, and cast a curse otherwise
    public void CheckPlant(PlantEffect.Ingredient ingredient)
    {
        if (recipe[index].ingredientType == ingredient.ingredientType && recipe[index].ingredientColor == ingredient.ingredientColor)
        {
            cauldronAudioSource.PlayOneShot(cauldronGood);
            cauldronAnimator.Play("Happy");
            cauldronParticlesSmoke.Stop();

            if (index < RecipeManager.instance.currentRecipeSize - 1)
            {
                ingredientsUI[index].ToggleSelected();
                index++;
                ingredientsUI[index].ToggleSelected();
            }
            else
            {
                index = 0;
                foreach (var item in ingredientsUI)
                {
                    Destroy(item.gameObject);
                }
                ingredientsUI.Clear();
                recipeAnimator.SetTrigger("Close");
                cauldronAudioSource.PlayOneShot(cauldronApplause);
                score++;
                UpdateScore();
                RecipeManager.instance.IncreaseRecipeSize(true);
            }
        }
        else
        {
            CurseManager.instance.DoomPlayers();
            cauldronAudioSource.PlayOneShot(cauldronBad);
            cauldronAnimator.Play("Sad");
            cauldronParticlesSmoke.Play();
            CauldronFailed();
        }
    }
Exemple #5
0
 public void AddRecipeToDropList(PlantEffect.Ingredient recipe, int index)
 {
     ingredientSpawner.ingredientsLists[ingredientSpawner.currentBatch, index] = recipe;
 }