Exemple #1
0
    public bool ApplyIngredient(Ingredient ingredient, out bool stayHere)
    {
        if (!wig || (!ingredient && !actionStarted) || (ingredient && !wig.HasValidNextStepWith(ingredient)))
        {
            stayHere = false;
            return(false);
        }

        if (!actionStarted)
        {
            actionStarted = true;
            canvas.gameObject.SetActive(true);
            this.ingredient = ingredient;

            recipeBar.sprite = ingredient.data.progressionBar;

            ingredient.icon.gameObject.SetActive(false);
            ingredient.gameObject.SetActive(true);

            stayHere = true;

            return(true);
        }

        actionCounter += Time.deltaTime;

        float percent = Mathf.Clamp(actionCounter / this.ingredient.data.actionPressSeconds, 0f, 1f);

        progressBar.anchoredPosition = new Vector2(-mask.rect.width * (1 - percent), progressBar.anchoredPosition.y);

        if (actionCounter >= this.ingredient.data.actionPressSeconds)
        {
            actionStarted = false;
            actionCounter = 0f;

            IngredientData newIngredientData = RecipeManager.Instance.GetResultingIngredient(wig.data, this.ingredient.data);
            HairReferencer refer             = wig.GetComponent <HairReferencer>();

            hairMeshes[wig.data.wigIndex].gameObject.SetActive(false);
            refer.hairs[wig.data.wigIndex].gameObject.SetActive(false);
            wig.data = newIngredientData;
            hairMeshes[wig.data.wigIndex].gameObject.SetActive(true);
            refer.hairs[wig.data.wigIndex].gameObject.SetActive(true);

            Destroy(this.ingredient.gameObject);
            this.ingredient = null;
        }

        stayHere = true;

        return(false);
    }
Exemple #2
0
 private void Awake()
 {
     rb             = GetComponent <Rigidbody>();
     hairReferencer = GetComponent <HairReferencer>();
 }